xmlBlaster 2.2.0 API

org.xmlBlaster.engine
Class ClientSubscriptions

java.lang.Object
  extended by org.xmlBlaster.engine.ClientSubscriptions
All Implemented Interfaces:
java.util.EventListener, I_ClientListener, I_SubscriptionListener

public class ClientSubscriptions
extends java.lang.Object
implements I_ClientListener, I_SubscriptionListener

Handling subscriptions, collected for each session of each client.

There exists exactly one instance of this class for each xmlBlaster server, the instance is handled by RequestBroker.

The interface SubscriptionListener informs about subscribe/unsubscribe events

Author:
Marcel Ruff

Field Summary
private  java.util.Map clientSubscriptionMap
          All exact subscriptions of a Client are in this map.
private static java.util.logging.Logger log
           
private  java.util.Set querySubscribeRequestsSet
          All generic subscriptions are collected here.
 
Fields inherited from interface org.xmlBlaster.engine.I_SubscriptionListener
PRIO_01, PRIO_05, PRIO_10
 
Constructor Summary
ClientSubscriptions(ServerScope glob, RequestBroker requestBroker, Authenticate authenticate)
          Exactly one instance for each xmlBlaster server.
 
Method Summary
 int getNumSubscriptions()
           
 java.lang.Integer getPriority()
          The priority by which it will be invoked.
 java.util.Set getQuerySubscribeRequestsSet()
          All known subscriptions which match a query, but not those subscriptions which address exactly via key-oid
 java.util.ArrayList<SubscriptionInfo> getSubscription(SessionInfo sessionInfo, QueryKeyData queryKey, QueryQosData queryQos)
           
 SubscriptionInfo getSubscription(SessionInfo sessionInfo, java.lang.String subscriptionInfoUniqueKey)
          If you have the unique id of a subscription, you may access the SubscriptionInfo object here.
 SubscriptionInfo getSubscription(java.lang.String subscriptionInfoUniqueKey)
          If you have the unique id of a subscription, you may access the SubscriptionInfo object here.
 java.util.Vector<SubscriptionInfo> getSubscriptionByOid(SessionInfo sessionInfo, java.lang.String keyOid, boolean exactOnly)
           
 java.util.Vector getSubscriptionByOid(java.lang.String keyOid, boolean exactOnly)
           
 java.lang.String getSubscriptionList()
           
 java.lang.String[] getSubscriptions()
           
 SubscriptionInfo[] getSubscriptions(SessionInfo sessionInfo)
          Access all subscriptions of a client
private  void removeFromClientSubscriptionMap(SessionInfo sessionInfo, java.lang.String subscriptionInfoUniqueKey)
           
private  int removeFromQuerySubscribeRequestsSet(SessionInfo sessionInfo, java.lang.String subscriptionInfoUniqueKey)
           
 void sessionAdded(ClientEvent e)
          Invoked on successful client login (interface I_ClientListener)
 void sessionPreRemoved(ClientEvent e)
          Invoked before a client does a logout
 void sessionRemoved(ClientEvent e)
          Invoked when client does a logout (interface I_ClientListener)
 void sessionUpdated(ClientEvent e)
          Invoked on successful client re-login (interface I_ClientListener)
 void subjectAdded(ClientEvent e)
          Event invoked on new created SubjectInfo.
 void subjectRemoved(ClientEvent e)
          Event invoked on deleted SubjectInfo.
 void subscriptionAdd(SubscriptionEvent e)
          Event invoked on new subscription (interface SubscriptionListener).
 void subscriptionRemove(SubscriptionEvent e)
          Invoked when a subscription is canceled (interface SubscriptionListener).
 void topicRemove(TopicHandler topicHandler)
          Event invoked on message erase() invocation.
 java.lang.String toXml()
          Dump state of this object into XML.
 java.lang.String toXml(java.lang.String extraOffset)
          Dump state of this object into XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

clientSubscriptionMap

private final java.util.Map clientSubscriptionMap
All exact subscriptions of a Client are in this map.

These are the subscriptions which are referenced from a TopicHandler
including those with a query (XPATH).

A multimap would be appropriate, but since this is not supported by the Collections API, a map with a set as value is used.
Used for performing logout.

key = client.getSessionName().getRelativeName() value = subMap (Collections.synchronizedMap(new HashMap());) with SubscriptionInfo objects


querySubscribeRequestsSet

private final java.util.Set querySubscribeRequestsSet
All generic subscriptions are collected here. Generic are all subscriptions who don't subscribe a precise key-oid, but rather subscribe all MsgUnit matching a XPath query match.
If new MsgUnit are published, this set is consulted to check if some older subscriptions would match as well

value = SubscriptionInfo objects with generic subscriptions, but not those, who subscribed a MsgUnit exactly by a known oid

Constructor Detail

ClientSubscriptions

ClientSubscriptions(ServerScope glob,
                    RequestBroker requestBroker,
                    Authenticate authenticate)
              throws XmlBlasterException
Exactly one instance for each xmlBlaster server.

(no singleton pattern to allow multiple servers)

Parameters:
requestBroker - my master (singleton)
authenticate - another master
Throws:
XmlBlasterException
Method Detail

getQuerySubscribeRequestsSet

public java.util.Set getQuerySubscribeRequestsSet()
All known subscriptions which match a query, but not those subscriptions which address exactly via key-oid


getSubscription

public SubscriptionInfo getSubscription(SessionInfo sessionInfo,
                                        java.lang.String subscriptionInfoUniqueKey)
                                 throws XmlBlasterException
If you have the unique id of a subscription, you may access the SubscriptionInfo object here.

You can access XPATH or EXACT subscription objects through this method

