jade.core
Class BackEndContainer

java.lang.Object
  extended by jade.core.BackEndContainer
All Implemented Interfaces:
AgentContainer, BackEnd

public class BackEndContainer
extends java.lang.Object
implements BackEnd

Author:
Giovanni Caire - TILAB, Jerome Picault - Motorola Labs

Nested Class Summary
 class BackEndContainer.AgentImage
          Inner class AgentImage
 
Field Summary
static java.lang.String ENABLE_MONITOR
           
protected  jade.core.LADT localAgents
           
static java.lang.String MONITOR_AGENT_CLASS
           
static java.lang.String MONITOR_AGENT_NAME
           
protected  jade.core.CommandProcessor myCommandProcessor
           
protected  ContainerID myID
           
protected  IMTPManager myIMTPManager
           
protected  MainContainerImpl myMainContainer
           
protected  NodeDescriptor myNodeDescriptor
           
protected  Profile myProfile
           
protected  jade.security.Credentials ownerCredentials
           
protected  jade.security.JADEPrincipal ownerPrincipal
           
static java.lang.String RESYNCH
           
static java.lang.String USE_BACKEND_MANAGER
           
 
Fields inherited from interface jade.core.AgentContainer
AUX_CONTAINER_NAME, MAIN_CONTAINER_NAME
 
Constructor Summary
BackEndContainer(Properties props, BEConnectionManager cm)
           
 
Method Summary
 Agent acquireLocalAgent(AID id)
           
 void addAddressToLocalAgents(java.lang.String address)
           
 BackEndContainer.AgentImage addAgentImage(AID id, BackEndContainer.AgentImage img)
           
 Agent addLocalAgent(AID id, Agent a)
           
 void addPlatformListener(AgentManager.Listener l)
           
 AID[] agentNames()
           
 void becomeLeader(AMSEventQueueFeeder feeder)
           
 java.lang.String bornAgent(java.lang.String name)
          A new agent has just started on the FrontEnd.
 boolean connect()
           
 BackEndContainer.AgentImage createAgentImage(AID id)
           
 void createAgentOnFE(java.lang.String name, java.lang.String className, java.lang.String[] args)
           
 void deadAgent(java.lang.String name)
          An agent has just died on the FrontEnd.
 void disableDebugger(AID debuggerName, AID notToBeDebugged)
          This method is re-defined to avoid NullPointerException.
 void enableDebugger(AID debuggerName, AID toBeDebugged)
          This method is re-defined to avoid NullPointerException.
 void fillListFromBlockedBehaviours(List behaviours, Agent a)
           
 void fillListFromMessageQueue(List messages, Agent a)
           
 void fillListFromReadyBehaviours(List behaviours, Agent a)
           
 BackEndContainer.AgentImage getAgentImage(AID id)
           
 AID[] getAgentImages()
           
 AID getAMS()
           
 Properties getBootProperties()
           
 AgentContainer getContainerController(jade.security.JADEPrincipal principal, jade.security.Credentials credentials)
           
 AID getDefaultDF()
           
 ServiceHelper getHelper(Agent a, java.lang.String serviceName)
           
 ContainerID getID()
           
 MainContainer getMain()
           
 NodeDescriptor getNodeDescriptor()
           
 java.lang.String getPlatformID()
           
 java.lang.String getProperty(java.lang.String key, java.lang.String aDefault)
           
 ServiceFinder getServiceFinder()
           
 ServiceManager getServiceManager()
           
 void handleBehaviourAdded(AID agentID, Behaviour b)
           
 void handleBehaviourRemoved(AID agentID, Behaviour b)
           
 void handleChangeBehaviourState(AID agentID, Behaviour b, java.lang.String from, java.lang.String to)
           
 void handleChangedAgentPrincipal(AID agentID, jade.security.JADEPrincipal oldPrincipal, jade.security.Credentials creds)
           
 void handleChangedAgentState(AID agentID, int oldState, int newState)
           
 void handleEnd(AID agentID)
           
 void handlePosted(AID agentID, ACLMessage msg)
           
 void handleReceived(AID agentID, ACLMessage msg)
          Issue a NOTIFY_RECEIVED VerticalCommand
 void handleSend(ACLMessage msg, AID sender, boolean needClone)
          Issue a SEND_MESSAGE VerticalCommand for each receiver
 Location here()
           
