All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaAgent.oplan.OPAgentContext

java.lang.Object
   |
   +----JavaAgent.context.AgentContext
           |
           +----JavaAgent.oplan.OPAgentContext

public class OPAgentContext
extends AgentContext
OPAgentContext is the context for an OPAgent. One difference to a SocketContext on which this code is based is, of course, that the agent created in this context is an instance of the class OPAgent. Another important difference is that an OPAgentContext expects an additional command line argument marked -b (for broker) which specifies the address of the broker.

See Also:
SocketContext, OPAgent

Constructor Index

 o OPAgentContext(SocketParams)
The constructor for the OPAgentContext just calls the constructor for an AgentContext.

Method Index

 o addAgent()
This function creates the OPAgent and initializes it by calling its init() function.
 o createCommInterface()
Creates a SocketInterface for the Agent.
 o getBrokerAddress()
This function gets the SocketAddress of the broker out of the params and returns it.
 o main(String[])
Called if the OPAgentContext is started as an application from the command line.
 o setAgentAddress(int)
Sets the agents address, and name if no name was specified.
 o SubmitAddress()
Send the agent's name and address to the ANS.

Constructors

 o OPAgentContext
 public OPAgentContext(SocketParams params)
The constructor for the OPAgentContext just calls the constructor for an AgentContext. This is necessary as there is no constructor for an AgentContext that takes no arguments.

Parameters:
params - Runtime parameters for the AgentContext.

Methods

 o getBrokerAddress
 public SocketAddress getBrokerAddress()
This function gets the SocketAddress of the broker out of the params and returns it.

Returns:
the SocketAddress of the broker (ANS)
 o addAgent
 protected boolean addAgent()
This function creates the OPAgent and initializes it by calling its init() function. Note this does not include the reading of the init-file as for other Agents. It returns true iff the agent was created successfully.

Returns:
whether the agent was created sucessfully
Overrides:
addAgent in class AgentContext
 o createCommInterface
 protected void createCommInterface()
Creates a SocketInterface for the Agent. Unlike other Agents, this function does not cause the agent to announce its presence to the broker/ANS. This is now triggered by the Agent itself in the function sendInitMessages() which calls SubmitAddress() below.

Overrides:
createCommInterface in class AgentContext
 o setAgentAddress
 protected void setAgentAddress(int port)
Sets the agents address, and name if no name was specified.

Parameters:
port - the port of the agent on this host
 o SubmitAddress
 protected void SubmitAddress()
Send the agent's name and address to the ANS. This function must be called by the OPAgent.

 o main
 public static void main(String arg[])
Called if the OPAgentContext is started as an application from the command line. Command line args are:

Parameters:
arg - Array of command line arguments.

All Packages  Class Hierarchy  This Package  Previous  Next  Index