org.objectweb.joram.mom.proxies
Class UserAgent

java.lang.Object
  extended by fr.dyade.aaa.agent.Agent
      extended by org.objectweb.joram.mom.proxies.UserAgent
All Implemented Interfaces:
AgentMBean, BagSerializer, java.io.Serializable, ProxyAgentItf, UserAgentMBean

public final class UserAgent
extends Agent
implements UserAgentMBean, BagSerializer, ProxyAgentItf

The UserAgent class implements the MOM proxy behaviour, basically forwarding client requests to MOM destinations and MOM destinations replies to clients.

See Also:
Serialized Form

Field Summary
static org.objectweb.util.monolog.api.Logger logger
           
 
Fields inherited from class fr.dyade.aaa.agent.Agent
emptyString, fixed, logmon
 
Constructor Summary
UserAgent()
          Constructs a UserAgent instance.
UserAgent(java.lang.String name, int stamp)
          Creates a new user proxy.
 
Method Summary
 void agentFinalize(boolean lastTime)
          Finalizes the agent before it is garbaged.
 void agentInitialize(boolean firstTime)
          (Re)initializes the agent when (re)loading.
protected  void cleanPendingMessages(long currentTime)
           
 void delete()
          Permits this agent to destroy itself.
 void deleteSubscriptionMessage(java.lang.String subName, java.lang.String msgId)
          Deletes a particular pending message in a subscription.
protected  org.objectweb.joram.mom.proxies.ClientContext getClientContext(int ctxId)
           
 java.lang.String getDMQId()
          Returns the default DMQ for subscription of this user.
protected  java.lang.String getMsgTxname()
           
 int getNbMaxMsg()
          Returns the default maximum number of message for the subscription of this user.
 long getNbMsgsSentToDMQSinceCreation()
          Returns the number of erroneous messages forwarded to the DMQ since creation time of this proxy..
 long getPeriod()
          Returns the period value of this queue, -1 if not set.
 java.lang.String[] getSubscriptionNames()
          Returns the list of subscriptions for this user.
 int getThreshold()
          Returns the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.
 void react(AgentId from, Notification not)
          Overrides the Agent class react method for providing the JMS client proxy with its specific behaviour.
protected  void reactToClientRequest(int key, AbstractJmsRequest request)
          Method processing clients requests.
 void readBag(java.io.ObjectInputStream in)
          The readBag method is responsible for reading from the stream and restoring the agent's transient state.
 void sendNot(AgentId to, Notification not)
          Sends a notification to the specified agent.
 void sendToClient(int key, AbstractJmsReply reply)
          Sends a reply to the client connected through the specified connection.
 void setInterceptors(java.util.Properties prop)
          Only call in UserAgent creation.
protected  void setMsgTxName(Message msg)
           
 void setNbMaxMsg(int nbMaxMsg)
          Sets the maximum number of message for the subscription of this user.
 void setNoSave()
          Sets the updated field to false so that the agent state is not saved after the current reaction; the field is set back to true for the next reaction.
 void setPeriod(long period)
          Sets or unsets the period for this queue.
 void setSave()
          Sets the updated field to true so that the agent state is saved after the current reaction.
 void setThreshold(int threshold)
          Sets the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.
 java.lang.String toString()
          Returns a string representation of this user's proxy.
 void writeBag(java.io.ObjectOutputStream out)
          The writeBag method is responsible for writing the extra data of this particular agent so that the corresponding readBag method can restore it.
 
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
 
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.proxies.UserAgentMBean
getName
 
Methods inherited from interface fr.dyade.aaa.agent.AgentMBean
getAgentId, getCommitTime, getReactNb, getReactTime, isFixed
 
Methods inherited from interface org.objectweb.joram.mom.proxies.ProxyAgentItf
getId
 

Field Detail

logger

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

UserAgent

public UserAgent()
Constructs a UserAgent instance.


UserAgent

public UserAgent(java.lang.String name,
                 int stamp)
Creates a new user proxy.

See Also:
ConnectionManager
Method Detail

getPeriod

public long getPeriod()
Returns the period value of this queue, -1 if not set.

Specified by:
getPeriod in interface UserAgentMBean
Returns:
the period value of this queue; -1 if not set.

setPeriod

public void setPeriod(long period)
Sets or unsets the period for this queue.

Specified by:
setPeriod in interface UserAgentMBean
Parameters:
period - The period value to be set or -1 for unsetting previous value.

getDMQId

public java.lang.String getDMQId()
Returns the default DMQ for subscription of this user.

Specified by:
getDMQId in interface UserAgentMBean
Returns:
the default DMQ for subscription of this user.

getThreshold

public int getThreshold()
Returns the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.

Specified by:
getThreshold in interface UserAgentMBean
Returns:
the maximum number of message if set; -1 otherwise.

setThreshold

public void setThreshold(int threshold)
Sets the default threshold for the subscription of this user. 0 stands for no threshold, -1 for value not set.

Specified by:
setThreshold in interface UserAgentMBean
Parameters:
threshold - the threshold to set.

