Package jade.core
Class BackEndContainer
- java.lang.Object
-
- jade.core.BackEndContainer
-
- All Implemented Interfaces:
AgentContainer,BackEnd
public class BackEndContainer extends Object implements BackEnd
- Author:
- Giovanni Caire - TILAB, Jerome Picault - Motorola Labs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBackEndContainer.AgentImageInner class AgentImage
-
Field Summary
Fields Modifier and Type Field Description static StringENABLE_MONITORprotected jade.core.LADTlocalAgentsstatic StringMONITOR_AGENT_CLASSstatic StringMONITOR_AGENT_NAMEprotected jade.core.CommandProcessormyCommandProcessorprotected ContainerIDmyIDprotected IMTPManagermyIMTPManagerprotected MainContainerImplmyMainContainerprotected NodeDescriptormyNodeDescriptorprotected ProfilemyProfileprotected CredentialsownerCredentialsprotected JADEPrincipalownerPrincipalstatic StringRESYNCHstatic StringUSE_BACKEND_MANAGERstatic StringVERBOSE_SHUTDOWNProfile option that specifies whether or not all log messages should be produced during the shutdown procedure-
Fields inherited from interface jade.core.AgentContainer
AUX_CONTAINER_NAME, MAIN_CONTAINER_NAME
-
-
Constructor Summary
Constructors Constructor Description BackEndContainer(Properties props, BEConnectionManager cm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AgentacquireLocalAgent(AID id)voidaddAddressToLocalAgents(String address)BackEndContainer.AgentImageaddAgentImage(AID id, BackEndContainer.AgentImage img)AgentaddLocalAgent(AID id, Agent a)voidaddPlatformListener(AgentManager.Listener l)AID[]agentNames()voidbecomeLeader(AMSEventQueueFeeder feeder)StringbornAgent(String name)A new agent has just started on the FrontEnd.booleanconnect()BackEndContainer.AgentImagecreateAgentImage(AID id)voidcreateAgentOnFE(String name, String className, String[] args)voiddeadAgent(String name)An agent has just died on the FrontEnd.voiddisableDebugger(AID debuggerName, AID notToBeDebugged)This method is re-defined to avoid NullPointerException.voidenableDebugger(AID debuggerName, AID toBeDebugged)This method is re-defined to avoid NullPointerException.voidfillListFromBlockedBehaviours(List behaviours, Agent a)voidfillListFromMessageQueue(List messages, Agent a)voidfillListFromReadyBehaviours(List behaviours, Agent a)BackEndContainer.AgentImagegetAgentImage(AID id)AID[]getAgentImages()AIDgetAMS()PropertiesgetBootProperties()AgentContainergetContainerController(JADEPrincipal principal, Credentials credentials)AIDgetDefaultDF()ServiceHelpergetHelper(Agent a, String serviceName)ContainerIDgetID()MainContainergetMain()NodeDescriptorgetNodeDescriptor()StringgetPlatformID()StringgetProperty(String key, String aDefault)ServiceFindergetServiceFinder()ServiceManagergetServiceManager()voidhandleBehaviourAdded(AID agentID, Behaviour b)voidhandleBehaviourRemoved(AID agentID, Behaviour b)voidhandleChangeBehaviourState(AID agentID, Behaviour b, String from, String to)voidhandleChangedAgentPrincipal(AID agentID, JADEPrincipal oldPrincipal, Credentials creds)voidhandleChangedAgentState(AID agentID, int oldState, int newState)voidhandleEnd(AID agentID)voidhandlePosted(AID agentID, ACLMessage msg)voidhandleReceived(AID agentID, ACLMessage msg)Issue a NOTIFY_RECEIVED VerticalCommandvoidhandleSend(ACLMessage msg, AID sender, boolean needClone)Issue a SEND_MESSAGE VerticalCommand for each receiverLocationhere()protected voidinit()voidinitAgent(AID agentID, Agent instance, JADEPrincipal ownerPrincipal, Credentials initialCredentials)Issue an INFORM_CREATED vertical command.booleanisJoined()booleanisLocalAgent(AID id)voidkillAgentOnFE(String name)voidmessageOut(ACLMessage msg, String sender)An agent on the FrontEnd has sent a message.booleanpostMessagesBlockToLocalAgent(ACLMessage[] mm, AID receiverID)booleanpostMessageToLocalAgent(ACLMessage msg, AID receiverID)Dispatch a message to an agent in the FrontEnd.voidpowerUpLocalAgent(AID agentID)voidreleaseLocalAgent(AID id)voidremoveAddressFromLocalAgents(String address)BackEndContainer.AgentImageremoveAgentImage(AID id)voidremoveLocalAgent(AID id)ListremovePendingMessages(MessageTemplate template, boolean notifyFailure)voidremovePlatformListener(AgentManager.Listener l)voidresumeAgentOnFE(String name)voidresumedAgent(String name)Notify the BackEnd container that an agent has resumed.ObjectserviceInvokation(String actor, String serviceName, String methodName, Object[] methodParams)Pass a service helper method invocation request to the BackEndvoidsetPlatformAddresses(AID id)voidshutDown()protected voidstartNode()Add the node to the platform with the basic servicesprotected ServiceDescriptorstartService(String name, boolean activateIt)protected voidstopService(String name)voidsuspendAgentOnFE(String name)voidsuspendedAgent(String name)Notify the BackEnd container that an agent has suspended.
-
-
-
Field Detail
-
USE_BACKEND_MANAGER
public static final String USE_BACKEND_MANAGER
- See Also:
- Constant Field Values
-
RESYNCH
public static final String RESYNCH
- See Also:
- Constant Field Values
-
VERBOSE_SHUTDOWN
public static final String VERBOSE_SHUTDOWN
Profile option that specifies whether or not all log messages should be produced during the shutdown procedure- See Also:
- Constant Field Values
-
ENABLE_MONITOR
public static final String ENABLE_MONITOR
- See Also:
- Constant Field Values
-
MONITOR_AGENT_NAME
public static final String MONITOR_AGENT_NAME
- See Also:
- Constant Field Values
-
MONITOR_AGENT_CLASS
public static final 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 JADEPrincipal ownerPrincipal
-
ownerCredentials
protected 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, JADESecurityException, NotFoundExceptionAdd the node to the platform with the basic services
-
bornAgent
public String bornAgent(String name) throws 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:
bornAgentin interfaceBackEnd- Parameters:
name- The name of the new agent.- Returns:
- the actual name of the agent
- Throws:
JADESecurityExceptionIMTPException
-
deadAgent
public void deadAgent(String name) throws IMTPException
An agent has just died on the FrontEnd. Remove its image and notify the Main- Specified by:
deadAgentin interfaceBackEnd- Parameters:
name- The name of the dead agent.- Throws:
IMTPException
-
suspendedAgent
public void suspendedAgent(String name) throws NotFoundException, IMTPException
Description copied from interface:BackEndNotify the BackEnd container that an agent has suspended.- Specified by:
suspendedAgentin interfaceBackEnd- Parameters:
name- The name of the suspended agent.- Throws:
NotFoundExceptionIMTPException
-
resumedAgent
public void resumedAgent(String name) throws NotFoundException, IMTPException
Description copied from interface:BackEndNotify the BackEnd container that an agent has resumed.- Specified by:
resumedAgentin interfaceBackEnd- Parameters:
name- The name of the resumed agent.- Throws:
NotFoundExceptionIMTPException
-
messageOut
public void messageOut(ACLMessage msg, 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:
messageOutin interfaceBackEnd- Parameters:
msg- The message to be dispatched.sender- The name of the sender agent.- Throws:
NotFoundExceptionIMTPException
-
serviceInvokation
public Object serviceInvokation(String actor, String serviceName, String methodName, Object[] methodParams) throws NotFoundException, ServiceException, IMTPException
Description copied from interface:BackEndPass a service helper method invocation request to the BackEnd- Specified by:
serviceInvokationin interfaceBackEnd- Parameters:
actor- The name of the agent that invoked the methodserviceName- The name of the servicemethodName- The name of the invoked methodmethodParams- The parameters of the invoked methods as an array of Objects- Returns:
- the result of the invoked method or
nullif the method returnsvoid - Throws:
NotFoundExceptionServiceExceptionIMTPException
-
createAgentOnFE
public void createAgentOnFE(String name, String className, String[] args) throws IMTPException
- Throws:
IMTPException
-
killAgentOnFE
public void killAgentOnFE(String name) throws IMTPException, NotFoundException
- Throws:
IMTPExceptionNotFoundException
-
suspendAgentOnFE
public void suspendAgentOnFE(String name) throws IMTPException, NotFoundException
- Throws:
IMTPExceptionNotFoundException
-
resumeAgentOnFE
public void resumeAgentOnFE(String name) throws IMTPException, NotFoundException
- Throws:
IMTPExceptionNotFoundException
-
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:
postMessageToLocalAgentin interfaceAgentContainer
-
postMessagesBlockToLocalAgent
public boolean postMessagesBlockToLocalAgent(ACLMessage[] mm, AID receiverID)
- Specified by:
postMessagesBlockToLocalAgentin interfaceAgentContainer
-
acquireLocalAgent
public Agent acquireLocalAgent(AID id)
- Specified by:
acquireLocalAgentin interfaceAgentContainer
-
releaseLocalAgent
public void releaseLocalAgent(AID id)
- Specified by:
releaseLocalAgentin interfaceAgentContainer
-
agentNames
public AID[] agentNames()
- Specified by:
agentNamesin interfaceAgentContainer
-
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:
shutDownin interfaceAgentContainer
-
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(JADEPrincipal principal, Credentials credentials)
-
initAgent
public void initAgent(AID agentID, Agent instance, JADEPrincipal ownerPrincipal, Credentials initialCredentials) throws NameClashException, IMTPException, NotFoundException, 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:
initAgentin interfaceAgentContainer- Throws:
NameClashExceptionIMTPExceptionNotFoundExceptionJADESecurityException
-
getNodeDescriptor
public NodeDescriptor getNodeDescriptor()
- Specified by:
getNodeDescriptorin interfaceAgentContainer
-
init
protected void init() throws IMTPException, ProfileException- Throws:
IMTPExceptionProfileException
-
here
public Location here()
- Specified by:
herein interfaceAgentContainer
-
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
-
handleChangeBehaviourState
public void handleChangeBehaviourState(AID agentID, Behaviour b, String from, String to)
-
handleChangedAgentPrincipal
public void handleChangedAgentPrincipal(AID agentID, JADEPrincipal oldPrincipal, 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:
getAMSin interfaceAgentContainer
-
getDefaultDF
public AID getDefaultDF()
- Specified by:
getDefaultDFin interfaceAgentContainer
-
getBootProperties
public Properties getBootProperties()
-
getHelper
public ServiceHelper getHelper(Agent a, String serviceName) throws ServiceException
- Throws:
ServiceException
-
getPlatformID
public String getPlatformID()
- Specified by:
getPlatformIDin interfaceAgentContainer
-
addLocalAgent
public Agent addLocalAgent(AID id, Agent a)
- Specified by:
addLocalAgentin interfaceAgentContainer
-
powerUpLocalAgent
public void powerUpLocalAgent(AID agentID) throws NotFoundException
- Specified by:
powerUpLocalAgentin interfaceAgentContainer- Throws:
NotFoundException
-
removeLocalAgent
public void removeLocalAgent(AID id)
- Specified by:
removeLocalAgentin interfaceAgentContainer
-
isLocalAgent
public boolean isLocalAgent(AID id)
- Specified by:
isLocalAgentin interfaceAgentContainer
-
fillListFromMessageQueue
public void fillListFromMessageQueue(List messages, Agent a)
- Specified by:
fillListFromMessageQueuein interfaceAgentContainer
-
fillListFromReadyBehaviours
public void fillListFromReadyBehaviours(List behaviours, Agent a)
- Specified by:
fillListFromReadyBehavioursin interfaceAgentContainer
-
fillListFromBlockedBehaviours
public void fillListFromBlockedBehaviours(List behaviours, Agent a)
- Specified by:
fillListFromBlockedBehavioursin interfaceAgentContainer
-
addAddressToLocalAgents
public void addAddressToLocalAgents(String address)
- Specified by:
addAddressToLocalAgentsin interfaceAgentContainer
-
removeAddressFromLocalAgents
public void removeAddressFromLocalAgents(String address)
- Specified by:
removeAddressFromLocalAgentsin interfaceAgentContainer
-
getID
public ContainerID getID()
- Specified by:
getIDin interfaceAgentContainer
-
getMain
public MainContainer getMain()
- Specified by:
getMainin interfaceAgentContainer
-
getServiceManager
public ServiceManager getServiceManager()
- Specified by:
getServiceManagerin interfaceAgentContainer
-
getServiceFinder
public ServiceFinder getServiceFinder()
- Specified by:
getServiceFinderin interfaceAgentContainer
-
startService
protected ServiceDescriptor startService(String name, boolean activateIt) throws ServiceException
- Throws:
ServiceException
-
stopService
protected void stopService(String name) throws ServiceException
- Throws:
ServiceException
-
becomeLeader
public void becomeLeader(AMSEventQueueFeeder feeder)
- Specified by:
becomeLeaderin interfaceAgentContainer
-
addPlatformListener
public void addPlatformListener(AgentManager.Listener l) throws ClassCastException
- Throws:
ClassCastException
-
removePlatformListener
public void removePlatformListener(AgentManager.Listener l) throws ClassCastException
- Throws:
ClassCastException
-
isJoined
public boolean isJoined()
- Specified by:
isJoinedin interfaceAgentContainer
-
-