org.jlab.coda.cMsg.cMsgDomain.server
Class cMsgServerSubscribeInfo

java.lang.Object
  extended by org.jlab.coda.cMsg.cMsgDomain.server.cMsgServerSubscribeInfo

public class cMsgServerSubscribeInfo
extends java.lang.Object

Class to store the record of a server client's subscription to a particular message subject, type, and namespace. It also stores a record of all subscribeAndGet calls to the same subject, type, and namespace. Used by the cMsgDomainServer class.

Version:
1.0
Author:
Carl Timmer

Constructor Summary
cMsgServerSubscribeInfo(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgClientInfo info)
          Constructor used by cMsgDomainServer object basically for storage of subject, type, namespace and callbacks for subscribes.
cMsgServerSubscribeInfo(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgClientInfo info, int id, cMsgCallbackAdapter cb)
          Constructor used by cMsgDomainServer object basically for storage of subject, type, namespace and callbacks for subAndGets.
 
Method Summary
 void addSubAndGetter(int id, cMsgCallbackAdapter cb)
          Adds an entry to a hashmap with the subscribeAndGet id as the key and the callback object as the value.
 void addSubscription()
          Calling this method means this client is now subscribed to this sub/type/namespace.
 java.util.HashMap<java.lang.Integer,cMsgCallbackAdapter> getSubAndGetters()
          Gets the HashMap containing the subscribeAndGet id generated by the originating client as the key (receiverSubscribeId which identifies the particular subscribeAndGet call in question), and the value which is the callback object of that subscribeAndGet.
 boolean isSubscribed()
          Is the client subscribed or are there only subAndGets?
 int numberOfSubscribers()
          Gets the number of subscriptions a client has to a subject, type, namespace combination.
 void removeSubAndGetter(int id)
          Removes an entry to a hashmap with the subscribeAndGet id as the key and the callback object as the value.
 void removeSubscription()
          Calling this method means this client is not subscribed to this sub/type/namespace anymore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

cMsgServerSubscribeInfo

public cMsgServerSubscribeInfo(java.lang.String subject,
                               java.lang.String type,
                               java.lang.String namespace,
                               cMsgClientInfo info)
Constructor used by cMsgDomainServer object basically for storage of subject, type, namespace and callbacks for subscribes.

Parameters:
subject - subscription subject
type - subscription type
namespace - subscription's namespace
info - client information object

cMsgServerSubscribeInfo

public cMsgServerSubscribeInfo(java.lang.String subject,
                               java.lang.String type,
                               java.lang.String namespace,
                               cMsgClientInfo info,
                               int id,
                               cMsgCallbackAdapter cb)
Constructor used by cMsgDomainServer object basically for storage of subject, type, namespace and callbacks for subAndGets.

Parameters:
subject - subscription subject
type - subscription type
namespace - subscription's namespace
info - client information object
id - receiverSubscribeId of subscribeAndGet request
cb - callback of subscribeAndGet
Method Detail

addSubscription

public void addSubscription()
                     throws cMsgException
Calling this method means this client is now subscribed to this sub/type/namespace. Previously only a subscribeAndGet to this sub/type/ns was done.

Throws:
cMsgException - if user tries to subscribe more than once (subscribeAndGet NOT included)

removeSubscription

public void removeSubscription()
Calling this method means this client is not subscribed to this sub/type/namespace anymore.


isSubscribed

public boolean isSubscribed()
Is the client subscribed or are there only subAndGets?

Returns:
true if client has a subscription, false if client only did subAndGets

getSubAndGetters

public java.util.HashMap<java.lang.Integer,cMsgCallbackAdapter> getSubAndGetters()
Gets the HashMap containing the subscribeAndGet id generated by the originating client as the key (receiverSubscribeId which identifies the particular subscribeAndGet call in question), and the value which is the callback object of that subscribeAndGet.

Returns:
hashmap of (id, callback object) key-value pairs of all subAndGets

addSubAndGetter

public void addSubAndGetter(int id,
                            cMsgCallbackAdapter cb)
Adds an entry to a hashmap with the subscribeAndGet id as the key and the callback object as the value.

Parameters:
id - id of subscribeAndGet call
cb - callback object

removeSubAndGetter

public void removeSubAndGetter(int id)
Removes an entry to a hashmap with the subscribeAndGet id as the key and the callback object as the value.

Parameters:
id - subscribeAndGet id key

numberOfSubscribers

public int numberOfSubscribers()
Gets the number of subscriptions a client has to a subject, type, namespace combination. This includes both subscribes and subAndGets.

Returns:
the number of subscriptions a client has to a subject, type, namespace combination including subscribes and subAndGets