protected  void init()
           
 void initAgent(AID agentID, Agent instance, jade.security.JADEPrincipal ownerPrincipal, jade.security.Credentials initialCredentials)
          Issue an INFORM_CREATED vertical command.
 boolean isJoined()
           
 boolean isLocalAgent(AID id)
           
 void killAgentOnFE(java.lang.String name)
           
 void messageOut(ACLMessage msg, java.lang.String sender)
          An agent on the FrontEnd has sent a message.
 boolean postMessageToLocalAgent(ACLMessage msg, AID receiverID)
          Dispatch a message to an agent in the FrontEnd.
 void powerUpLocalAgent(AID agentID)
           
 void releaseLocalAgent(AID id)
           
 void removeAddressFromLocalAgents(java.lang.String address)
           
 BackEndContainer.AgentImage removeAgentImage(AID id)
           
 void removeLocalAgent(AID id)
           
 List removePendingMessages(MessageTemplate template, boolean notifyFailure)
           
 void removePlatformListener(AgentManager.Listener l)
           
 void resumeAgentOnFE(java.lang.String name)
           
 void resumedAgent(java.lang.String name)
          Notify the BackEnd container that an agent has resumed.
 java.lang.Object serviceInvokation(java.lang.String actor, java.lang.String serviceName, java.lang.String methodName, java.lang.Object[] methodParams)
          Pass a service helper method invokation request to the BackEnd
 void setPlatformAddresses(AID id)
           
 void shutDown()
           
protected  void startNode()
          Add the node to the platform with the basic services
protected  ServiceDescriptor startService(java.lang.String name, boolean activateIt)
           
protected  void stopService(java.lang.String name)
           
 void suspendAgentOnFE(java.lang.String name)
           
 void suspendedAgent(java.lang.String name)
          Notify the BackEnd container that an agent has suspended.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_BACKEND_MANAGER

public static final java.lang.String USE_BACKEND_MANAGER
See Also:
Constant Field Values

RESYNCH

public static final java.lang.String RESYNCH
See Also:
Constant Field Values

ENABLE_MONITOR

public static final java.lang.String ENABLE_MONITOR
See Also:
Constant Field Values

MONITOR_AGENT_NAME

public static final java.lang.String MONITOR_AGENT_NAME
See Also:
Constant Field Values

MONITOR_AGENT_CLASS

public static final java.lang.String MONITOR_AGENT_CLASS
See Also:
Constant Field Values

localAgents

protected jade.core.LADT localAgents

myProfile

protected Profile myProfile

myCommandProcessor

protected jade.core.CommandProcessor myCommandProcessor

myMainContainer

protected MainContainerImpl myMainContainer

myIMTPManager

protected IMTPManager myIMTPManager

myID

protected ContainerID myID

myNodeDescriptor

protected NodeDescriptor myNodeDescriptor

ownerPrincipal

protected jade.security.JADEPrincipal ownerPrincipal

ownerCredentials

protected jade.security.Credentials ownerCredentials
Constructor Detail

BackEndContainer

public BackEndContainer(Properties props,
                        BEConnectionManager cm)
                 throws ProfileException
Throws:
ProfileException
Method Detail

connect

public boolean connect()

startNode

protected void startNode()
                  throws IMTPException,
                         ProfileException,
                         ServiceException,
                         jade.security.JADESecurityException,
                         NotFoundException
Add the node to the platform with the basic services

Throws:
IMTPException
ProfileException
ServiceException
jade.security.JADESecurityException
NotFoundException

bornAgent

public java.lang.String bornAgent(java.lang.String name)
                           throws jade.security.JADESecurityException,
                                  IMTPException
A new agent has just started on the FrontEnd. Adjust the agent name taking into account wild-cards. Issue an INFORM_CREATED vertical command.

Specified by:
bornAgent in interface BackEnd
Parameters:
name - The name of the new agent.
Returns:
the actual name of the agent
Throws:
jade.security.JADESecurityException
IMTPException

deadAgent

public void deadAgent(java.lang.String name)
               throws IMTPException
An agent has just died on the FrontEnd. Remove its image and notify the Main

Specified by:
deadAgent in interface BackEnd
Parameters:
name - The name of the dead agent.
Throws:
IMTPException

suspendedAgent

public void suspendedAgent(java.lang.String name)
                    throws NotFoundException,
                           IMTPException
Description copied from interface: BackEnd
Notify the BackEnd container that an agent has suspended.

Specified by:
suspendedAgent in interface BackEnd
Parameters:
name - The name of the suspended agent.
Throws:
NotFoundException
IMTPException

resumedAgent

public void resumedAgent(java.lang.String name)
                  throws NotFoundException,
                         IMTPException
Description copied from interface: BackEnd
Notify the BackEnd container that an agent has resumed.

Specified by:
resumedAgent in interface BackEnd
Parameters:
name - The name of the resumed agent.
Throws:
NotFoundException
IMTPException

messageOut

public void messageOut(ACLMessage msg,
                       java.lang.String sender)
                throws NotFoundException,
                       IMTPException
