Package jade.wrapper
Class ContainerController
- java.lang.Object
-
- jade.wrapper.ContainerController
-
- Direct Known Subclasses:
AgentContainer
public class ContainerController extends Object
This class is a Proxy class, allowing access to a JADE agent container. Invoking methods on instances of this class, it is possible to request services fromin-process agent containers. This class must not be instantiated by applications. Instead, use thecreateContainer()method in classRuntime.
NOT available in MIDP- Author:
- Giovanni Rimassa - Universita' di Parma, Giovanni Caire - TILAB
- See Also:
Runtime.createAgentContainer(Profile)
-
-
Field Summary
Fields Modifier and Type Field Description protected PlatformControllermyPlatformController
-
Constructor Summary
Constructors Constructor Description ContainerController(ContainerProxy cp, AgentContainer impl, String platformName)This constructor requires a concrete implementation of a JADE agent container, which cannot be instantiated by applications, so it cannot be meaningfully called from application code.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AgentControlleracceptNewAgent(String nickname, Agent anAgent)Add an Agent to this container.AgentControllercreateNewAgent(String nickname, String className, Object[] args)Creates a new JADE agent, running within this container,AgentControllergetAgent(String localAgentName)Get a controller (i.e.AgentControllergetAgent(String name, boolean isGuid)Get a controller (i.e.StringgetContainerName()Retrieve the name of the wrapped container.PlatformControllergetPlatformController()Retrieve a controller for the platform the container wrapped by this ContainerController belongs to and acts as the Main Container.StringgetPlatformName()Retrieve the name of the platform the container wrapped by this ContainerController belongs to.protected voidinitPlatformController()voidinstallMTP(String address, String className)Installs a new message transport protocol, that will run within this container.booleanisJoined()voidkill()Shuts down this container, terminating all the agents running within it.voiduninstallMTP(String address)Removes a message transport protocol, previously running within this container.
-
-
-
Field Detail
-
myPlatformController
protected PlatformController myPlatformController
-
-
Constructor Detail
-
ContainerController
public ContainerController(ContainerProxy cp, AgentContainer impl, String platformName)
This constructor requires a concrete implementation of a JADE agent container, which cannot be instantiated by applications, so it cannot be meaningfully called from application code. The proper way to create an agent container from an application is to call theRuntime.createContainer()method.- Parameters:
impl- A concrete implementation of a JADE agent container.platformName- the name of the platform- See Also:
Runtime.createAgentContainer(Profile)
-
-
Method Detail
-
getAgent
public AgentController getAgent(String localAgentName) throws ControllerException
Get a controller (i.e. a proxy) to a local agent given its local-name.- Parameters:
localAgentName- The local name of the desired agent.- Throws:
ControllerException- If any problems occur obtaining this proxy or if no such agent exists in the local container.
-
getAgent
public AgentController getAgent(String name, boolean isGuid) throws ControllerException
Get a controller (i.e. a proxy) to a local agent given its local-name or GUID.- Parameters:
name- The local name or the GUID of the desired agent.isGuid- A flag indicating whethernamerepresents the local-name (AID.ISLOCALNAME) or the GUID (AID.ISGUID) of the desired agent.- Throws:
ControllerException- If any problems occur obtaining this proxy or if no such agent exists in the local container.
-
createNewAgent
public AgentController createNewAgent(String nickname, String className, Object[] args) throws StaleProxyException
Creates a new JADE agent, running within this container,- Parameters:
nickname- A platform-unique nickname for the newly created agent. The agent will be given a FIPA compliant agent identifier using the nickname and the ID of the platform it is running on.className- The fully qualified name of the class that implements the agent.args- An object array, containing initialization parameters to pass to the new agent.- Returns:
- A proxy object, allowing to call state-transition forcing methods on the real agent instance.
- Throws:
StaleProxyException
-
acceptNewAgent
public AgentController acceptNewAgent(String nickname, Agent anAgent) throws StaleProxyException
Add an Agent to this container. Typically Agent would be some class extending Agent which was instantiated and configured.- Parameters:
nickname- A platform-unique nickname for the newly created agent. The agent will be given a FIPA compliant agent identifier using the nickname and the ID of the platform it is running on.anAgent- The agent to be added to this agent container.- Returns:
- An AgentController, allowing to call state-transition forcing methods on the real agent instance.
- Throws:
StaleProxyException
-
kill
public void kill() throws StaleProxyExceptionShuts down this container, terminating all the agents running within it.- Throws:
StaleProxyException
-
installMTP
public void installMTP(String address, String className) throws MTPException, StaleProxyException
Installs a new message transport protocol, that will run within this container.- Parameters:
address- The transport address exported by the new MTP, in string format.className- The fully qualified name of the Java class that implements the transport protocol.- Throws:
MTPException- If something goes wrong during transport protocol activation.StaleProxyException
-
uninstallMTP
public void uninstallMTP(String address) throws MTPException, NotFoundException, StaleProxyException
Removes a message transport protocol, previously running within this container.- Parameters:
address- The transport address exported by the new MTP, in string format.- Throws:
MTPException- If something goes wrong during transport protocol activation.NotFoundException- If no protocol with the given address is currently installed on this container.StaleProxyException
-
getPlatformName
public String getPlatformName()
Retrieve the name of the platform the container wrapped by this ContainerController belongs to.- Returns:
- the name (i.e. the HAP) of this platform.
-
getContainerName
public String getContainerName() throws ControllerException
Retrieve the name of the wrapped container.- Returns:
- the name of this platform container.
- Throws:
ControllerException
-
getPlatformController
public PlatformController getPlatformController() throws ControllerException
Retrieve a controller for the platform the container wrapped by this ContainerController belongs to and acts as the Main Container.- Returns:
- a
PlatfromControllerfor the platform the container wrapped by thisContainerControllerbelongs to. - Throws:
ControllerException- If the container wrapped by thisContainerControlleris not valid or is not the platform Main Container.
-
initPlatformController
protected void initPlatformController() throws ControllerException- Throws:
ControllerException
-
isJoined
public boolean isJoined()
-
-