Class HubXmlRpcHandler.HubActorImpl

  • All Implemented Interfaces:
    HubActor
    Enclosing class:
    HubXmlRpcHandler

    private static class HubXmlRpcHandler.HubActorImpl
    extends java.lang.Object
    implements HubActor
    Implementation of the HubActor interface which does the work for this class. Apart from a few methods which have Standard-Profile-specific aspects, the work is simply delegated to the hub connection factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String call​(java.lang.String privateKey, java.lang.String recipientId, java.lang.String msgTag, java.util.Map msg)
      Sends a message to a given client expecting a response.
      java.util.Map callAll​(java.lang.String privateKey, java.lang.String msgTag, java.util.Map msg)
      Sends a message to all subscribed clients expecting responses.
      java.util.Map callAndWait​(java.lang.String privateKey, java.lang.String recipientId, java.util.Map msg, java.lang.String timeoutStr)
      Sends a message synchronously to a client.
      void declareMetadata​(java.lang.String privateKey, java.util.Map metadata)
      Declares metadata for the calling client.
      void declareSubscriptions​(java.lang.String privateKey, java.util.Map subs)
      Declares subscription information for the calling client.
      private HubConnection getConnection​(java.lang.String privateKey)
      Returns the HubConnection associated with a private key used by this hub actor.
      java.util.Map getMetadata​(java.lang.String privateKey, java.lang.String clientId)
      Returns metadata for a given client.
      java.util.List getRegisteredClients​(java.lang.String privateKey)
      Returns a list of the public-ids of all currently registered clients.
      java.util.Map getSubscribedClients​(java.lang.String privateKey, java.lang.String mtype)
      Returns a map of the clients subscribed to a given MType.
      java.util.Map getSubscriptions​(java.lang.String privateKey, java.lang.String clientId)
      Returns subscriptions for a given client.
      void notify​(java.lang.String privateKey, java.lang.String recipientId, java.util.Map msg)
      Sends a message to a given client without wanting a response.
      java.util.List notifyAll​(java.lang.String privateKey, java.util.Map msg)
      Sends a message to all subscribed clients without wanting a response.
      void ping()
      Throws an exception if service is not operating.
      void ping​(java.lang.String privateKey)
      Throws an exception if service is not operating.
      java.util.Map register​(java.lang.String secret)
      Registers a new client and returns a map with registration information.
      void reply​(java.lang.String privateKey, java.lang.String msgId, java.util.Map response)
      Responds to a previously sent message.
      void setXmlrpcCallback​(java.lang.String privateKey, java.lang.String surl)
      Sets the XML-RPC URL to use for callbacks for a callable client.
      void unregister​(java.lang.String privateKey)
      Unregisters a registered client.
      • Methods inherited from class java.lang.Object

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

      • secret_

        private final java.lang.String secret_
      • clientMap_

        private final java.util.Map clientMap_
    • Constructor Detail

      • HubActorImpl

        HubActorImpl​(SampXmlRpcClientFactory xClientFactory,
                     ClientProfile profile,
                     java.lang.String secret,
                     KeyGenerator keyGen)
        Constructor.
        Parameters:
        xClientFactory - XML-RPC client factory implementation
        profile - hub connection factory
        secret - password required for client registration
        keyGen - generator for private keys
    • Method Detail

      • register

        public java.util.Map register​(java.lang.String secret)
                               throws SampException
        Description copied from interface: HubActor
        Registers a new client and returns a map with registration information.
        Specified by:
        register in interface HubActor
        Parameters:
        secret - registration password
        Returns:
        RegInfo-like map.
        Throws:
        SampException
      • unregister

        public void unregister​(java.lang.String privateKey)
                        throws SampException
        Description copied from interface: HubActor
        Unregisters a registered client.
        Specified by:
        unregister in interface HubActor
        Parameters:
        privateKey - calling client private key
        Throws:
        SampException
      • ping

        public void ping​(java.lang.String privateKey)
                  throws SampException
        Description copied from interface: HubActor
        Throws an exception if service is not operating.
        Specified by:
        ping in interface HubActor
        Parameters:
        privateKey - ignored
        Throws:
        SampException
      • setXmlrpcCallback

        public void setXmlrpcCallback​(java.lang.String privateKey,
                                      java.lang.String surl)
                               throws SampException
        Description copied from interface: HubActor
        Sets the XML-RPC URL to use for callbacks for a callable client.
        Specified by:
        setXmlrpcCallback in interface HubActor
        Parameters:
        privateKey - calling client private key
        surl - XML-RPC endpoint for client API callbacks
        Throws:
        SampException
      • declareMetadata

        public void declareMetadata​(java.lang.String privateKey,
                                    java.util.Map metadata)
                             throws SampException
        Description copied from interface: HubActor
        Declares metadata for the calling client.
        Specified by:
        declareMetadata in interface HubActor
        Parameters:
        privateKey - calling client private key
        metadata - Metadata-like map
        Throws:
        SampException
      • getMetadata

        public java.util.Map getMetadata​(java.lang.String privateKey,
                                         java.lang.String clientId)
                                  throws SampException
        Description copied from interface: HubActor
        Returns metadata for a given client.
        Specified by:
        getMetadata in interface HubActor
        Parameters:
        privateKey - calling client private key
        clientId - public ID for client whose metadata is required
        Returns:
        Metadata-like map
        Throws:
        SampException
      • declareSubscriptions

        public void declareSubscriptions​(java.lang.String privateKey,
                                         java.util.Map subs)
                                  throws SampException
        Description copied from interface: HubActor
        Declares subscription information for the calling client.
        Specified by:
        declareSubscriptions in interface HubActor
        Parameters:
        privateKey - calling client private key
        subs - Subscriptions-like map
        Throws:
        SampException
      • getSubscriptions

        public java.util.Map getSubscriptions​(java.lang.String privateKey,
                                              java.lang.String clientId)
                                       throws SampException
        Description copied from interface: HubActor
        Returns subscriptions for a given client.
        Specified by:
        getSubscriptions in interface HubActor
        Parameters:
        privateKey - calling client private key
        Returns:
        Subscriptions-like map
        Throws:
        SampException
      • getRegisteredClients

        public java.util.List getRegisteredClients​(java.lang.String privateKey)
                                            throws SampException
        Description copied from interface: HubActor
        Returns a list of the public-ids of all currently registered clients.
        Specified by:
        getRegisteredClients in interface HubActor
        Parameters:
        privateKey - calling client private key
        Returns:
        list of Strings
        Throws:
        SampException
      • getSubscribedClients

        public java.util.Map getSubscribedClients​(java.lang.String privateKey,
                                                  java.lang.String mtype)
                                           throws SampException
        Description copied from interface: HubActor
        Returns a map of the clients subscribed to a given MType.
        Specified by:
        getSubscribedClients in interface HubActor
        Parameters:
        privateKey - calling client private key
        mtype - MType of interest
        Returns:
        map in which the keys are the public-ids of clients subscribed to mtype
        Throws:
        SampException
      • notify

        public void notify​(java.lang.String privateKey,
                           java.lang.String recipientId,
                           java.util.Map msg)
                    throws SampException
        Description copied from interface: HubActor
        Sends a message to a given client without wanting a response.
        Specified by:
        notify in interface HubActor
        Parameters:
        privateKey - calling client private key
        recipientId - public-id of client to receive message
        msg - Message-like map
        Throws:
        SampException
      • notifyAll

        public java.util.List notifyAll​(java.lang.String privateKey,
                                        java.util.Map msg)
                                 throws SampException
        Description copied from interface: HubActor
        Sends a message to all subscribed clients without wanting a response.
        Specified by:
        notifyAll in interface HubActor
        Parameters:
        privateKey - calling client private key
        msg - Message-like map
        Returns:
        list of public-ids for clients to which the notify will be sent
        Throws:
        SampException
      • call

        public java.lang.String call​(java.lang.String privateKey,
                                     java.lang.String recipientId,
                                     java.lang.String msgTag,
                                     java.util.Map msg)
                              throws SampException
        Description copied from interface: HubActor
        Sends a message to a given client expecting a response.
        Specified by:
        call in interface HubActor
        Parameters:
        privateKey - calling client private key
        recipientId - public-id of client to receive message
        msgTag - arbitrary string tagging this message for caller's benefit
        msg - Message-like map
        Returns:
        message ID
        Throws:
        SampException
      • callAll

        public java.util.Map callAll​(java.lang.String privateKey,
                                     java.lang.String msgTag,
                                     java.util.Map msg)
                              throws SampException
        Description copied from interface: HubActor
        Sends a message to all subscribed clients expecting responses.
        Specified by:
        callAll in interface HubActor
        Parameters:
        privateKey - calling client private key
        msgTag - arbitrary string tagging this message for caller's benefit
        msg - Message-like map
        Returns:
        public-id->msg-id map for clients to which an attempt to send the call will be made
        Throws:
        SampException
      • callAndWait

        public java.util.Map callAndWait​(java.lang.String privateKey,
                                         java.lang.String recipientId,
                                         java.util.Map msg,
                                         java.lang.String timeoutStr)
                                  throws SampException
        Description copied from interface: HubActor
        Sends a message synchronously to a client.
        Specified by:
        callAndWait in interface HubActor
        Parameters:
        privateKey - calling client private key
        recipientId - public-id of client to receive message
        msg - Message-like map
        timeoutStr - timeout in seconds encoded as a SAMP int
        Returns:
        Response-like map
        Throws:
        SampException
      • reply

        public void reply​(java.lang.String privateKey,
                          java.lang.String msgId,
                          java.util.Map response)
                   throws SampException
        Description copied from interface: HubActor
        Responds to a previously sent message.
        Specified by:
        reply in interface HubActor
        Parameters:
        privateKey - calling client private key
        msgId - ID associated with earlier send
        response - Response-like map
        Throws:
        SampException
      • getConnection

        private HubConnection getConnection​(java.lang.String privateKey)
                                     throws SampException
        Returns the HubConnection associated with a private key used by this hub actor.
        Parameters:
        privateKey - private key
        Returns:
        connection for privateKey
        Throws:
        SampException