org.objectweb.joram.mom.dest
Class Topic

java.lang.Object
  extended by fr.dyade.aaa.agent.Agent
      extended by org.objectweb.joram.mom.dest.Destination
          extended by org.objectweb.joram.mom.dest.Topic
All Implemented Interfaces:
AgentMBean, java.io.Serializable, ClusterDestinationMBean, DestinationMBean, TopicMBean
Direct Known Subclasses:
AcquisitionTopic, AdminTopic, DistributionTopic, JMSBridgeTopic

public class Topic
extends Destination
implements TopicMBean

The Topic class implements the MOM topic behavior, 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 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  AgentId fatherId
          Identifier of this topic's father, if any.
protected  java.util.Set friends
          Set of cluster elements (including itself), if any.
static org.objectweb.util.monolog.api.Logger logger
           
protected  java.util.Map selectors
          Table of subscribers' selectors.
protected  java.util.List subscribers
          Vector of subscribers' identifiers.
 
Fields inherited from class org.objectweb.joram.mom.dest.Destination
_rights, clients, creationDate, dmqId, freeReading, freeWriting, nbMsgsDeliverSinceCreation, nbMsgsReceiveSinceCreation, nbMsgsSentToDMQSinceCreation, READ, READWRITE, task, WAKEUP_PERIOD, WRITE
 
Fields inherited from class fr.dyade.aaa.agent.Agent
emptyString, fixed, logmon
 
Constructor Summary
Topic()
           
Topic(java.lang.String string, boolean b, int joramAdminStamp)
           
 
Method Summary
protected  void clusterJoin(ClusterJoinNot not)
          Method implementing the reaction to a ClusterJoinNot notification, sent by a fellow topic for notifying this topic to join the cluster, doing a transitive closure of clusters, if any.
protected  void clusterJoinAck(ClusterJoinAck not)
          Method implementing the reaction to a ClusterJoinAck notification, doing a transitive closure with the current cluster and the one of the new cluster element.
protected  void doClientMessages(AgentId from, ClientMessages not)
          Method specifically processing a ClientMessages instance.
protected  void doDeleteNot(DeleteNot not)
          Method specifically processing a fr.dyade.aaa.agent.DeleteNot instance.
protected  void doRightRequest(AgentId user, int right)
          Method specifically processing a SetRightRequest instance.
protected  void doUnknownAgent(UnknownAgent uA)
          Method specifically processing an UnknownAgent instance.
protected  void forwardMessages(ClientMessages messages)
          Actually forwards a list of messages to the father or the cluster fellows, if any.
 java.lang.String[] getClusterElements()
           
 long getNbMsgsReceiveSinceCreation()
          Returns the number of messages received since creation time of this destination.
 int getNumberOfSubscribers()
          Returns the number of subscribers.
 java.lang.String[] getSubscriberIds()
          Returns the list of unique identifiers of all subscribers.
 byte getType()
          Returns the type of this destination: Queue or Topic.
 void handleAdminRequestNot(AgentId from, FwdAdminRequestNot not)
           
 void initialize(boolean firstTime)
          Initializes the destination.
 void postSubscribe()
          Deprecated.  
 void postUnsubscribe()
          Deprecated.  
 void preSubscribe()
          Deprecated.  
 void preUnsubscribe()
          Deprecated.  
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 react(AgentId from, Notification not)
          Distributes the received notifications to the appropriate reactions.
protected  void sendToCluster(Notification not)
          Sends a notification to all topics in cluster.
 void setAlreadySentLocally(boolean alreadySentLocally)
           
protected  void subscribeRequest(AgentId from, SubscribeRequest not)
          Method implementing the reaction to a SubscribeRequest instance.
