Class StandardHubProfile

  • All Implemented Interfaces:
    HubProfile, ProfileToken

    public class StandardHubProfile
    extends java.lang.Object
    implements HubProfile
    HubProfile implementation for the SAMP Standard Profile.
    Since:
    31 Jan 2011
    Author:
    Mark Taylor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String createSecret()
      Returns a string suitable for use as a Standard Profile Secret.
      LockInfo getLockInfo()
      Returns the lockfile information associated with this object.
      MessageRestriction getMessageRestriction()
      Returns a MessageRestriction object which controls what messages may be sent by clients registering under ths profile.
      java.lang.String getProfileName()
      Returns the name of this profile.
      boolean isRunning()
      Indicates whether this profile is currently running.
      java.net.URL publishLockfile()
      Returns an HTTP URL at which the lockfile for this hub can be found.
      void start​(ClientProfile profile)
      Starts this profile's activity allowing access to a given supplier of hub connections.
      void stop()
      Ends this profile's activity on behalf of the hub.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StandardHubProfile

        public StandardHubProfile​(SampXmlRpcClientFactory xClientFactory,
                                  SampXmlRpcServerFactory xServerFactory,
                                  java.io.File lockfile,
                                  java.lang.String secret)
        Constructs a hub profile with given configuration information. If the supplied lockfile is null, no lockfile will be written at hub startup.
        Parameters:
        xClientFactory - XML-RPC client factory implementation
        xServerFactory - XML-RPC server implementation
        lockfile - location to use for hub lockfile, or null
        secret - value for samp.secret lockfile key
      • StandardHubProfile

        public StandardHubProfile()
                           throws java.io.IOException
        Constructs a hub profile with default configuration.
        Throws:
        java.io.IOException
    • Method Detail

      • getMessageRestriction

        public MessageRestriction getMessageRestriction()
        Description copied from interface: ProfileToken
        Returns a MessageRestriction object which controls what messages may be sent by clients registering under ths profile. If null is returned, any messages may be sent.
        Specified by:
        getMessageRestriction in interface ProfileToken
        Returns:
        message restriction, or null
      • start

        public void start​(ClientProfile profile)
                   throws java.io.IOException
        Description copied from interface: HubProfile
        Starts this profile's activity allowing access to a given supplier of hub connections.
        Specified by:
        start in interface HubProfile
        Parameters:
        profile - object which can provide hub connections
        Throws:
        java.io.IOException
      • isRunning

        public boolean isRunning()
        Description copied from interface: HubProfile
        Indicates whether this profile is currently running.
        Specified by:
        isRunning in interface HubProfile
        Returns:
        true iff profile is running
      • stop

        public void stop()
        Description copied from interface: HubProfile
        Ends this profile's activity on behalf of the hub. Any resources associated with the profile should be released. This does not include messaging registered clients about profile termination; that should be taken care of by the user of this profile.
        Specified by:
        stop in interface HubProfile
      • getLockInfo

        public LockInfo getLockInfo()
        Returns the lockfile information associated with this object. Only present when running.
        Returns:
        lock info
      • publishLockfile

        public java.net.URL publishLockfile()
                                     throws java.io.IOException
        Returns an HTTP URL at which the lockfile for this hub can be found. The first call to this method causes the lockfile to be published in this way; subsequent calls return the same value.

        Use this with care; publishing your lockfile means that other people can connect to your hub and potentially do disruptive things.

        Returns:
        lockfile information URL
        Throws:
        java.io.IOException
      • createSecret

        public static java.lang.String createSecret()
        Returns a string suitable for use as a Standard Profile Secret.
        Returns:
        new secret