An agent on the FrontEnd has sent a message. Note that the NotFoundException here is referred to the sender and indicates an inconsistency between the FrontEnd and the BackEnd

Specified by:
messageOut in interface BackEnd
Parameters:
msg - The message to be dispatched.
sender - The name of the sender agent.
Throws:
NotFoundException
IMTPException

serviceInvokation

public java.lang.Object serviceInvokation(java.lang.String actor,
                                          java.lang.String serviceName,
                                          java.lang.String methodName,
                                          java.lang.Object[] methodParams)
                                   throws NotFoundException,
                                          ServiceException,
                                          IMTPException
Description copied from interface: BackEnd
Pass a service helper method invokation request to the BackEnd

Specified by:
serviceInvokation in interface BackEnd
Parameters:
actor - The name of the agent that invoked the method
serviceName - The name of the service
methodName - The name of the invoked method
methodParams - The parameters of the invoked methods as an array of Objects
Returns:
the result of the invoked method or null if the method returns void
Throws:
NotFoundException
ServiceException
IMTPException

createAgentOnFE

public void createAgentOnFE(java.lang.String name,
                            java.lang.String className,
                            java.lang.String[] args)
                     throws IMTPException
Throws:
IMTPException

killAgentOnFE

public void killAgentOnFE(java.lang.String name)
                   throws IMTPException,
                          NotFoundException
Throws:
IMTPException
NotFoundException

suspendAgentOnFE

public void suspendAgentOnFE(java.lang.String name)
                      throws IMTPException,
                             NotFoundException
Throws:
IMTPException
NotFoundException

resumeAgentOnFE

public void resumeAgentOnFE(java.lang.String name)
                     throws IMTPException,
                            NotFoundException
Throws:
IMTPException
NotFoundException

postMessageToLocalAgent

public boolean postMessageToLocalAgent(ACLMessage msg,
                                       AID receiverID)
Dispatch a message to an agent in the FrontEnd. If this method is called by a thread that is serving a message sent by an agent in the FrontEnd too, nothing is done as the dispatch has already taken place in the FrontEnd (see messageOut()).

Specified by:
postMessageToLocalAgent in interface AgentContainer

acquireLocalAgent

public Agent acquireLocalAgent(AID id)
Specified by:
acquireLocalAgent in interface AgentContainer

releaseLocalAgent

public void releaseLocalAgent(AID id)
Specified by:
releaseLocalAgent in interface AgentContainer

agentNames

public AID[] agentNames()
Specified by:
agentNames in interface AgentContainer

enableDebugger

public void enableDebugger(AID debuggerName,
                           AID toBeDebugged)
                    throws IMTPException
This method is re-defined to avoid NullPointerException. In fact a search in the LADT would be done for the agent to be debugged, but the LADT is obviously empty.

Throws:
IMTPException

disableDebugger

public void disableDebugger(AID debuggerName,
                            AID notToBeDebugged)
                     throws IMTPException
This method is re-defined to avoid NullPointerException. In fact a search in the LADT would be done for the agent to be debugged, but the LADT is obviously empty.

Throws:
IMTPException

shutDown

public void shutDown()
Specified by:
shutDown in interface AgentContainer

createAgentImage

public BackEndContainer.AgentImage createAgentImage(AID id)

addAgentImage

public BackEndContainer.AgentImage addAgentImage(AID id,
                                                 BackEndContainer.AgentImage img)

removeAgentImage

public BackEndContainer.AgentImage removeAgentImage(AID id)

getAgentImage

public BackEndContainer.AgentImage getAgentImage(AID id)

getAgentImages

public AID[] getAgentImages()

removePendingMessages

public List removePendingMessages(MessageTemplate template,
                                  boolean notifyFailure)

getContainerController

public AgentContainer getContainerController(jade.security.JADEPrincipal principal,
                                             jade.security.Credentials credentials)

initAgent

public void initAgent(AID agentID,
                      Agent instance,
                      jade.security.JADEPrincipal ownerPrincipal,
                      jade.security.Credentials initialCredentials)
               throws NameClashException,
                      IMTPException,
                      NotFoundException,
                      jade.security.JADESecurityException
Issue an INFORM_CREATED vertical command. Note that the Principal, if any, is that of the owner of the newly born agent, while the Credentials, if any, are a set additional initial credentials to be attached to the newly born agent. The SecurityService, if active, will create a new Principal for the newly born agent and will initialize its credentials as the union of the initial credential and the ownership certificate.

Specified by:
initAgent in interface AgentContainer
Throws:
NameClashException
IMTPException
NotFoundException
jade.security.JADESecurityException

getNodeDescriptor

