Package org.astrogrid.samp.web

# Class WebClientProfile

java.lang.Object
org.astrogrid.samp.web.WebClientProfile

All Implemented Interfaces:
  `ClientProfile`

public class WebClientProfile extends Object implements ClientProfile
ClientProfile implementation for Web Profile.

Since:
  3 Feb 2011
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`URLTRANS_KEY`
RegInfo map key for URL translation service base URL ("samp.url-translator").
`static final String`
`WEBPROFILE_HUB_PREFIX`
Prefix in SAMP_HUB value indicating web profile application name ("web-appname:").
`static final String`
`WEBSAMP_CLIENT_PREFIX`
Prefix to client interface opeation names for XML-RPC method names ("").
`static final String`
`WEBSAMP_HUB_PREFIX`
Prefix to hub interface operation names for XML-RPC method names ("samp.webhub.").
`static final String`
`WEBSAMP_PATH`
Path on WEBSAMP_PORT web server at which XML-RPC server lives ("/").
`static final int`
`WEBSAMP_PORT`
Web Profile hub port number (21012).

## Constructor Summary

Constructors
Constructor
Description
`WebClientProfile()`
Constructor with no arguments.
`WebClientProfile(String appName)`
Constructor with declared client name.
`WebClientProfile(Map securityMap, SampXmlRpcClientFactory xClientFactory, URL hubEndpoint)`
Constructor with configuration options.

## Method Summary

Modifier and Type
Method
Description
`static String`
`getDefaultAppName()`
Returns the default application name used by this profile if none is supplied explicitly.
`static URL`
`getDefaultHubEndpoint()`
Returns the hub XML-RPC endpoint defined by the Web Profile.
`URL`
`getHubEndpoint()`
Returns the hub XML-RPC endpoint used by this profile.
`static WebClientProfile`
`getInstance()`
Returns a default instance of this profile.
`boolean`
`isHubRunning()`
Indicates whether a hub contactable by this profile appears to be running.
`HubConnection`
`register()`
Attempts to register with a SAMP hub and return a corresponding connection object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### WEBSAMP_PORT

public static final int WEBSAMP_PORT
Web Profile hub port number (21012).

See Also:
  - Constant Field Values

### WEBSAMP_PATH

public static final String WEBSAMP_PATH
Path on WEBSAMP_PORT web server at which XML-RPC server lives ("/").

See Also:
  - Constant Field Values

### WEBSAMP_HUB_PREFIX

public static final String WEBSAMP_HUB_PREFIX
Prefix to hub interface operation names for XML-RPC method names ("samp.webhub.").

See Also:
  - Constant Field Values

### WEBSAMP_CLIENT_PREFIX

public static final String WEBSAMP_CLIENT_PREFIX
Prefix to client interface opeation names for XML-RPC method names ("").

See Also:
  - Constant Field Values

### URLTRANS_KEY

public static final String URLTRANS_KEY
RegInfo map key for URL translation service base URL ("samp.url-translator").

See Also:
  - Constant Field Values

### WEBPROFILE_HUB_PREFIX

public static final String WEBPROFILE_HUB_PREFIX
Prefix in SAMP_HUB value indicating web profile application name ("web-appname:").

See Also:
  - Constant Field Values

## Constructor Details

### WebClientProfile

public WebClientProfile(Map securityMap, SampXmlRpcClientFactory xClientFactory, URL hubEndpoint)
Constructor with configuration options.

Parameters:
  `securityMap` - map containing security information for registration
  `xClientFactory` - XML-RPC client factory
  `hubEndpoint` - XML-RPC endpoint for hub server

### WebClientProfile

public WebClientProfile(String appName)
Constructor with declared client name.

Parameters:
  `appName` - client's declared application name (samp.name entry in security-info map)

### WebClientProfile

public WebClientProfile()
Constructor with no arguments. The client's declared application name will be as given by `getDefaultAppName()`.

## Method Details

### isHubRunning

public boolean isHubRunning()
Description copied from interface: `ClientProfile`
Indicates whether a hub contactable by this profile appears to be running. This is intended to execute reasonably quickly. It should not go as far as registering.

Specified by:
  `isHubRunning` in interface `ClientProfile`
Returns:
  true iff it looks like a hub is running

### register

public HubConnection register() throws SampException
Description copied from interface: `ClientProfile`
Attempts to register with a SAMP hub and return a corresponding connection object. Some profile-specific hub discovery mechanism is used to locate the hub. If no hub is running, null will normally be returned.

Specified by:
  `register` in interface `ClientProfile`
Returns:
  hub connection representing a new registration, or null
Throws:
  `SampException` - in case of some unexpected error

### getHubEndpoint

public URL getHubEndpoint()
Returns the hub XML-RPC endpoint used by this profile.

Returns:
  hub endpoint URL

### getDefaultHubEndpoint

public static URL getDefaultHubEndpoint()
Returns the hub XML-RPC endpoint defined by the Web Profile.

Returns:
  Web Profile hub endpoint URL

### getInstance

public static WebClientProfile getInstance()
Returns a default instance of this profile.

Returns:
  default web client profile instance

### getDefaultAppName

public static String getDefaultAppName()
Returns the default application name used by this profile if none is supplied explicitly. If the SAMP_HUB environment variable has the form "web-appname:<appname>" it is taken from there; otherwise it's something like "Unknown".

Returns:
  default declared client name