Package org.astrogrid.samp.xmlrpc
Class StandardClientProfile
- java.lang.Object
-
- org.astrogrid.samp.xmlrpc.StandardClientProfile
-
- All Implemented Interfaces:
ClientProfile
public class StandardClientProfile extends java.lang.Object implements 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 Modifier and Type Field Description static java.lang.StringLOCKFILE_NAMEFilename used for lockfile in home directory by default (".samp").static java.lang.StringSTDPROFILE_HUB_PREFIXPrefix in SAMP_HUB value indicating lockfile URL ("std-lockurl:").
-
Constructor Summary
Constructors Constructor Description StandardClientProfile(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.net.URLgetDefaultLockUrl()Returns the lockfile URL which will be used in absence of any SAMP_HUB environment variable.static StandardClientProfilegetInstance()Returns an instance based on the default XML-RPC implementation.LockInfogetLockInfo()Returns the LockInfo which indicates how to locate the hub.static java.net.URLgetLockUrl()Returns the location of the Standard Profile lockfile.booleanisHubRunning()Indicates whether a hub contactable by this profile appears to be running.HubConnectionregister()Attempts to register with a SAMP hub and return a corresponding connection object.
-
-
-
Field Detail
-
LOCKFILE_NAME
public static final java.lang.String LOCKFILE_NAME
Filename used for lockfile in home directory by default (".samp").- See Also:
- Constant Field Values
-
STDPROFILE_HUB_PREFIX
public static final java.lang.String STDPROFILE_HUB_PREFIX
Prefix in SAMP_HUB value indicating lockfile URL ("std-lockurl:").- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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
public StandardClientProfile(XmlRpcKit xmlrpc)
Constructs a profile given an XmlRpcKit object.- Parameters:
xmlrpc- XML-RPC implementation
-
-
Method Detail
-
isHubRunning
public boolean isHubRunning()
Description copied from interface:ClientProfileIndicates 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:
isHubRunningin interfaceClientProfile- Returns:
- true iff it looks like a hub is running
-
register
public HubConnection register() throws SampException
Description copied from interface:ClientProfileAttempts 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:
registerin interfaceClientProfile- Returns:
- hub connection representing a new registration, or null
- Throws:
SampException- in case of some unexpected error
-
getLockInfo
public LockInfo getLockInfo() throws java.io.IOException
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:
java.io.IOException- if the lockfile exists but cannot be read for some reason
-
getLockUrl
public static java.net.URL getLockUrl() throws java.io.IOExceptionReturns the location of the Standard Profile lockfile. By default this is the file.sampin the user's "home" directory, unless overridden by a value of the SAMP_HUB environment variable starting with "std-lockurl".- Returns:
- lockfile URL
- Throws:
java.io.IOException
-
getDefaultLockUrl
public static java.net.URL getDefaultLockUrl() throws java.io.IOExceptionReturns 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:
java.io.IOException
-
getInstance
public static StandardClientProfile 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:
XmlRpcKit.getInstance(),DefaultClientProfile.getProfile()
-
-