Package org.astrogrid.samp.web
Class WebClientProfile
- java.lang.Object
-
- org.astrogrid.samp.web.WebClientProfile
-
- All Implemented Interfaces:
ClientProfile
public class WebClientProfile extends java.lang.Object implements ClientProfile
ClientProfile implementation for Web Profile.- Since:
- 3 Feb 2011
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
URLTRANS_KEY
RegInfo map key for URL translation service base URL ("samp.url-translator").static java.lang.String
WEBPROFILE_HUB_PREFIX
Prefix in SAMP_HUB value indicating web profile application name ("web-appname:").static java.lang.String
WEBSAMP_CLIENT_PREFIX
Prefix to client interface opeation names for XML-RPC method names ("").static java.lang.String
WEBSAMP_HUB_PREFIX
Prefix to hub interface operation names for XML-RPC method names ("samp.webhub.").static java.lang.String
WEBSAMP_PATH
Path on WEBSAMP_PORT web server at which XML-RPC server lives ("/").static int
WEBSAMP_PORT
Web Profile hub port number (21012).
-
Constructor Summary
Constructors Constructor Description WebClientProfile()
Constructor with no arguments.WebClientProfile(java.lang.String appName)
Constructor with declared client name.WebClientProfile(java.util.Map securityMap, SampXmlRpcClientFactory xClientFactory, java.net.URL hubEndpoint)
Constructor with configuration options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getDefaultAppName()
Returns the default application name used by this profile if none is supplied explicitly.static java.net.URL
getDefaultHubEndpoint()
Returns the hub XML-RPC endpoint defined by the Web Profile.java.net.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.
-
-
-
Field Detail
-
WEBSAMP_PORT
public static final int WEBSAMP_PORT
Web Profile hub port number (21012).- See Also:
- Constant Field Values
-
WEBSAMP_PATH
public static final java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String WEBPROFILE_HUB_PREFIX
Prefix in SAMP_HUB value indicating web profile application name ("web-appname:").- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WebClientProfile
public WebClientProfile(java.util.Map securityMap, SampXmlRpcClientFactory xClientFactory, java.net.URL hubEndpoint)
Constructor with configuration options.- Parameters:
securityMap
- map containing security information for registrationxClientFactory
- XML-RPC client factoryhubEndpoint
- XML-RPC endpoint for hub server
-
WebClientProfile
public WebClientProfile(java.lang.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 bygetDefaultAppName()
.
-
-
Method Detail
-
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 interfaceClientProfile
- 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 interfaceClientProfile
- Returns:
- hub connection representing a new registration, or null
- Throws:
SampException
- in case of some unexpected error
-
getHubEndpoint
public java.net.URL getHubEndpoint()
Returns the hub XML-RPC endpoint used by this profile.- Returns:
- hub endpoint URL
-
getDefaultHubEndpoint
public static java.net.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 java.lang.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
-
-