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

public final class UserAgent
extends Agent
implements BagSerializer, ProxyAgentItf

Class of a user proxy agent.

See Also:
Serialized Form

Nested Class Summary
(package private)  class UserAgent.HeartBeatTask
          Timer task responsible for closing the connection if it has not sent any requests for the duration 'timeout'.
 
Field Summary
private  WakeUpTask cleaningTask
           
private  java.util.Hashtable connections
          Table that contains the user connections: - key = Integer (connection key) - value =
private  java.util.Hashtable heartBeatTasks
           
private  int keyCounter
          Counter of the connection keys
static org.objectweb.util.monolog.api.Logger logger
          logger
private  ProxyImpl proxyImpl
          All the user requests are delegated to the proxy
private static long serialVersionUID
          define serialVersionUID for interoperability
 
Fields inherited from class fr.dyade.aaa.agent.Agent
emptyString, fixed, logmon
 
Constructor Summary
UserAgent()
          Creates a new user proxy.
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.
private  void doReact(CloseConnectionNot not)
           
private  void doReact(GetConnectionNot not)
           
private  void doReact(OpenConnectionNot not)
          Registers and starts the UserConnection.
private  void doReact(ProxyRequestGroupNot not)
           
private  void doReact(RequestNot not)
           
private  void doReact(ResetCollocatedConnectionsNot not)
           
private  void doReact(ReturnConnectionNot not)
          Differs the reply because the connection key counter must be saved before the OpenConnectionNot returns.
private  void doReact(SendRepliesNot not)
           
private  void doReact(SendReplyNot not)
          Notification sent by local agents (destinations) indicating that the proxy can reply to a client.
 java.lang.String getMBeanName()
           
private  void init()
           
 void react(AgentId from, Notification not)
          Overrides the Agent class react method for providing the JMS client proxy with its specific behaviour.
 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 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.
private  void setPeriod(long period)
           
 void setSave()
          Sets the updated field to true so that the agent state is saved after the current reaction.
 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, delete, deploy, deploy, getAgentId, getCommitTime, getId, getLogTopic, getName, getReactNb, getReactTime, isDeployed, isFixed, needToBeCommited, save, sendTo, sendTo, sendTo, setName, toString
 
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.ProxyAgentItf
getId, getName
 

Field Detail

serialVersionUID

private static final long serialVersionUID
define serialVersionUID for interoperability

See Also:
Constant Field Values

logger

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


proxyImpl

private ProxyImpl proxyImpl
All the user requests are delegated to the proxy


connections

private transient java.util.Hashtable connections
Table that contains the user connections: - key = Integer (connection key) - value =


heartBeatTasks

private transient java.util.Hashtable heartBeatTasks

keyCounter

private int keyCounter
Counter of the connection keys


cleaningTask

private transient WakeUpTask cleaningTask
Constructor Detail

UserAgent

public UserAgent()
Creates a new user proxy.

See Also:
ConnectionManager

UserAgent

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

See Also:
ConnectionManager
Method Detail

init

private void init()

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.

getMBeanName

public java.lang.String getMBeanName()
Specified by:
getMBeanName in interface ProxyAgentItf

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

setPeriod

private void setPeriod(long period)

doReact

private void doReact(OpenConnectionNot not)
Registers and starts the UserConnection.


doReact

private void doReact(ReturnConnectionNot not)
Differs the reply because the connection key counter must be saved before the OpenConnectionNot returns.


doReact

private void doReact(GetConnectionNot not)

doReact

private void doReact(RequestNot not)

doReact

private void doReact(ProxyRequestGroupNot not)

doReact

private void doReact(CloseConnectionNot not)

doReact

private void doReact(ResetCollocatedConnectionsNot not)

doReact

private void doReact(SendRepliesNot not)

doReact

private void doReact(SendReplyNot not)
Notification sent by local agents (destinations) indicating that the proxy can reply to a client.

Parameters:
not -

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.

Specified by:
sendToClient in interface ProxyAgentItf
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

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


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