Package org.astrogrid.samp.xmlrpc
Class StandardClientProfile
java.lang.Object
org.astrogrid.samp.xmlrpc.StandardClientProfile
- All Implemented Interfaces:
ClientProfile
Standard Profile implementation of ClientProfile.
It is normally appropriate to use one of the static methods
to obtain an instance based on a particular XML-RPC implementation.
- Since:
- 15 Jul 2008
- Author:
- Mark Taylor
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStandardClientProfile
(SampXmlRpcClientFactory xClientFactory, SampXmlRpcServerFactory xServerFactory) Constructs a profile given client and server factory implementations.StandardClientProfile
(XmlRpcKit xmlrpc) Constructs a profile given an XmlRpcKit object. -
Method Summary
Modifier and TypeMethodDescriptionstatic URL
Returns the lockfile URL which will be used in absence of any SAMP_HUB environment variable.static StandardClientProfile
Returns an instance based on the default XML-RPC implementation.Returns the LockInfo which indicates how to locate the hub.static URL
Returns the location of the Standard Profile lockfile.boolean
Indicates whether a hub contactable by this profile appears to be running.register()
Attempts to register with a SAMP hub and return a corresponding connection object.
-
Field Details
-
LOCKFILE_NAME
Filename used for lockfile in home directory by default (".samp").- See Also:
-
STDPROFILE_HUB_PREFIX
Prefix in SAMP_HUB value indicating lockfile URL ("std-lockurl:").- See Also:
-
-
Constructor Details
-
StandardClientProfile
public StandardClientProfile(SampXmlRpcClientFactory xClientFactory, SampXmlRpcServerFactory xServerFactory) Constructs a profile given client and server factory implementations.- Parameters:
xClientFactory
- XML-RPC client factory implementationxServerFactory
- XML-RPC server factory implementation
-
StandardClientProfile
Constructs a profile given an XmlRpcKit object.- Parameters:
xmlrpc
- XML-RPC implementation
-
-
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 interfaceClientProfile
- Returns:
- true iff it looks like a hub is running
-
register
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
-
getLockInfo
Returns the LockInfo which indicates how to locate the hub. If no lockfile exists (probably becuause no appropriate hub is running), null is returned. The default implementation returnsLockInfo.readLockFile(getLockUrl())
; it may be overridden to provide a non-standard client profiles.- Returns:
- hub location information
- Throws:
IOException
- if the lockfile exists but cannot be read for some reason
-
getLockUrl
Returns the location of the Standard Profile lockfile. By default this is the file.samp
in the user's "home" directory, unless overridden by a value of the SAMP_HUB environment variable starting with "std-lockurl".- Returns:
- lockfile URL
- Throws:
IOException
-
getDefaultLockUrl
Returns the lockfile URL which will be used in absence of any SAMP_HUB environment variable.- Returns:
- URL for file .samp in user's home directory
- Throws:
IOException
-
getInstance
Returns an instance based on the default XML-RPC implementation. This can be configured using system properties.- Returns:
- a client profile instance
- See Also:
-