public class JadeGateway
extends java.lang.Object
GatewayAgent
that acts as entry point in the JADE based system.
The activation/termination of this agent (and its underlying container) are completely managed
by the JadeGateway class and developers do not need to care about them.
The suggested way of using the JadeGateway class is creating proper behaviours that perform the commands
that the external system must issue to the JADE based system and pass them as parameters to the execute()
method. When the execute() method returns the internal agent of the JadeGateway as completely executed
the behaviour and outputs (if any) can be retrieved from the behaviour object using ad hoc methods
as exemplified below.
DoSomeActionBehaviour b = new DoSomeActionBehaviour(....);
JadeGateway.execute(b); // At this point b has been completely executed --> we can get results
result = b.getResult();
null
should be
passed as first parameter to the init()
method.
Alternatively programmers can
GatewayAgent
, that redefine its method processCommand
and that is the agent responsible for processing all command-requests
init
with the
name of the class of the application-specific agent
JadeGateway.execute(Object command).
This method will cause the callback of
the method processCommand
of the application-specific agent.
The method execute
will return only after the method GatewayAgent.releaseCommand(command)
has been called
by your application-specific agent.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SPLIT_CONTAINER |
Modifier and Type | Method and Description |
---|---|
static void |
addListener(GatewayListener l) |
static void |
checkJADE()
This method checks if both the container, and the agent, are up and running.
|
static void |
execute(java.lang.Object command)
execute a command.
|
static void |
execute(java.lang.Object command,
long timeout)
Execute a command specifying a timeout.
|
static DynamicJadeGateway |
getDefaultGateway() |
static java.lang.String |
getProfileProperty(java.lang.String key,
java.lang.String defaultValue)
Searches for the property with the specified key in the JADE Platform Profile.
|
static void |
init(java.lang.String agentClassName,
java.lang.Object[] agentArgs,
Properties jadeProfile)
Initialize this gateway by passing the proper configuration parameters
|
static void |
init(java.lang.String agentClassName,
Properties jadeProfile) |
static boolean |
isGatewayActive()
Return the state of JadeGateway
|
void |
removeListener(GatewayListener l) |
static void |
shutdown()
Kill the JADE Container in case it is running.
|
public static final java.lang.String SPLIT_CONTAINER
public static final java.lang.String getProfileProperty(java.lang.String key, java.lang.String defaultValue)
key
- - the property key.defaultValue
- - a default valueProperties.getProperty(String, String)
public static final void execute(java.lang.Object command) throws StaleProxyException, ControllerException, java.lang.InterruptedException
releaseCommand
is called by the executor agent)StaleProxyException
- if the method was not able to execute the CommandControllerException
java.lang.InterruptedException
AgentController.putO2AObject(Object, boolean)
public static final void execute(java.lang.Object command, long timeout) throws StaleProxyException, ControllerException, java.lang.InterruptedException
java.lang.InterruptedException
- if the timeout expires or the Thread
executing this method is interrupted.StaleProxyException
- if the method was not able to execute the CommandControllerException
AgentController.putO2AObject(Object, boolean)
public static final void checkJADE() throws StaleProxyException, ControllerException
public static final void init(java.lang.String agentClassName, java.lang.Object[] agentArgs, Properties jadeProfile)
agentClassName
- is the fully-qualified class name of the JadeGateway internal agent. If null is passed
the default class will be used.agentArgs
- is the list of agent argumentsjadeProfile
- the properties that contain all parameters for running JADE (see jade.core.Profile).
Typically these properties will have to be read from a JADE configuration file.
If jadeProfile is null, then a JADE container attaching to a main on the local host is launchedpublic static final void init(java.lang.String agentClassName, Properties jadeProfile)
public static final void shutdown()
public static final boolean isGatewayActive()
public static void addListener(GatewayListener l)
public void removeListener(GatewayListener l)
public static final DynamicJadeGateway getDefaultGateway()