jade.core
Class MainContainerImpl

java.lang.Object
  extended by jade.core.MainContainerImpl
All Implemented Interfaces:
AgentManager, MainContainer

public class MainContainerImpl
extends java.lang.Object
implements MainContainer, AgentManager

This class is a concrete implementation of the JADE main container, providing runtime support to JADE agents, and the special, front end container where the AMS and the Default DF can run. This class cannot be instantiated from applications. Instead, the Runtime.createMainContainer(Profile p) method must be called.

Version:
$Date: 2009-05-18 17:20:55 +0200 (lun, 18 mag 2009) $ $Revision: 6126 $
Author:
Giovanni Rimassa - Universita' di Parma
See Also:
Runtime.createMainContainer(Profile p);

Nested Class Summary
 
Nested classes/interfaces inherited from interface jade.core.AgentManager
AgentManager.Listener
 
Constructor Summary
MainContainerImpl(Profile p, PlatformManagerImpl pm)
           
 
Method Summary
 AgentDescriptor acquireAgentDescriptor(AID agentID)
           
 void activate(AID agentID)
          Resume an agent wherever it is
 void addListener(AgentManager.Listener l)
          Add a listener of platform events
 void addTool(AID tool)
           
 AID[] agentNames()
          Return the IDs of all agents in the platform
 AID[] agentTools()
           
 void amsDeregister(AMSAgentDescription dsc)
          Deregister an agent from the White Pages service of this platform
 void amsModify(AMSAgentDescription dsc)
          Modify the registration of an agent to the White Pages service of this platform.
 void amsRegister(AMSAgentDescription dsc)
          Register an agent to the White Pages service of this platform
 List amsSearch(AMSAgentDescription template, long maxResults)
          Searches the White Pages for agents whose description matches a given template.
 void bornAgent(AID aid, ContainerID cid, jade.security.JADEPrincipal principal, java.lang.String ownership, boolean forceReplacement)
          Notify the platform that an agent has just born on a container
 List containerAgents(ContainerID cid)
          Return all agents living on a container
 ContainerID[] containerIDs()
          Return the IDs of all containers in the platform
 List containerMTPs(ContainerID cid)
          Return all MTPs in a given container
 void copy(AID agentID, Location where, java.lang.String newName)
          Clone an agent to a given destination
 void create(java.lang.String name, java.lang.String className, java.lang.Object[] args, ContainerID cid, jade.security.JADEPrincipal owner, jade.security.Credentials initialCredentials, jade.security.JADEPrincipal requesterPrincipal, jade.security.Credentials requesterCredentials)
          Create an agent on a given container
 void deadAgent(AID name, boolean containerRemoved)
          Notify the platform that an agent has just died
 void deadMTP(MTPDescriptor mtp, ContainerID cid)
          Notify the platform that an MTP is no longer active on a given container
 void debugOff(AID debuggerName, List notToBeDebugged)
          Deactivate debugging on a given agent
 void debugOn(AID debuggerName, List toBeDebugged)
          Activate debugging on a given agent
 void frozenAgent(AID name, ContainerID bufferContainer)
          Notify the platform that an agent has just frozen
 AMSAgentDescription getAMSDescription(AID agentID)
          Return the AMS description of an agent
 ContainerID getContainerID(AID agentID)
          Return the ID of the container an agent lives in
 NodeDescriptor getContainerNode(ContainerID cid)
          Return the node a container is deployed at
 PlatformManager getPlatformManager()
           
 MTPDescriptor installMTP(java.lang.String address, ContainerID cid, java.lang.String className)
          Install a new MTP on a given container
 void kill(AID agentID, jade.security.JADEPrincipal requesterPrincipal, jade.security.Credentials requesterCredentials)
          Kill an agent wherever it is
 void killContainer(ContainerID cid, jade.security.JADEPrincipal requesterPrincipal, jade.security.Credentials requesterCredentials)
          Kill a given container
 void move(AID agentID, Location where)
          Move an agent to a given destination
 void movedAgent(AID agentID, ContainerID srcID, ContainerID destID)
          Notify the platform that an agent has just moved
 void newMTP(MTPDescriptor mtp, ContainerID cid)
          Notify the platform that a new MTP has become active on a given container
 void releaseAgentDescriptor(AID agentID)
           
 void removeListener(AgentManager.Listener l)
          Remove a listener of platform events
 void removeTool(AID tool)
           
 void resumedAgent(AID name)
          Notify the platform that an agent has just resumed
 void shutdownPlatform(jade.security.JADEPrincipal requesterPrincipal, jade.security.Credentials requesterCredentials)
          Shut down the whole platform
 void sniffOff(AID snifferName, List notToBeSniffed)
          Deactivate sniffing on a given agent
 void sniffOn(AID snifferName, List toBeSniffed)
          Activate sniffing on a given agent
 void suspend(AID agentID)
          Suspend an agent wherever it is
 void suspendedAgent(AID name)
          Notify the platform that an agent has just suspended
 void take(AID agentID, java.lang.String username, byte[] password)
          Change the ownership of an agent // FIXME: implement or remove
 void thawedAgent(AID name, ContainerID bufferContainer)
          Notify the platform that an agent has just thawed
 void toolAdded(AID tool)
           
 void toolRemoved(AID tool)
           
 void uninstallMTP(java.lang.String address, ContainerID cid)
          Uninstall an MTP on a given container
 void wait(AID agentID, java.lang.String password)
          Put an agent in the WAITING state wherever it is
 void wake(AID agentID, java.lang.String password)
          Wake-up an agent wherever it is
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MainContainerImpl

