org.astrogrid.samp.xmlrpc
Class StandardClientProfile

java.lang.Object
  extended by org.astrogrid.samp.xmlrpc.StandardClientProfile
All Implemented Interfaces:
ClientProfile

public class StandardClientProfile
extends 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
static String LOCKFILE_NAME
          Filename used for lockfile in home directory by default (".samp").
static String STDPROFILE_HUB_PREFIX
          Prefix in SAMP_HUB value indicating lockfile URL ("std-lockurl:").
 
Constructor Summary
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
static URL getDefaultLockUrl()
          Returns the lockfile URL which will be used in absence of any SAMP_HUB environment variable.
static StandardClientProfile getInstance()
          Returns an instance based on the default XML-RPC implementation.
 LockInfo getLockInfo()
          Returns the LockInfo which indicates how to locate the hub.
static URL getLockUrl()
          Returns the location of the Standard Profile lockfile.
 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 Detail

LOCKFILE_NAME

public static final String LOCKFILE_NAME
Filename used for lockfile in home directory by default (".samp").

See Also:
Constant Field Values

STDPROFILE_HUB_PREFIX

public static final 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 implementation
xServerFactory - 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: 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

getLockInfo

public LockInfo getLockInfo()
                     throws 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 returns LockInfo.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

public static URL getLockUrl()
                      throws IOException
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

public static URL getDefaultLockUrl()
                             throws IOException
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

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()


Copyright © 2008-2011 AstroGrid. All Rights Reserved.