public class cMsgSubscription extends cMsgGetHelper
errorCode, intVal, message, timedOut
Constructor and Description |
---|
cMsgSubscription(java.lang.String subject,
java.lang.String type)
Constructor used for cMsg and rcServer domain subscribeAndGets.
|
cMsgSubscription(java.lang.String subject,
java.lang.String type,
int id,
cMsgCallbackThread cbThread)
Constructor used by cMsg domain API.
|
cMsgSubscription(java.lang.String subject,
java.lang.String type,
java.lang.String namespace)
Constructor used by cMsg subdomain handler.
|
Modifier and Type | Method and Description |
---|---|
void |
addCallback(cMsgCallbackThread cbThread)
Method to add a callback thread.
|
boolean |
addClientSubscriber(cMsgClientInfo client)
Adds a client to the set containing only regular clients subscribed to this subject, type,
and namespace.
|
void |
addNotifier(cMsgNotifier notifier)
Add a notifier object to the set of objects used to notify servers that their
subscribeAndGet is complete.
|
void |
addSubAndGetter(cMsgClientInfo client)
Adds a client to the hashmap containing all regular clients who have
called
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int) . |
boolean |
addSubscriber(cMsgClientInfo client)
Adds a client to the set containing all clients (regular and bridge) subscribed
to this subject, type, and namespace.
|
boolean |
areWildCardsInSub()
Returns true if there are * or ? characters in subject.
|
boolean |
areWildCardsInType()
Returns true if there are * or ? characters in type.
|
void |
clearNotifiers()
Clear all notifier objects from the set of objects used to notify servers that their
subscribeAndGet is complete.
|
void |
clearSubAndGetters()
Clears the hashmap containing all regular clients who have
called
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int) . |
boolean |
containsSubscriber(cMsgClientInfo client)
Is this a subscription of the given client (regular or bridge)?
Used only on the server side.
|
static java.lang.String |
escape(java.lang.String s)
This method takes a string and escapes regular expression characters
with the exception of * and ? which are untouched.
|
static java.lang.String |
escapeBar(java.lang.String s)
This method takes a string and escapes | (bar (OR)).
|
static java.lang.String |
escapeNoBar(java.lang.String s)
This method takes a string and escapes regular expression characters
with the exception of *, ?, and | which are untouched.
|
java.util.HashSet<cMsgClientInfo> |
getAllSubscribers()
Gets the set containing all clients (regular and bridge) subscribed to this
subject, type, and namespace.
|
java.util.Set<cMsgCallbackThread> |
getCallbacks()
Gets the set storing callback threads.
|
java.util.HashSet<cMsgClientInfo> |
getClientSubscribers()
Gets the set containing only regular clients subscribed to this subject, type,
and namespace.
|
int |
getIntVal()
Gets the intVal which client generates (receiverSubscribeId).
|
java.lang.String |
getNamespace()
Gets the namespace in the cMsg subdomain in which this subscription resides.
|
java.util.Set<cMsgNotifier> |
getNotifiers()
Gets the set of objects used to notify servers that their subscribeAndGet is complete.
|
java.util.HashMap<cMsgClientInfo,java.lang.Integer> |
getSubAndGetters()
Gets the hashmap containing all regular clients who have
called
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int)
with this subject, type, and namespace. |
java.lang.String |
getSubject()
Gets subject subscribed to.
|
java.util.regex.Pattern |
getSubjectPattern()
Gets subject turned into compiled regular expression pattern.
|
java.lang.String |
getSubjectRegexp()
Gets subject turned into regular expression that understands * and ?.
|
java.lang.String |
getType()
Gets type subscribed to.
|
java.util.regex.Pattern |
getTypePattern()
Gets type turned into compiled regular expression pattern.
|
java.lang.String |
getTypeRegexp()
Gets type turned into regular expression that understands * and ?.
|
boolean |
matches(java.lang.String msgSubject,
java.lang.String msgType)
This method checks to see if there is a match between a given (message's) subject and type
pair and this subscription's subject and type.
|
static boolean |
matches(java.lang.String regexp,
java.lang.String s,
boolean escapeRegexp)
This method implements a simple wildcard matching scheme where "*" means
any or no characters, "?" means exactly 1 character, and "#" means
1 or no positive integer.
|
boolean |
matchesOrig(java.lang.String msgSubject,
java.lang.String msgType)
This method checks to see if there is a match between a given msgSubject and msgType
pair and this subscription's msgSubject and msgType.
|
int |
numberOfCallbacks()
Method to return the number of callback threads registered.
|
int |
numberOfSubscribers()
Returns the total number of subscribers and subscribeAndGet callers
subscribed to this subject, type, and namespace.
|
void |
printSizes()
This method prints the sizes of all sets and maps.
|
void |
removeCallback(cMsgCallbackThread cbThread)
Method to remove a callback thread.
|
boolean |
removeClientSubscriber(cMsgClientInfo client)
Removes a client from the set containing only regular clients subscribed to this subject, type,
and namespace.
|
void |
removeNotifier(cMsgNotifier notifier)
Remove a notifier object from the set of objects used to notify servers that their
subscribeAndGet is complete.
|
void |
removeSubAndGetter(cMsgClientInfo client)
Removes a client from the hashmap containing all regular clients who have
called
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int) . |
boolean |
removeSubscriber(cMsgClientInfo client)
Removes a client from the set containing all clients (regular and bridge) subscribed
to this subject, type, and namespace.
|
void |
setIntVal(int id)
Sets the intVal which client generates (receiverSubscribeId).
|
void |
setNamespace(java.lang.String namespace)
Sets the namespace in the cMsg subdomain in which this subscription resides.
|
getErrorCode, getMessage, isTimedOut, needToWait, setErrorCode, setMessage, setTimedOut
public cMsgSubscription(java.lang.String subject, java.lang.String type)
subject
- subscription subjecttype
- subscription typepublic cMsgSubscription(java.lang.String subject, java.lang.String type, java.lang.String namespace)
subject
- subscription subjecttype
- subscription typenamespace
- namespace subscription exists inpublic cMsgSubscription(java.lang.String subject, java.lang.String type, int id, cMsgCallbackThread cbThread)
subject
- subscription subjecttype
- subscription typeid
- unique intVal referring to subject and type combinationcbThread
- object containing callback, its argument, and the thread to run itpublic static java.lang.String escape(java.lang.String s)
s
- string to be escapedpublic static java.lang.String escapeNoBar(java.lang.String s)
s
- string to be escapedpublic static java.lang.String escapeBar(java.lang.String s)
s
- string to be escapedpublic boolean matches(java.lang.String msgSubject, java.lang.String msgType)
msgSubject
- subjectmsgType
- typepublic static boolean matches(java.lang.String regexp, java.lang.String s, boolean escapeRegexp)
regexp
- subscription string that can contain wildcards (*, ?, #), null matches everythings
- message string to be matched (blank only matches *, null matches nothing)escapeRegexp
- if true, the regexp argument has regular expression chars escaped,
and *, ?, # chars translated to real java regular expression syntax, else notpublic boolean matchesOrig(java.lang.String msgSubject, java.lang.String msgType)
msgSubject
- msgSubjectmsgType
- msgTypepublic void printSizes()
public boolean areWildCardsInSub()
public boolean areWildCardsInType()
public java.lang.String getSubject()
public java.lang.String getSubjectRegexp()
public java.util.regex.Pattern getSubjectPattern()
public java.lang.String getType()
public java.lang.String getTypeRegexp()
public java.util.regex.Pattern getTypePattern()
public int getIntVal()
getIntVal
in class cMsgGetHelper
public void setIntVal(int id)
setIntVal
in class cMsgGetHelper
id
- intVal which client generates (receiverSubscribeId)public java.lang.String getNamespace()
public void setNamespace(java.lang.String namespace)
namespace
- namespace subscription resides inpublic java.util.Set<cMsgCallbackThread> getCallbacks()
public void addCallback(cMsgCallbackThread cbThread)
cbThread
- object containing callback thread, its argument,
and the thread to run itpublic void removeCallback(cMsgCallbackThread cbThread)
cbThread
- object containing callback thread to be removedpublic int numberOfCallbacks()
public java.util.HashSet<cMsgClientInfo> getClientSubscribers()
public boolean addClientSubscriber(cMsgClientInfo client)
client
- regular client to be added to subscriptionpublic boolean removeClientSubscriber(cMsgClientInfo client)
client
- regular client to be removed from subscriptionpublic java.util.HashSet<cMsgClientInfo> getAllSubscribers()
public boolean containsSubscriber(cMsgClientInfo client)
client
- clientpublic boolean addSubscriber(cMsgClientInfo client)
client
- client to be added to subscriptionpublic boolean removeSubscriber(cMsgClientInfo client)
client
- client to be removed from subscriptionpublic java.util.HashMap<cMsgClientInfo,java.lang.Integer> getSubAndGetters()
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int)
with this subject, type, and namespace. A count is
keep of how many times subscribeAndGet for a particular
client has been called. The client info object is the key
and count is the value. This is used on the server side.cMsg.subscribeAndGet(java.lang.String, java.lang.String, int)
public void addSubAndGetter(cMsgClientInfo client)
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int)
.
This is used on the server side.client
- client who called subscribeAndGetpublic void clearSubAndGetters()
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int)
.
This is used on the server side.public void removeSubAndGetter(cMsgClientInfo client)
cMsg.subscribeAndGet(java.lang.String, java.lang.String, int)
. If the client has
called subscribeAndGet more than once, it's entry in the table stays but
it's count of active subscribeAndGet calls is decremented.
This is used on the server side.client
- client who called subscribeAndGetpublic int numberOfSubscribers()
public java.util.Set<cMsgNotifier> getNotifiers()
public void addNotifier(cMsgNotifier notifier)
notifier
- notifier objectpublic void removeNotifier(cMsgNotifier notifier)
notifier
- notifier objectpublic void clearNotifiers()