Class 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.String LOCKFILE_NAME
      Filename used for lockfile in home directory by default (".samp").
      static java.lang.String STDPROFILE_HUB_PREFIX
      Prefix in SAMP_HUB value indicating lockfile URL ("std-lockurl:").
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.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 java.net.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 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 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 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 returns LockInfo.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.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:
        java.io.IOException
      • getDefaultLockUrl

        public static java.net.URL getDefaultLockUrl()
                                              throws java.io.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:
        java.io.IOException