Joram 5.3.0

org.objectweb.joram.mom.dest
Class TopicImpl

java.lang.Object
  extended by org.objectweb.joram.mom.dest.DestinationImpl
      extended by org.objectweb.joram.mom.dest.TopicImpl
All Implemented Interfaces:
java.io.Serializable, DestinationImplMBean, TopicImplMBean
Direct Known Subclasses:
AdminTopicImpl, JMSBridgeTopicImpl, MonitoringTopicImpl

public class TopicImpl
extends DestinationImpl
implements TopicImplMBean

The TopicImpl class implements the MOM topic behaviour, basically distributing the received messages to subscribers.

A Topic might be part of a hierarchy; if it is the case, and if the topic is not on top of that hierarchy, it will have a father to forward messages to.

A topic might also be part of a cluster; if it is the case, it will have friends to forward messages to.

A topic can't be part of a hierarchy and of a cluster at the same time.

See Also:
Serialized Form

Field Summary
protected  boolean alreadySentLocally
          Internal boolean used for tagging local sendings.
protected  fr.dyade.aaa.agent.AgentId fatherId
          Identifier of this topic's father, if any.
protected  java.util.Set friends
          Set of cluster fellows, if any.
protected  java.util.Hashtable selectors
          Table of subscribers' selectors.
protected  java.util.Vector subscribers
          Vector of subscribers' identifiers.
 
Fields inherited from class org.objectweb.joram.mom.dest.DestinationImpl
_rights, agent, clients, creationDate, dmqId, freeReading, freeWriting, logger, nbMsgsDeliverSinceCreation, nbMsgsReceiveSinceCreation, nbMsgsSentToDMQSinceCreation, READ, READWRITE, WAKEUP_PERIOD, WRITE
 
Constructor Summary
TopicImpl(fr.dyade.aaa.agent.AgentId adminId, java.util.Properties prop)
          Constructs a TopicImpl instance.
 
Method Summary
 void clusterAck(fr.dyade.aaa.agent.AgentId from, org.objectweb.joram.mom.dest.ClusterAck ack)
          Method implementing the reaction to a ClusterAck notification sent by a topic requested to join the cluster.
 void clusterNot(fr.dyade.aaa.agent.AgentId from, org.objectweb.joram.mom.dest.ClusterNot not)
          Method implementing the reaction to a ClusterNot notification sent by a fellow topic for notifying this topic of a new cluster fellow.
 void clusterRequest(fr.dyade.aaa.agent.AgentId from, ClusterRequest req)
          Method implementing the reaction to a ClusterRequest instance requesting to add a topic to the cluster, or to set a cluster with a given topic.
 void clusterTest(fr.dyade.aaa.agent.AgentId from, org.objectweb.joram.mom.dest.ClusterTest not)
          Method implementing the reaction to a ClusterTest notification sent by a fellow topic for testing if this topic might be part of a cluster.
 void destinationAdminRequestNot(fr.dyade.aaa.agent.AgentId from, DestinationAdminRequestNot not)
           
protected  void doClientMessages(fr.dyade.aaa.agent.AgentId from, ClientMessages not)
          Method specifically processing a ClientMessages instance.
protected  void doDeleteNot(fr.dyade.aaa.agent.DeleteNot not)
          Method specifically processing a fr.dyade.aaa.agent.DeleteNot instance.
protected  void doRightRequest(SetRightRequest not)
          Method specifically processing a SetRightRequest instance.
protected  void doUnknownAgent(fr.dyade.aaa.agent.UnknownAgent uA)
          Method specifically processing an UnknownAgent instance.
 void fatherAck(fr.dyade.aaa.agent.AgentId from, org.objectweb.joram.mom.dest.FatherAck not)
          Method reacting to a FatherAck notification coming from the topic this topic requested as a father.
 void fatherTest(fr.dyade.aaa.agent.AgentId from, org.objectweb.joram.mom.dest.FatherTest not)
          Method reacting to a FatherTest notification checking if it can be a father to a topic.