public MainContainerImpl(Profile p,
                         PlatformManagerImpl pm)
                  throws ProfileException
Throws:
ProfileException
Method Detail

getPlatformManager

public PlatformManager getPlatformManager()

bornAgent

public void bornAgent(AID aid,
                      ContainerID cid,
                      jade.security.JADEPrincipal principal,
                      java.lang.String ownership,
                      boolean forceReplacement)
               throws NameClashException,
                      NotFoundException
Notify the platform that an agent has just born on a container

Specified by:
bornAgent in interface MainContainer
Throws:
NameClashException
NotFoundException

deadAgent

public void deadAgent(AID name,
                      boolean containerRemoved)
               throws NotFoundException
Notify the platform that an agent has just died

Specified by:
deadAgent in interface MainContainer
Throws:
NotFoundException

suspendedAgent

public void suspendedAgent(AID name)
                    throws NotFoundException
Notify the platform that an agent has just suspended

Specified by:
suspendedAgent in interface MainContainer
Throws:
NotFoundException

resumedAgent

public void resumedAgent(AID name)
                  throws NotFoundException
Notify the platform that an agent has just resumed

Specified by:
resumedAgent in interface MainContainer
Throws:
NotFoundException

movedAgent

public void movedAgent(AID agentID,
                       ContainerID srcID,
                       ContainerID destID)
                throws NotFoundException
Notify the platform that an agent has just moved

Specified by:
movedAgent in interface MainContainer
Throws:
NotFoundException

frozenAgent

public void frozenAgent(AID name,
                        ContainerID bufferContainer)
                 throws NotFoundException
Notify the platform that an agent has just frozen

Specified by:
frozenAgent in interface MainContainer
Throws:
NotFoundException

thawedAgent

public void thawedAgent(AID name,
                        ContainerID bufferContainer)
                 throws NotFoundException
Notify the platform that an agent has just thawed

Specified by:
thawedAgent in interface MainContainer
Throws:
NotFoundException

newMTP

public void newMTP(MTPDescriptor mtp,
                   ContainerID cid)
            throws IMTPException
Notify the platform that a new MTP has become active on a given container

Specified by:
newMTP in interface MainContainer
Throws:
IMTPException

deadMTP

public void deadMTP(MTPDescriptor mtp,
                    ContainerID cid)
             throws IMTPException
Notify the platform that an MTP is no longer active on a given container

Specified by:
deadMTP in interface MainContainer
Throws:
IMTPException

addTool

public void addTool(AID tool)
Specified by:
addTool in interface AgentManager

removeTool

public void removeTool(AID tool)
Specified by:
removeTool in interface AgentManager

create

public void create(java.lang.String name,
                   java.lang.String className,
                   java.lang.Object[] args,
                   ContainerID cid,
                   jade.security.JADEPrincipal owner,
                   jade.security.Credentials initialCredentials,
                   jade.security.JADEPrincipal requesterPrincipal,
                   jade.security.Credentials requesterCredentials)
            throws UnreachableException,
                   jade.security.JADESecurityException,
                   NotFoundException,
                   NameClashException
Create an agent on a given container

Specified by:
create in interface AgentManager
Throws:
UnreachableException - if the container is unreachable
jade.security.JADESecurityException - if this action is not authorized
NotFoundException - if the passed container does not exist
NameClashException
See Also:
throws UnreachableException, JADESecurityException, NotFoundException