protected  void topicForwardNot(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.
protected  void unsubscribeRequest(AgentId from)
          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.Destination
agentFinalize, agentInitialize, clientMessages, delete, deleteNot, forward, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQAgentId, getDMQId, getJMXStatistics, getMBeanName, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, getRights, handleDeniedMessage, interceptorsAvailable, isAdministrator, isFreeReading, isFreeWriting, isLocal, isReader, isValidJMXAttribute, isWriter, postProcess, preProcess, processAdminCommand, processInterceptors, processSetRight, processStartHandler, processStopHandler, replyToTopic, requestGroupNot, setAdminId, setFreeReading, setFreeWriting, setPeriod, setProperties, setRight, unknownAgent, updateProperties
 
Methods inherited from class fr.dyade.aaa.agent.Agent
delete, delete, deploy, deploy, getAgentId, getCommitTime, getId, getLogTopic, getName, getReactNb, getReactTime, isDeployed, isFixed, needToBeCommited, save, sendTo, sendTo, sendTo, setName, setNoSave, setSave
 
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.DestinationMBean
delete, getCreationDate, getCreationTimeInMillis, getDestinationId, getDMQId, getName, getNbMsgsDeliverSinceCreation, getNbMsgsSentToDMQSinceCreation, getPeriod, getRight, getRights, isFreeReading, isFreeWriting, setFreeReading, setFreeWriting, setPeriod
 
Methods inherited from interface fr.dyade.aaa.agent.AgentMBean
getAgentId, getCommitTime, getReactNb, getReactTime, isFixed
 

Field Detail

logger

public static org.objectweb.util.monolog.api.Logger logger

fatherId

protected AgentId fatherId
Identifier of this topic's father, if any.


friends

protected java.util.Set friends
Set of cluster elements (including itself), if any.


subscribers

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


selectors

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


alreadySentLocally

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

Constructor Detail

Topic

public Topic()

Topic

public Topic(java.lang.String string,
             boolean b,
             int joramAdminStamp)
Method Detail

getType

public final byte getType()
Description copied from class: Destination
Returns the type of this destination: Queue or Topic.

Specified by:
getType in class Destination
Returns:
the type of this destination.
See Also:
DestinationConstants.TOPIC_TYPE, DestinationConstants.QUEUE_TYPE

react

public void react(AgentId from,
                  Notification not)
           throws java.lang.Exception
Distributes the received notifications to the appropriate reactions.

Overrides:
react in class Destination
Parameters:
from - agent sending notification
not - notification to react to
Throws:
java.lang.Exception

initialize

public void initialize(boolean firstTime)
Initializes the destination.

Specified by:
initialize in class Destination
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 AgentMBean
Specified by:
toString in interface DestinationMBean
Overrides:
toString in class Agent
Returns:
A string representation of this agent.

wakeUpNot

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

clusterJoin

protected void clusterJoin(ClusterJoinNot not)
Method implementing the reaction to a ClusterJoinNot notification, sent by a fellow topic for notifying this topic to join the cluster, doing a transitive closure of clusters, if any.


clusterJoinAck

protected void clusterJoinAck(ClusterJoinAck not)
Method implementing the reaction to a ClusterJoinAck notification, doing a transitive closure with the current cluster and the one of the new cluster element.


getClusterElements

public java.lang.String[] getClusterElements()
Specified by:
getClusterElements in interface ClusterDestinationMBean
Returns:
an array containing the ids of the cluster elements.

sendToCluster

protected void sendToCluster(Notification not)
Sends a notification to all topics in cluster.

Parameters:
not - The notification to send.

preSubscribe

public void preSubscribe()
Deprecated. 

This method is currently needed by the JMSBridge. AF(TODO): Remove it.


postSubscribe

public void postSubscribe()
Deprecated. 

This method is currently needed by the JMSBridge. AF(TODO): Remove it.


subscribeRequest

protected void subscribeRequest(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()
Deprecated. 

This method is currently needed by the JMSBridge. AF(TODO): Remove it.


postUnsubscribe

public void postUnsubscribe()
Deprecated. 

This method is currently needed by the JMSBridge. AF(TODO): Remove it.


unsubscribeRequest

protected void unsubscribeRequest(AgentId from)
Method implementing the reaction to an UnsubscribeRequest instance, requesting to remove a subscriber.


topicForwardNot

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


handleAdminRequestNot

public void handleAdminRequestNot(AgentId from,
                                  FwdAdminRequestNot not)
Overrides:
handleAdminRequestNot in class Destination
See Also:
Destination.handleAdminRequestNot(fr.dyade.aaa.agent.AgentId, org.objectweb.joram.mom.notifications.FwdAdminRequestNot)

getNumberOfSubscribers

public final int getNumberOfSubscribers()
Returns the number of subscribers. Each user appears once even if there is multiples subscriptions, the different subscriptions can be enumerate through the proxy MBean.

Specified by:
getNumberOfSubscribers in interface TopicMBean
Returns:
the number of subscribers.

getSubscriberIds

public final 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 TopicMBean
Returns:
the list of unique identifiers of all subscribers.

doRightRequest

protected void doRightRequest(AgentId user,
                              int right)
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 Destination
Parameters:
user - The user about right modification.
right - The right modification.

doClientMessages

protected void doClientMessages(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 Destination

doUnknownAgent

protected void doUnknownAgent(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 Destination

doDeleteNot

protected void doDeleteNot(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 Destination

forwardMessages

protected void forwardMessages(ClientMessages messages)
Actually forwards a list 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: Destination
Returns the number of messages received since creation time of this destination.

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


Copyright © 2011 ScalAgent D.T.. All Rights Reserved.