protected  void forwardMessages(ClientMessages messages)
          Actually forwards a vector of messages to the father or the cluster fellows, if any.
 long getNbMsgsReceiveSinceCreation()
          Returns the number of messages received since creation time of this destination.
 java.lang.String[] getSubscriberIds()
          Returns the list of unique identifiers of all subscribers.
 void initialize(boolean firstTime)
          Initializes the destination.
 void monitGetCluster(fr.dyade.aaa.agent.AgentId from, Monit_GetCluster not)
          Method implementing the reaction to a Monit_GetCluster notification requesting the identifiers of the cluster's topics.
 void monitGetFather(fr.dyade.aaa.agent.AgentId from, Monit_GetFather not)
          Method implementing the reaction to a Monit_GetFather notification requesting the identifier of the hierarchical father.
 void monitGetSubscriptions(fr.dyade.aaa.agent.AgentId from, Monit_GetSubscriptions not)
          Method implementing the reaction to a Monit_GetSubscriptions notification requesting the number of subscriptions.
 void postSubscribe(SubscribeRequest not)
           
 void postUnsubscribe(UnsubscribeRequest not)
           
 void preSubscribe(SubscribeRequest not)
           
 void preUnsubscribe(UnsubscribeRequest not)
           
protected  void processMessages(ClientMessages not)
          Actually processes the distribution of the received messages to the valid subscriptions by sending a TopicMsgsReply notification to the valid subscribers.
 void setAlreadySentLocally(boolean alreadySentLocally)
           
 void setFatherRequest(fr.dyade.aaa.agent.AgentId from, SetFatherRequest request)
          Method implementing the reaction to a SetFatherRequest instance notifying this topic it is part of a hierarchy as a son.
 void subscribeRequest(fr.dyade.aaa.agent.AgentId from, SubscribeRequest not)
          Method implementing the reaction to a SubscribeRequest instance.
 void topicForwardNot(fr.dyade.aaa.agent.AgentId from, TopicForwardNot not)
          Method implementing the reaction to a TopicForwardNot instance, carrying messages forwarded by a cluster fellow or a hierarchical son.
 java.lang.String toString()
          Returns a string representation of this destination.
 void unclusterNot(fr.dyade.aaa.agent.AgentId from, org.objectweb.joram.mom.dest.UnclusterNot not)
          Method implementing the reaction to an UnclusterNot notification sent by a topic leaving the cluster.
 void unclusterRequest(fr.dyade.aaa.agent.AgentId from, UnclusterRequest request)
          Method implementing the reaction to an UnclusterRequest instance requesting this topic to leave the cluster it is part of.
 void unsetFatherRequest(fr.dyade.aaa.agent.AgentId from, UnsetFatherRequest request)
          Method implementing the reaction to an UnsetFatherRequest instance notifying this topic to leave its father.
 void unsubscribeRequest(fr.dyade.aaa.agent.AgentId from, UnsubscribeRequest not)
          Method implementing the reaction to an UnsubscribeRequest instance, requesting to remove a subscriber.
 void wakeUpNot(WakeUpNot not)
           
 
Methods inherited from class org.objectweb.joram.mom.dest.DestinationImpl
canBeDeleted, clientMessages, deleteNot, forward, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQId, getId, getJMXStatistics, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, handleDeniedMessage, isAdministrator, isFreeReading, isFreeWriting, isLocal, isReader, isValidJMXAttribute, isWriter, monitFreeAccess, monitGetDMQSettings, monitGetReaders, monitGetStat, monitGetWriters, postProcess, postProcess, preProcess, preProcess, processSetRight, replyToTopic, requestGroupNot, setAgent, setDMQRequest, setFreeReading, setFreeWriting, setPeriod, setRightRequest, specialAdminProcess, specialAdminRequest, unknownAgent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.objectweb.joram.mom.dest.DestinationImplMBean
getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQId, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, isFreeReading, isFreeWriting, setFreeReading, setFreeWriting, setPeriod
 

Field Detail

fatherId

protected fr.dyade.aaa.agent.AgentId fatherId
Identifier of this topic's father, if any.


friends

protected java.util.Set friends
Set of cluster fellows, if any.


subscribers

protected java.util.Vector subscribers
Vector of subscribers' identifiers.


selectors

protected java.util.Hashtable selectors
Table of subscribers' selectors.


alreadySentLocally

protected transient boolean alreadySentLocally
Internal boolean used for tagging local sendings.

