jade.wrapper.gateway
Class JadeGateway

java.lang.Object
  |
  +--jade.wrapper.gateway.JadeGateway

public class JadeGateway
extends java.lang.Object

This class is the entry point for using the functionalities of a simple gateway useful to issue commands to a JADE Agent. The class is responsible for creating, and keeping alive, a JADE Container and a JADE Agent.

The package must be used as follows:

An alternative way of using this functionality is to extend the GatewayBehaviour instead of GatewayAgent; notice that that allows re-use at the behaviour level rather than at the agent level: it is really an implementation choice left to the programmer and both choices are equivalently good. NOT available in MIDP

Version:
$Date: 2006-01-30 09:49:00 +0100 (Mon, 30 Jan 2006) $ $Revision: 5859 $
Author:
Fabio Bellifemine, Telecom Italia LAB

Method Summary
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 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, Properties jadeProfile)
          Initialize this gateway by passing the proper configuration parameters
static void shutdown()
          Kill the JADE Container in case it is running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProfileProperty

public static final 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. 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 static final void execute(java.lang.Object command)
                          throws StaleProxyException,
                                 ControllerException,
                                 java.lang.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 method releaseCommand is called by the executor agent)

Throws:
StaleProxyException - if the method was not able to execute the Command
ControllerException
java.lang.InterruptedException
See Also:
AgentController.putO2AObject(Object, boolean)

execute

public static final void execute(java.lang.Object command,
                                 long timeout)
                          throws StaleProxyException,
                                 ControllerException,
                                 java.lang.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 (i.e. the method releaseCommand is called by the executor agent)

Throws:
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 Command
ControllerException
See Also:
AgentController.putO2AObject(Object, boolean)

init

public static final void init(java.lang.String agentClassName,
                              Properties jadeProfile)
Initialize this gateway by passing the proper configuration parameters

Parameters:
agentClassName - is the fully-qualified class name of the agent to be executed
jadeProfile - 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

shutdown

public static final void shutdown()
Kill the JADE Container in case it is running.



JADE