kill

public void kill(AID agentID,
                 jade.security.JADEPrincipal requesterPrincipal,
                 jade.security.Credentials requesterCredentials)
          throws NotFoundException,
                 UnreachableException,
                 jade.security.JADESecurityException
Kill an agent wherever it is

Specified by:
kill in interface AgentManager
Throws:
NotFoundException
UnreachableException
jade.security.JADESecurityException

suspend

public void suspend(AID agentID)
             throws NotFoundException,
                    UnreachableException,
                    jade.security.JADESecurityException
Suspend an agent wherever it is

Specified by:
suspend in interface AgentManager
Throws:
NotFoundException
UnreachableException
jade.security.JADESecurityException

activate

public void activate(AID agentID)
              throws NotFoundException,
                     UnreachableException,
                     jade.security.JADESecurityException
Resume an agent wherever it is

Specified by:
activate in interface AgentManager
Throws:
NotFoundException
UnreachableException
jade.security.JADESecurityException

wait

public void wait(AID agentID,
                 java.lang.String password)
          throws NotFoundException,
                 UnreachableException
Put an agent in the WAITING state wherever it is

Specified by:
wait in interface AgentManager
Throws:
NotFoundException
UnreachableException

wake

public void wake(AID agentID,
                 java.lang.String password)
          throws NotFoundException,
                 UnreachableException
Wake-up an agent wherever it is

Specified by:
wake in interface AgentManager
Throws:
NotFoundException
UnreachableException

move

public void move(AID agentID,
                 Location where)
          throws NotFoundException,
                 UnreachableException,
                 jade.security.JADESecurityException
Move an agent to a given destination

Specified by:
move in interface AgentManager
Throws:
NotFoundException
UnreachableException
jade.security.JADESecurityException

copy

public void copy(AID agentID,
                 Location where,
                 java.lang.String newName)
          throws NotFoundException,
                 NameClashException,
                 UnreachableException,
                 jade.security.JADESecurityException
Clone an agent to a given destination

Specified by:
copy in interface AgentManager
Throws:
NotFoundException
NameClashException
UnreachableException
jade.security.JADESecurityException

killContainer

public void killContainer(ContainerID cid,
                          jade.security.JADEPrincipal requesterPrincipal,
                          jade.security.Credentials requesterCredentials)
                   throws NotFoundException,
                          UnreachableException,
                          jade.security.JADESecurityException
Kill a given container

Specified by:
killContainer in interface AgentManager
Throws:
NotFoundException
UnreachableException
jade.security.JADESecurityException

shutdownPlatform

public void shutdownPlatform(jade.security.JADEPrincipal requesterPrincipal,
                             jade.security.Credentials requesterCredentials)
                      throws jade.security.JADESecurityException
Shut down the whole platform

Specified by:
shutdownPlatform in interface AgentManager
Throws:
jade.security.JADESecurityException

installMTP

public MTPDescriptor installMTP(java.lang.String address,
                                ContainerID cid,
                                java.lang.String className)
                         throws NotFoundException,
                                UnreachableException,
                                MTPException
Install a new MTP on a given container

Specified by:
installMTP in interface AgentManager
Throws:
NotFoundException
UnreachableException
MTPException

uninstallMTP

public void uninstallMTP(java.lang.String address,
                         ContainerID cid)
                  throws NotFoundException,
                         UnreachableException,
                         MTPException
Uninstall an MTP on a given container

Specified by:
uninstallMTP in interface AgentManager
Throws:
NotFoundException
UnreachableException
MTPException

take

public void take(AID agentID,
                 java.lang.String username,
                 byte[] password)
          throws NotFoundException,
                 UnreachableException,
                 jade.security.JADESecurityException
Change the ownership of an agent // FIXME: implement or remove

Specified by:
take in interface AgentManager
Throws:
NotFoundException
UnreachableException
jade.security.JADESecurityException

sniffOn

public void sniffOn(AID snifferName,
                    List toBeSniffed)
             throws NotFoundException,
                    UnreachableException
Activate sniffing on a given agent

Specified by:
sniffOn in interface AgentManager
Throws:
NotFoundException
UnreachableException

sniffOff

public void sniffOff(AID snifferName,
                     List notToBeSniffed)
              throws NotFoundException,
                     UnreachableException
Deactivate sniffing on a given agent