Constructor Detail

TopicImpl

public TopicImpl(fr.dyade.aaa.agent.AgentId adminId,
                 java.util.Properties prop)
Constructs a TopicImpl instance.

Parameters:
adminId - Identifier of the administrator of the topic.
prop - The initial set of properties.
Method Detail

initialize

public void initialize(boolean firstTime)
Initializes the destination.

Specified by:
initialize in class DestinationImpl
Parameters:
firstTime - true when first called by the factory

toString

public java.lang.String toString()
Returns a string representation of this destination.

Specified by:
toString in interface DestinationImplMBean
Overrides:
toString in class java.lang.Object

wakeUpNot

public void wakeUpNot(WakeUpNot not)
Specified by:
wakeUpNot in class DestinationImpl

clusterRequest

public void clusterRequest(fr.dyade.aaa.agent.AgentId from,
                           ClusterRequest req)
                    throws AccessException
Method implementing the reaction to a ClusterRequest instance requesting to add a topic to the cluster, or to set a cluster with a given topic.

Throws:
AccessException - If the requester is not an administrator.

clusterTest

public void clusterTest(fr.dyade.aaa.agent.AgentId from,
                        org.objectweb.joram.mom.dest.ClusterTest not)
Method implementing the reaction to a ClusterTest notification sent by a fellow topic for testing if this topic might be part of a cluster.


clusterAck

public void clusterAck(fr.dyade.aaa.agent.AgentId from,
                       org.objectweb.joram.mom.dest.ClusterAck ack)
Method implementing the reaction to a ClusterAck notification sent by a topic requested to join the cluster.


clusterNot

public void clusterNot(fr.dyade.aaa.agent.AgentId from,
                       org.objectweb.joram.mom.dest.ClusterNot not)
Method implementing the reaction to a ClusterNot notification sent by a fellow topic for notifying this topic of a new cluster fellow.


unclusterRequest

public void unclusterRequest(fr.dyade.aaa.agent.AgentId from,
                             UnclusterRequest request)
                      throws MomException
Method implementing the reaction to an UnclusterRequest instance requesting this topic to leave the cluster it is part of.

Throws:
AccessException - If the requester is not an administrator.
MomException

unclusterNot

public void unclusterNot(fr.dyade.aaa.agent.AgentId from,
                         org.objectweb.joram.mom.dest.UnclusterNot not)
Method implementing the reaction to an UnclusterNot notification sent by a topic leaving the cluster.


setFatherRequest

public void setFatherRequest(fr.dyade.aaa.agent.AgentId from,
                             SetFatherRequest request)
                      throws MomException
Method implementing the reaction to a SetFatherRequest instance notifying this topic it is part of a hierarchy as a son.

Throws:
AccessException - If the requester is not an administrator.
MomException

fatherTest

public void fatherTest(fr.dyade.aaa.agent.AgentId from,
                       org.objectweb.joram.mom.dest.FatherTest not)
Method reacting to a FatherTest notification checking if it can be a father to a topic.


fatherAck

public void fatherAck(fr.dyade.aaa.agent.AgentId from,
                      org.objectweb.joram.mom.dest.FatherAck not)
Method reacting to a FatherAck notification coming from the topic this topic requested as a father.


unsetFatherRequest

public void unsetFatherRequest(fr.dyade.aaa.agent.AgentId from,
                               UnsetFatherRequest request)
                        throws MomException
Method implementing the reaction to an UnsetFatherRequest instance notifying this topic to leave its father.

Throws:
AccessException - If the requester is not an administrator.
MomException

monitGetSubscriptions

public void monitGetSubscriptions(fr.dyade.aaa.agent.AgentId from,
                                  Monit_GetSubscriptions not)
                           throws AccessException
Method implementing the reaction to a Monit_GetSubscriptions notification requesting the number of subscriptions.

Throws:
AccessException - If the requester is not the administrator.

monitGetFather

public void monitGetFather(fr.dyade.aaa.agent.AgentId from,
                           Monit_GetFather not)
                    throws AccessException
Method implementing the reaction to a Monit_GetFather notification requesting the identifier of the hierarchical father.

Throws:
AccessException - If the requester is not the administrator.

monitGetCluster