Parameters:
sessionInfo - All infos about the client
subscriptionInfoUniqueKey -
Returns:
corresponding subscriptionInfo object
or null if not found
Throws:
XmlBlasterException

getSubscription

public SubscriptionInfo getSubscription(java.lang.String subscriptionInfoUniqueKey)
If you have the unique id of a subscription, you may access the SubscriptionInfo object here.

You can access XPATH or EXACT subscription objects through this method

Parameters:
subscriptionInfoUniqueKey -
Returns:
corresponding subscriptionInfo object
or null if not found

getNumSubscriptions

public int getNumSubscriptions()
Returns:
The number of all subscriptions in this cluster node.

getSubscriptionList

public java.lang.String getSubscriptionList()
Returns:
All subscriptionId in a comma separated string

getSubscriptions

public java.lang.String[] getSubscriptions()

getSubscriptions

public SubscriptionInfo[] getSubscriptions(SessionInfo sessionInfo)
Access all subscriptions of a client

Returns:
never null

getSubscription

public java.util.ArrayList<SubscriptionInfo> getSubscription(SessionInfo sessionInfo,
                                                             QueryKeyData queryKey,
                                                             QueryQosData queryQos)
                                                      throws XmlBlasterException
Throws:
XmlBlasterException

getSubscriptionByOid

public java.util.Vector<SubscriptionInfo> getSubscriptionByOid(SessionInfo sessionInfo,
                                                               java.lang.String keyOid,
                                                               boolean exactOnly)
                                                        throws XmlBlasterException
Throws:
XmlBlasterException

getSubscriptionByOid

public java.util.Vector getSubscriptionByOid(java.lang.String keyOid,
                                             boolean exactOnly)
                                      throws XmlBlasterException
Throws:
XmlBlasterException

sessionAdded

public void sessionAdded(ClientEvent e)
                  throws XmlBlasterException
Invoked on successful client login (interface I_ClientListener)

Specified by:
sessionAdded in interface I_ClientListener
Throws:
XmlBlasterException

sessionUpdated

public void sessionUpdated(ClientEvent e)
                    throws XmlBlasterException
Invoked on successful client re-login (interface I_ClientListener)

Specified by:
sessionUpdated in interface I_ClientListener
Throws:
XmlBlasterException

sessionPreRemoved

public void sessionPreRemoved(ClientEvent e)
                       throws XmlBlasterException
Description copied from interface: I_ClientListener
Invoked before a client does a logout

Specified by:
sessionPreRemoved in interface I_ClientListener
Throws:
XmlBlasterException

sessionRemoved

public void sessionRemoved(ClientEvent e)
                    throws XmlBlasterException
Invoked when client does a logout (interface I_ClientListener)

Specified by:
sessionRemoved in interface I_ClientListener
Throws:
XmlBlasterException

subjectAdded

public void subjectAdded(ClientEvent e)
                  throws XmlBlasterException
Event invoked on new created SubjectInfo.

Specified by:
subjectAdded in interface I_ClientListener
Throws:
XmlBlasterException

subjectRemoved

public void subjectRemoved(ClientEvent e)
                    throws XmlBlasterException
Event invoked on deleted SubjectInfo.

Specified by:
subjectRemoved in interface I_ClientListener
Throws:
XmlBlasterException

topicRemove

public void topicRemove(TopicHandler topicHandler)
                 throws XmlBlasterException
Event invoked on message erase() invocation.

Throws:
XmlBlasterException

subscriptionAdd

public void subscriptionAdd(SubscriptionEvent e)
                     throws XmlBlasterException
Event invoked on new subscription (interface SubscriptionListener).

Specified by:
subscriptionAdd in interface I_SubscriptionListener
Throws:
XmlBlasterException

subscriptionRemove

public void subscriptionRemove(SubscriptionEvent e)
                        throws XmlBlasterException
Invoked when a subscription is canceled (interface SubscriptionListener).

Note that the subscriptionInfo object carried in SubscriptionEvent is not the real known subscription, but rather misused as a container to carry the sessionInfo and subscriptionInfoUniqueKey

Specified by:
subscriptionRemove in interface I_SubscriptionListener
Throws:
XmlBlasterException

removeFromClientSubscriptionMap

private void removeFromClientSubscriptionMap(SessionInfo sessionInfo,
                                             java.lang.String subscriptionInfoUniqueKey)
                                      throws XmlBlasterException
Parameters:
subscriptionInfoUniqueKey - ==null: Remove client with all its subscriptions
!=null: Remove only the given subscription
Throws:
XmlBlasterException

removeFromQuerySubscribeRequestsSet

private int removeFromQuerySubscribeRequestsSet(SessionInfo sessionInfo,
                                                java.lang.String subscriptionInfoUniqueKey)
                                         throws XmlBlasterException
Parameters:
subscriptionInfoUniqueKey - ==null: Remove client with all its subscriptions
!=null: Remove only the given subscription
Throws:
XmlBlasterException

toXml

public final java.lang.String toXml()
                             throws XmlBlasterException
Dump state of this object into XML.

Returns:
XML state of ClientSubscriptions
Throws:
XmlBlasterException

toXml

public final java.lang.String toXml(java.lang.String extraOffset)
                             throws XmlBlasterException
Dump state of this object into XML.

Parameters:
extraOffset - indenting of tags
Returns:
XML state of ClientSubscriptions
Throws:
XmlBlasterException

getPriority

public java.lang.Integer getPriority()
Description copied from interface: I_SubscriptionListener
The priority by which it will be invoked. Lower numbers are invoked first on subscribe and last on unsubscribe.

Specified by:
getPriority in interface I_SubscriptionListener
Returns:
See Also:
I_SubscriptionListener.getPriority()

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.