Specified by:
sniffOff in interface AgentManager
Throws:
NotFoundException
UnreachableException

debugOn

public void debugOn(AID debuggerName,
                    List toBeDebugged)
             throws NotFoundException,
                    UnreachableException
Activate debugging on a given agent

Specified by:
debugOn in interface AgentManager
Throws:
NotFoundException
UnreachableException

debugOff

public void debugOff(AID debuggerName,
                     List notToBeDebugged)
              throws NotFoundException,
                     UnreachableException
Deactivate debugging on a given agent

Specified by:
debugOff in interface AgentManager
Throws:
NotFoundException
UnreachableException

amsRegister

public void amsRegister(AMSAgentDescription dsc)
                 throws AlreadyRegistered,
                        jade.security.JADESecurityException
Register an agent to the White Pages service of this platform

Specified by:
amsRegister in interface AgentManager
Throws:
AlreadyRegistered
jade.security.JADESecurityException

amsDeregister

public void amsDeregister(AMSAgentDescription dsc)
                   throws NotRegistered,
                          jade.security.JADESecurityException
Deregister an agent from the White Pages service of this platform

Specified by:
amsDeregister in interface AgentManager
Throws:
NotRegistered
jade.security.JADESecurityException

amsModify

public void amsModify(AMSAgentDescription dsc)
               throws NotRegistered,
                      NotFoundException,
                      UnreachableException,
                      jade.security.JADESecurityException
Modify the registration of an agent to the White Pages service of this platform. If the modification implies a change in the agent state (and the agent lives in the platform) --> force that change If the modification implies a change in the agent ownership (and the agent lives in the platform) --> force that change

Specified by:
amsModify in interface AgentManager
Throws:
NotRegistered
NotFoundException
UnreachableException
jade.security.JADESecurityException

amsSearch

public List amsSearch(AMSAgentDescription template,
                      long maxResults)
Searches the White Pages for agents whose description matches a given template.

Specified by:
amsSearch in interface AgentManager

containerIDs

public ContainerID[] containerIDs()
Return the IDs of all containers in the platform

Specified by:
containerIDs in interface AgentManager
Specified by:
containerIDs in interface MainContainer

agentNames

public AID[] agentNames()
Return the IDs of all agents in the platform

Specified by:
agentNames in interface AgentManager
Specified by:
agentNames in interface MainContainer

containerMTPs

public List containerMTPs(ContainerID cid)
                   throws NotFoundException
Return all MTPs in a given container

Specified by:
containerMTPs in interface AgentManager
Specified by:
containerMTPs in interface MainContainer
Throws:
NotFoundException

containerAgents

public List containerAgents(ContainerID cid)
                     throws NotFoundException
Return all agents living on a container

Specified by:
containerAgents in interface AgentManager
Specified by:
containerAgents in interface MainContainer
Throws:
NotFoundException

toolAdded

public void toolAdded(AID tool)
Specified by:
toolAdded in interface MainContainer

toolRemoved

public void toolRemoved(AID tool)
Specified by:
toolRemoved in interface MainContainer

agentTools

public AID[] agentTools()
Specified by:
agentTools in interface AgentManager

getContainerID

public ContainerID getContainerID(AID agentID)
                           throws NotFoundException
Return the ID of the container an agent lives in

Specified by:
getContainerID in interface AgentManager
Specified by:
getContainerID in interface MainContainer
Throws:
NotFoundException

getContainerNode

public NodeDescriptor getContainerNode(ContainerID cid)
                                throws NotFoundException
Return the node a container is deployed at

Specified by:
getContainerNode in interface MainContainer
Throws:
NotFoundException

getAMSDescription

public AMSAgentDescription getAMSDescription(AID agentID)
                                      throws NotFoundException
Return the AMS description of an agent

Specified by:
getAMSDescription in interface AgentManager
Throws:
NotFoundException

addListener

public void addListener(AgentManager.Listener l)
Add a listener of platform events

Specified by:
addListener in interface AgentManager

removeListener

public void removeListener(AgentManager.Listener l)
Remove a listener of platform events

Specified by:
removeListener in interface AgentManager

acquireAgentDescriptor

public AgentDescriptor acquireAgentDescriptor(AID agentID)
Specified by:
acquireAgentDescriptor in interface MainContainer

releaseAgentDescriptor

public void releaseAgentDescriptor(AID agentID)
Specified by:
releaseAgentDescriptor in interface MainContainer