fr.dyade.aaa.agent
Class ProxyAgent

java.lang.Object
  extended byfr.dyade.aaa.agent.Agent
      extended byfr.dyade.aaa.agent.ProxyAgent
All Implemented Interfaces:
AgentMBean, java.io.Serializable

public abstract class ProxyAgent
extends Agent

See Also:
Serialized Form

Field Summary
protected  boolean blockingCnx
          true if connect may block
static int DRIVER_IN
           
static int DRIVER_OUT
           
protected  java.util.Hashtable driversTable
          Table holding the DriverMonitor objects, each one holding a connection set (a pair of drivers, a qout, ois, oos, ...).
protected  int inFlowControl
          flow control in driver in
protected  boolean multiConn
          true if the proxy manages multiple connections.
protected  boolean multipleCnx
          true if proxy may handle multiple connection
protected  NotificationInputStream ois
          input stream, created by subclass during connect
protected  NotificationOutputStream oos
          output stream, created by subclass during connect
protected  Queue qout
          communication with drvOut
 
Fields inherited from class fr.dyade.aaa.agent.Agent
fixed, logmon, name
 
Constructor Summary
ProxyAgent()
           
ProxyAgent(short to, java.lang.String n)
           
ProxyAgent(java.lang.String n)
           
ProxyAgent(java.lang.String name, int stamp)
           
 
Method Summary
 void agentFinalize(boolean lastime)
          Finalizes this proxy agent execution.
protected  void agentInitialize(boolean firstTime)
          Initializes the transient members of this agent.
 void cleanDriverOut()
          Method cleaning DriverOut.
 void cleanDriverOut(int drvKey)
          Method cleaning the DriverOut specified by the key parameter (multi-connections mode).
protected  void closeAllConnections()
          Closes all the connections.
abstract  void connect()
          Initializes the connection with the outside, up to creating the input and output streams ois and oos.
abstract  void disconnect()
          Closes the connection with the outside.
protected  void driverDone(DriverDone not)
          Reacts to end of driver execution.
protected  void driverReact(int key, Notification not)
          Method called by the ProxyAgent DriverIn instances to forward the notifications they got from their input streams.
protected  java.lang.String getLogTopic()
          Returns default log topic for proxies.
 void react(AgentId from, Notification not)
          Method implementing the ProxyAgent reactions to notifications.
protected  void reinitialize()
          Reinitializes the agent, that is reconnects its input and output.
protected  void sendOut(int key, Notification not)
          Method called by subclasses to directly send their notifications to the right DriverOut.
 void setMultiConn()
          Method setting the ProxyAgent in multiConn mode.
protected  void stop()
          Stops all drivers (non multiConn mode).
protected  void stop(int drvKey)
          Method stopping the specified connection set (multi-connections mode).
 java.lang.String toString()
          Provides a string image for this object.
 
Methods inherited from class fr.dyade.aaa.agent.Agent
delete, delete, deploy, deploy, getId, getName, isDeployed, isFixed, needToBeCommited, save, sendTo, sendTo, sendTo, setNoSave
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DRIVER_IN

public static final int DRIVER_IN
See Also:
Constant Field Values

DRIVER_OUT

public static final int DRIVER_OUT
See Also:
Constant Field Values

blockingCnx

protected boolean blockingCnx
true if connect may block


multipleCnx

protected boolean multipleCnx
true if proxy may handle multiple connection


inFlowControl

protected int inFlowControl
flow control in driver in


qout

protected transient Queue qout
communication with drvOut


multiConn

protected boolean multiConn
true if the proxy manages multiple connections.


driversTable

protected transient java.util.Hashtable driversTable
Table holding the DriverMonitor objects, each one holding a connection set (a pair of drivers, a qout, ois, oos, ...). For multi-connections management.

See Also:
DriverMonitor

ois

protected transient NotificationInputStream ois
input stream, created by subclass during connect


oos

