Package jade.wrapper.gateway
Class DynamicJadeGateway
- java.lang.Object
-
- jade.wrapper.gateway.DynamicJadeGateway
-
- Direct Known Subclasses:
LocalJadeGateway,SplitJadeGateway
public class DynamicJadeGateway extends Object
-
-
Constructor Summary
Constructors Constructor Description DynamicJadeGateway()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(GatewayListener l)voidcheckJADE()This method checks if both the container, and the agent, are up and running.AIDcreateAID(String localName)voidexecute(Object command)execute a command.voidexecute(Object command, long timeout)Execute a command specifying a timeout.StringgetProfileProperty(String key, String defaultValue)Searches for the property with the specified key in the JADE Platform Profile.voidinit(String agentClassName, Properties jadeProfile)voidinit(String agentClassName, Object[] agentArgs, Properties jadeProfile)Initialize this gateway by passing the proper configuration parametersvoidinit(String agentName, String agentClassName, Object[] agentArgs, Properties jadeProfile)Initialize this gateway by passing the proper configuration parametersbooleanisGatewayActive()Return the state of JadeGatewayvoidremoveListener(GatewayListener l)voidshutdown()Kill the JADE Container in case it is running.
-
-
-
Method Detail
-
getProfileProperty
public final String getProfileProperty(String key, String defaultValue)
Searches for the property with the specified key in the JADE Platform Profile. The method returns the default value argument if the property is not found.- Parameters:
key- - the property key.defaultValue- - a default value- Returns:
- the value with the specified key value
- See Also:
Properties.getProperty(String, String)
-
execute
public final void execute(Object command) throws StaleProxyException, ControllerException, InterruptedException
execute a command. This method first check if the executor Agent is alive (if not it creates container and agent), then it forwards the execution request to the agent, finally it blocks waiting until the command has been executed (i.e. the methodreleaseCommandis called by the executor agent)- Throws:
StaleProxyException- if the method was not able to execute the CommandControllerExceptionInterruptedException- See Also:
AgentController.putO2AObject(Object, boolean)
-
execute
public final void execute(Object command, long timeout) throws StaleProxyException, ControllerException, InterruptedException
Execute a command specifying a timeout. This method first check if the executor Agent is alive (if not it creates container and agent), then it forwards the execution request to the agent, finally it blocks waiting until the command has been executed. In case the command is a behaviour this method blocks until the behaviour has been completely executed.- Throws:
InterruptedException- if the timeout expires or the Thread executing this method is interrupted.StaleProxyException- if the method was not able to execute the CommandControllerException- See Also:
AgentController.putO2AObject(Object, boolean)
-
checkJADE
public void checkJADE() throws StaleProxyException, ControllerExceptionThis method checks if both the container, and the agent, are up and running. If not, then the method is responsible for renewing myContainer. Normally programmers do not need to invoke this method explicitly.
-
init
public final void init(String agentName, String agentClassName, Object[] agentArgs, Properties jadeProfile)
Initialize this gateway by passing the proper configuration parameters- Parameters:
agentName- is the name of the JadeGateway internal agent. If null is passed the default name will be used.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 launched
-
init
public final void init(String agentClassName, Object[] agentArgs, Properties jadeProfile)
Initialize this gateway by passing the proper configuration parameters- Parameters:
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 launched
-
init
public final void init(String agentClassName, Properties jadeProfile)
-
shutdown
public void shutdown()
Kill the JADE Container in case it is running.
-
isGatewayActive
public boolean isGatewayActive()
Return the state of JadeGateway- Returns:
- true if the container and the gateway agent are active, false otherwise
-
addListener
public void addListener(GatewayListener l)
-
removeListener
public void removeListener(GatewayListener l)
-
-