public NodeDescriptor getNodeDescriptor()
Specified by:
getNodeDescriptor in interface AgentContainer

init

protected void init()
             throws IMTPException,
                    ProfileException
Throws:
IMTPException
ProfileException

here

public Location here()
Specified by:
here in interface AgentContainer

handleSend

public void handleSend(ACLMessage msg,
                       AID sender,
                       boolean needClone)
Issue a SEND_MESSAGE VerticalCommand for each receiver


handlePosted

public void handlePosted(AID agentID,
                         ACLMessage msg)

handleReceived

public void handleReceived(AID agentID,
                           ACLMessage msg)
Issue a NOTIFY_RECEIVED VerticalCommand


handleBehaviourAdded

public void handleBehaviourAdded(AID agentID,
                                 Behaviour b)

handleBehaviourRemoved

public void handleBehaviourRemoved(AID agentID,
                                   Behaviour b)

handleChangeBehaviourState

public void handleChangeBehaviourState(AID agentID,
                                       Behaviour b,
                                       java.lang.String from,
                                       java.lang.String to)

handleChangedAgentPrincipal

public void handleChangedAgentPrincipal(AID agentID,
                                        jade.security.JADEPrincipal oldPrincipal,
                                        jade.security.Credentials creds)

handleChangedAgentState

public void handleChangedAgentState(AID agentID,
                                    int oldState,
                                    int newState)

handleEnd

public void handleEnd(AID agentID)

setPlatformAddresses

public void setPlatformAddresses(AID id)

getAMS

public AID getAMS()
Specified by:
getAMS in interface AgentContainer

getDefaultDF

public AID getDefaultDF()
Specified by:
getDefaultDF in interface AgentContainer

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String aDefault)

getBootProperties

public Properties getBootProperties()

getHelper

public ServiceHelper getHelper(Agent a,
                               java.lang.String serviceName)
                        throws ServiceException
Throws:
ServiceException

getPlatformID

public java.lang.String getPlatformID()
Specified by:
getPlatformID in interface AgentContainer

addLocalAgent

public Agent addLocalAgent(AID id,
                           Agent a)
Specified by:
addLocalAgent in interface AgentContainer

powerUpLocalAgent

public void powerUpLocalAgent(AID agentID)
                       throws NotFoundException
Specified by:
powerUpLocalAgent in interface AgentContainer
Throws:
NotFoundException

removeLocalAgent

public void removeLocalAgent(AID id)
Specified by:
removeLocalAgent in interface AgentContainer

isLocalAgent

public boolean isLocalAgent(AID id)
Specified by:
isLocalAgent in interface AgentContainer

fillListFromMessageQueue

public void fillListFromMessageQueue(List messages,
                                     Agent a)
Specified by:
fillListFromMessageQueue in interface AgentContainer

fillListFromReadyBehaviours

public void fillListFromReadyBehaviours(List behaviours,
                                        Agent a)
Specified by:
fillListFromReadyBehaviours in interface AgentContainer

fillListFromBlockedBehaviours

public void fillListFromBlockedBehaviours(List behaviours,
                                          Agent a)
Specified by:
fillListFromBlockedBehaviours in interface AgentContainer

addAddressToLocalAgents

public void addAddressToLocalAgents(java.lang.String address)
Specified by:
addAddressToLocalAgents in interface AgentContainer

removeAddressFromLocalAgents

public void removeAddressFromLocalAgents(java.lang.String address)
Specified by:
removeAddressFromLocalAgents in interface AgentContainer

getID

public ContainerID getID()
Specified by:
getID in interface AgentContainer

getMain

public MainContainer getMain()
Specified by:
getMain in interface AgentContainer

getServiceManager

public ServiceManager getServiceManager()
Specified by:
getServiceManager in interface AgentContainer

getServiceFinder

public ServiceFinder getServiceFinder()
Specified by:
getServiceFinder in interface AgentContainer

startService

protected ServiceDescriptor startService(java.lang.String name,
                                         boolean activateIt)
                                  throws ServiceException
Throws:
ServiceException

stopService

protected void stopService(java.lang.String name)
                    throws ServiceException
Throws:
ServiceException

becomeLeader

public void becomeLeader(AMSEventQueueFeeder feeder)
Specified by:
becomeLeader in interface AgentContainer

addPlatformListener

public void addPlatformListener(AgentManager.Listener l)
                         throws java.lang.ClassCastException
Throws:
java.lang.ClassCastException

removePlatformListener

public void removePlatformListener(AgentManager.Listener l)
                            throws java.lang.ClassCastException
Throws:
java.lang.ClassCastException

isJoined

public boolean isJoined()
Specified by:
isJoined in interface AgentContainer