protected transient NotificationOutputStream oos
output stream, created by subclass during connect

Constructor Detail

ProxyAgent

public ProxyAgent()

ProxyAgent

public ProxyAgent(java.lang.String n)

ProxyAgent

public ProxyAgent(short to,
                  java.lang.String n)

ProxyAgent

public ProxyAgent(java.lang.String name,
                  int stamp)
Method Detail

getLogTopic

protected java.lang.String getLogTopic()
Returns default log topic for proxies. Its method overriddes the default one in Agent, the resulting logging topic is Debug.A3Proxy dot the real classname.

Overrides:
getLogTopic in class Agent

toString

public java.lang.String toString()
Provides a string image for this object.

Specified by:
toString in interface AgentMBean
Overrides:
toString in class Agent
Returns:
printable image of this object

setMultiConn

public void setMultiConn()
Method setting the ProxyAgent in multiConn mode. To be called immediately after the ProxyAgent instanciation.


agentInitialize

protected void agentInitialize(boolean firstTime)
                        throws java.lang.Exception
Initializes the transient members of this agent. This function is first called by the factory agent, then by the system each time the agent server is restarted.

This function is not declared final so that derived classes may change their reload policy.

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

reinitialize

protected void reinitialize()
                     throws java.io.IOException
Reinitializes the agent, that is reconnects its input and output. This function may be called only when all drivers are null if the ProxyAgent manages only one connection at a time. Otherwise, a multiConn ProxyAgent will reinitialize even if the current drivers are not null.

Throws:
java.io.IOException

connect

public abstract void connect()
                      throws java.lang.Exception
Initializes the connection with the outside, up to creating the input and output streams ois and oos.

Throws:
java.lang.Exception - unspecialized exception

disconnect

public abstract void disconnect()
                         throws java.lang.Exception
Closes the connection with the outside.

Throws:
java.lang.Exception - unspecialized exception

stop

protected void stop()
Stops all drivers (non multiConn mode). May be multiply called.


stop

protected void stop(int drvKey)
Method stopping the specified connection set (multi-connections mode).

Parameters:
drvKey - key identifying the connection set to stop.

cleanDriverOut

public void cleanDriverOut()
Method cleaning DriverOut. Single connection mode only.


cleanDriverOut

public void cleanDriverOut(int drvKey)
Method cleaning the DriverOut specified by the key parameter (multi-connections mode).

Parameters:
drvKey - key identifying the connection set.

closeAllConnections

protected void closeAllConnections()
Closes all the connections.


driverReact

protected void driverReact(int key,
                           Notification not)
Method called by the ProxyAgent DriverIn instances to forward the notifications they got from their input streams.

May be overridden for specific behaviour as long as the proxy state is not modified by the method, because it does not occur within a transaction.

Parameters:
key - Driver identifier.
not - Notification to forward.

sendOut

protected void sendOut(int key,
                       Notification not)
                throws java.lang.Exception
Method called by subclasses to directly send their notifications to the right DriverOut.

Parameters:
key - Driver identifier.
not - Notification to send out.
Throws:
java.lang.Exception - If the driver to pass the notification to can't be retrieved from the key parameter.

react

public void react(AgentId from,
                  Notification not)
           throws java.lang.Exception
Method implementing the ProxyAgent reactions to notifications. Forwards notifications coming from an identified agent onto the outgoing connection.

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

driverDone

protected void driverDone(DriverDone not)
                   throws java.io.IOException
Reacts to end of driver execution.

This is the end of the driver thread, however the thread resources may not have been released. This is why close is called on the notification streams, which requires from the stream classes to cope with a call to close when some resources may have been released.

Throws:
java.io.IOException

agentFinalize

public void agentFinalize(boolean lastime)
Finalizes this proxy agent execution. Calls disconnect to close the open streams, and stop to stop the drivers.

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


Copyright ? 2004 Scalagent - All rights reserved