getNbMaxMsg

public int getNbMaxMsg()
Returns the default maximum number of message for the subscription of this user. If the limit is unset the method returns -1.

Specified by:
getNbMaxMsg in interface UserAgentMBean
Returns:
the maximum number of message if set; -1 otherwise.

setNbMaxMsg

public void setNbMaxMsg(int nbMaxMsg)
Sets the maximum number of message for the subscription of this user.

Specified by:
setNbMaxMsg in interface UserAgentMBean
Parameters:
nbMaxMsg - the maximum number of message (-1 set no limit).

agentInitialize

public void agentInitialize(boolean firstTime)
                     throws java.lang.Exception
(Re)initializes the agent when (re)loading.

Overrides:
agentInitialize in class Agent
Parameters:
firstTime - true when first called by the factory
Throws:
java.lang.Exception - unspecialized exception

agentFinalize

public void agentFinalize(boolean lastTime)
Finalizes the agent before it is garbaged.

Overrides:
agentFinalize in class Agent
Parameters:
lastTime - true when last called by the factory on agent deletion.

react

public void react(AgentId from,
                  Notification not)
           throws java.lang.Exception
Overrides the Agent class react method for providing the JMS client proxy with its specific behaviour.

A JMS proxy specifically reacts to the following notifications:

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

sendNot

public void sendNot(AgentId to,
                    Notification not)
Sends a notification to the specified agent.

Specified by:
sendNot in interface ProxyAgentItf
Parameters:
to - the identifier of the recipient agent
not - the notification to send

sendToClient

public void sendToClient(int key,
                         AbstractJmsReply reply)
Sends a reply to the client connected through the specified connection.

Parameters:
key - the key of the connection the client is connected through.
reply - the reply to send to the client.

setNoSave

public void setNoSave()
Description copied from class: Agent
Sets the updated field to false so that the agent state is not saved after the current reaction; the field is set back to true for the next reaction.

Specified by:
setNoSave in interface ProxyAgentItf
Overrides:
setNoSave in class Agent

setSave

public void setSave()
Description copied from class: Agent
Sets the updated field to true so that the agent state is saved after the current reaction.

Specified by:
setSave in interface ProxyAgentItf
Overrides:
setSave in class Agent

toString

public java.lang.String toString()
Returns a string representation of this user's proxy.

Specified by:
toString in interface AgentMBean
Specified by:
toString in interface UserAgentMBean
Overrides:
toString in class Agent
Returns:
A string representation of this agent.

setInterceptors

public void setInterceptors(java.util.Properties prop)
Only call in UserAgent creation.

Parameters:
prop - properties

reactToClientRequest

protected void reactToClientRequest(int key,
                                    AbstractJmsRequest request)
Method processing clients requests.

Some of the client requests are directly forwarded, some others are sent to the proxy so that their processing occurs in a transaction.

A MomExceptionReply wrapping a DestinationException might be sent back if a target destination can't be identified.


getMsgTxname

protected final java.lang.String getMsgTxname()

setMsgTxName

protected final void setMsgTxName(Message msg)

getSubscriptionNames

public java.lang.String[] getSubscriptionNames()
Returns the list of subscriptions for this user. Each subscription is identified by its unique 'symbolic' name.

Specified by:
getSubscriptionNames in interface UserAgentMBean
Returns:
The list of subscriptions for this user.

deleteSubscriptionMessage

public void deleteSubscriptionMessage(java.lang.String subName,
                                      java.lang.String msgId)
Deletes a particular pending message in a subscription. The subscription is identified by its unique name, the message is pointed out through its unique identifier.

Parameters:
subName - The subscription unique name.
msgId - The unique message's identifier.

getClientContext

protected org.objectweb.joram.mom.proxies.ClientContext getClientContext(int ctxId)

cleanPendingMessages

protected void cleanPendingMessages(long currentTime)

delete

public void delete()
Description copied from class: Agent
Permits this agent to destroy itself. If necessary, this method should be overloaded to work properly.

Specified by:
delete in interface AgentMBean
Specified by:
delete in interface UserAgentMBean
Overrides:
delete in class Agent

readBag

public void readBag(java.io.ObjectInputStream in)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException
Description copied from interface: BagSerializer
The readBag method is responsible for reading from the stream and restoring the agent's transient state.

Specified by:
readBag in interface BagSerializer
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeBag

public void writeBag(java.io.ObjectOutputStream out)
              throws java.io.IOException
Description copied from interface: BagSerializer
The writeBag method is responsible for writing the extra data of this particular agent so that the corresponding readBag method can restore it.

Specified by:
writeBag in interface BagSerializer
Throws:
java.io.IOException

getNbMsgsSentToDMQSinceCreation

public long getNbMsgsSentToDMQSinceCreation()
Description copied from interface: UserAgentMBean
Returns the number of erroneous messages forwarded to the DMQ since creation time of this proxy..

Specified by:
getNbMsgsSentToDMQSinceCreation in interface UserAgentMBean
Returns:
the number of erroneous messages forwarded to the DMQ.


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