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
-
OPAgentContext(SocketParams)
- The constructor for the OPAgentContext just calls the constructor for
an AgentContext.
-
addAgent()
- This function creates the OPAgent and initializes it by calling its
init() function.
-
createCommInterface()
- Creates a SocketInterface for the Agent.
-
getBrokerAddress()
- This function gets the SocketAddress of the broker out of the params
and returns it.
-
main(String[])
- Called if the OPAgentContext is started as an application from
the command line.
-
setAgentAddress(int)
- Sets the agents address, and name if no name was specified.
-
SubmitAddress()
- Send the agent's name and address to the ANS.
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.
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)
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
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
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
SubmitAddress
protected void SubmitAddress()
- Send the agent's name and address to the ANS. This function must
be called by the OPAgent.
main
public static void main(String arg[])
- Called if the OPAgentContext is started as an application from
the command line. Command line args are:
- -b broker address - the address of the broker; must be provided
for an OPAgentContext
- -i init_file URL
- [-s] shared classes URL, for classes and other files which will
be shared with other agents.
- [-l] local directory for writing to the shared classes URL.
- [-w] working directory for saving local files, this should not
be included if the agent cannot access the local disk
- [-n] name, only included if the Agent should automatically
connect to the network.
- [-gui] create a GUI if this flag is included
- [-p] For for ServerSocket
- Parameters:
- arg - Array of command line arguments.
All Packages Class Hierarchy This Package Previous Next Index