public void monitGetCluster(fr.dyade.aaa.agent.AgentId from,
                            Monit_GetCluster not)
                     throws AccessException
Method implementing the reaction to a Monit_GetCluster notification requesting the identifiers of the cluster's topics.

Throws:
AccessException - If the requester is not the administrator.

preSubscribe

public void preSubscribe(SubscribeRequest not)

postSubscribe

public void postSubscribe(SubscribeRequest not)

subscribeRequest

public void subscribeRequest(fr.dyade.aaa.agent.AgentId from,
                             SubscribeRequest not)
                      throws AccessException
Method implementing the reaction to a SubscribeRequest instance.

Throws:
AccessException - If the sender is not a READER.

preUnsubscribe

public void preUnsubscribe(UnsubscribeRequest not)

postUnsubscribe

public void postUnsubscribe(UnsubscribeRequest not)

unsubscribeRequest

public void unsubscribeRequest(fr.dyade.aaa.agent.AgentId from,
                               UnsubscribeRequest not)
Method implementing the reaction to an UnsubscribeRequest instance, requesting to remove a subscriber.


topicForwardNot

public void topicForwardNot(fr.dyade.aaa.agent.AgentId from,
                            TopicForwardNot not)
Method implementing the reaction to a TopicForwardNot instance, carrying messages forwarded by a cluster fellow or a hierarchical son.


destinationAdminRequestNot

public void destinationAdminRequestNot(fr.dyade.aaa.agent.AgentId from,
                                       DestinationAdminRequestNot not)
Specified by:
destinationAdminRequestNot in class DestinationImpl

getSubscriberIds

public java.lang.String[] getSubscriberIds()
Returns the list of unique identifiers of all subscribers. Each user appears once even if there is multiples subscriptions, the different subscriptions can be enumerate through the proxy MBean.

Specified by:
getSubscriberIds in interface TopicImplMBean
Returns:
the list of unique identifiers of all subscribers.

doRightRequest

protected void doRightRequest(SetRightRequest not)
Method specifically processing a SetRightRequest instance.

When a reader is removed, deleting this reader's subscription if any, and sending an ExceptionReply notification to the client.

Specified by:
doRightRequest in class DestinationImpl

doClientMessages

protected void doClientMessages(fr.dyade.aaa.agent.AgentId from,
                                ClientMessages not)
Method specifically processing a ClientMessages instance.

This method may forward the messages to the topic father if any, or to the cluster fellows if any.It may finally send TopicMsgsReply instances to the valid subscribers.

Specified by:
doClientMessages in class DestinationImpl

doUnknownAgent

protected void doUnknownAgent(fr.dyade.aaa.agent.UnknownAgent uA)
Method specifically processing an UnknownAgent instance.

This method notifies the administrator of the failing cluster or hierarchy building request, if needed, or removes the subscriptions of the deleted client, if any, or sets the father identifier to null if it comes from a deleted father.

Specified by:
doUnknownAgent in class DestinationImpl

doDeleteNot

protected void doDeleteNot(fr.dyade.aaa.agent.DeleteNot not)
Method specifically processing a fr.dyade.aaa.agent.DeleteNot instance.

UnknownAgent notifications are sent to each subscriber and UnclusterNot notifications to the cluster fellows.

Specified by:
doDeleteNot in class DestinationImpl

forwardMessages

protected void forwardMessages(ClientMessages messages)
Actually forwards a vector of messages to the father or the cluster fellows, if any.


processMessages

protected void processMessages(ClientMessages not)
Actually processes the distribution of the received messages to the valid subscriptions by sending a TopicMsgsReply notification to the valid subscribers.


setAlreadySentLocally

public void setAlreadySentLocally(boolean alreadySentLocally)

getNbMsgsReceiveSinceCreation

public long getNbMsgsReceiveSinceCreation()
Description copied from class: DestinationImpl
Returns the number of messages received since creation time of this destination.

Specified by:
getNbMsgsReceiveSinceCreation in interface DestinationImplMBean
Specified by:
getNbMsgsReceiveSinceCreation in class DestinationImpl
Returns:
the number of messages received since creation time.

Joram 5.3.0

Copyright © 2000 - 2009 Scalagent D.T. - All rights reserved