fr.dyade.aaa.agent

Class ProxyAgent

Implemented Interfaces:
AgentMBean, Serializable

public abstract class ProxyAgent
extends Agent

Field Summary

static int
DRIVER_IN
static int
DRIVER_OUT
protected boolean
blockingCnx
true if connect may block
protected 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()
Allocates a new Agent object.
ProxyAgent(String n)
Allocates a new Agent object.
ProxyAgent(String name, int stamp)
ProxyAgent(short to, String n)
Allocates a new Agent object.

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.
void
connect()
Initializes the connection with the outside, up to creating the input and output streams ois and oos.
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 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).
String
toString()
Provides a string image for this object.

Methods inherited from class fr.dyade.aaa.agent.Agent

agentFinalize, agentInitialize, delete, delete, deploy, deploy, getId, getLogTopic, getName, isDeployed, isFixed, needToBeCommited, react, save, sendTo, sendTo, sendTo, setNoSave, toString

Field Details

DRIVER_IN

public static final int DRIVER_IN

Field Value:
1


DRIVER_OUT

public static final int DRIVER_OUT

Field Value:
2


blockingCnx

protected boolean blockingCnx
true if connect may block


driversTable

protected 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


inFlowControl

protected int inFlowControl
flow control in driver in


multiConn

protected boolean multiConn
true if the proxy manages multiple connections.


multipleCnx

protected boolean multipleCnx
true if proxy may handle multiple connection


ois

protected NotificationInputStream ois
input stream, created by subclass during connect


oos

protected NotificationOutputStream oos
output stream, created by subclass during connect


qout

protected Queue qout
communication with drvOut

Constructor Details

ProxyAgent

public ProxyAgent()
Allocates a new Agent object. The resulting object is not an agent; before it can react to a notification you must deploy it. This constructor has the same effect as Agent(AgentServer.getServerId(), null, false).

See Also:
Agent.Agent(short, java.lang.String, boolean), Agent.deploy()


ProxyAgent

public ProxyAgent(String n)
Allocates a new Agent object. This constructor has the same effect as Agent(AgentServer.getServerId(), name, false).

Parameters:

See Also:
Agent.Agent(short, java.lang.String, boolean)


ProxyAgent

public ProxyAgent(String name,
                  int stamp)


ProxyAgent

public ProxyAgent(short to,
                  String n)
Allocates a new Agent object. This constructor has the same effect as Agent(to, name, false).

Parameters:
to - Identication of target agent server

See Also:
Agent.Agent(short, java.lang.String, boolean)

Method Details

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 interface Agent

Parameters:


agentInitialize

protected void agentInitialize(boolean firstTime)
            throws 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 interface Agent

Parameters:
firstTime - true when first called by the factory


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.


connect

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


disconnect

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


driverDone

protected void driverDone(DriverDone not)
            throws 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.


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.


getLogTopic

protected 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 interface Agent


react

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

Parameters:
from - agent sending notification
not - notification to react to


reinitialize

protected void reinitialize()
            throws 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.


sendOut

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

Parameters:
key - Driver identifier.
not - Notification to send out.


setMultiConn

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


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.


toString

public String toString()
Provides a string image for this object.
Specified by:
toString in interface AgentMBean
Overrides:
toString in interface Agent

Returns:
printable image of this object


Copyright B) 2004 Scalagent - All rights reserved