Class PlatformEvent
- java.lang.Object
-
- java.util.EventObject
-
- jade.util.Event
-
- jade.core.event.JADEEvent
-
- jade.core.event.PlatformEvent
-
- All Implemented Interfaces:
PlatformEvent,Serializable
public class PlatformEvent extends JADEEvent implements PlatformEvent
This class represents an event related to the platform life cycle and configuration.- Version:
- $Date$ $Revision$
- Author:
- Giovanni Rimassa - Universita` di Parma, David I. Bell, Dick Cowan - Hewlett-Packard
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intADDED_CONTAINERstatic intCHANGED_AGENT_PRINCIPALstatic intCHANGED_CONTAINER_PRINCIPALstatic intFROZEN_AGENTstatic intMOVED_AGENTstatic intREMOVED_CONTAINERstatic intRESUMED_AGENTstatic intSUSPENDED_AGENTstatic intTHAWED_AGENT-
Fields inherited from class java.util.EventObject
source
-
Fields inherited from interface jade.wrapper.PlatformEvent
BORN_AGENT, DEAD_AGENT, KILLED_PLATFORM, RESUMED_PLATFORM, STARTED_PLATFORM, SUSPENDED_PLATFORM
-
-
Constructor Summary
Constructors Constructor Description PlatformEvent(int id, AID aid, ContainerID eventSource)This constructor is used to create a PlatformEvent when an agent is born or dies.PlatformEvent(int id, AID aid, ContainerID eventSource, boolean cr)PlatformEvent(int id, AID aid, ContainerID from, ContainerID to)PlatformEvent(int id, AID aid, ContainerID eventSource, String oldOwnership, String newOwnership)PlatformEvent(int id, ContainerID eventSource)This constructor is used to create a PlatformEvent when a container is added, deleted, or requested to be killed.PlatformEvent(AID aid, ContainerID eventSource, ContainerID to)This constructor is used to create a PlatformEvent when an agent moves from one container to another.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AIDgetAgent()Returns theAIDof the agent that was born, died, or moved.StringgetAgentGUID()Retrieve the global agent name (i.e.ContainerIDgetContainer()Returns theContainerIDof the event source.booleangetContainerRemoved()intgetEventType()Returns the event type which will be one ofADDED_CONTAINER,REMOVED_CONTAINER,BORN_AGENT,DEAD_AGENT,SUSPENDED_AGENT,RESUMED_AGENT, orMOVED_AGENT.ContainerIDgetNewContainer()Returns theContainerIDof the container to which an agent moved when the event type isMOVED_AGENT.StringgetNewOwnership()StringgetOldOwnership()StringgetPlatformName()Retrieve the platform name.booleanisAgentBD()Returns a boolean to indicate if the event type is eitherBORN_AGENTorDEAD_AGENT.booleanisContainerBD()Returns a boolean to indicate if the event type is eitherADDED_CONTAINERorREMOVED_CONTAINER.voidsetSource(Object s)StringtoString()Returns a string representation of this event.-
Methods inherited from class jade.util.Event
addParameter, getParameter, getType, notifyProcessed, reset, resetProcessed, waitUntilProcessed, waitUntilProcessed
-
Methods inherited from class java.util.EventObject
getSource
-
-
-
-
Field Detail
-
ADDED_CONTAINER
public static final int ADDED_CONTAINER
- See Also:
- Constant Field Values
-
REMOVED_CONTAINER
public static final int REMOVED_CONTAINER
- See Also:
- Constant Field Values
-
MOVED_AGENT
public static final int MOVED_AGENT
- See Also:
- Constant Field Values
-
SUSPENDED_AGENT
public static final int SUSPENDED_AGENT
- See Also:
- Constant Field Values
-
RESUMED_AGENT
public static final int RESUMED_AGENT
- See Also:
- Constant Field Values
-
CHANGED_AGENT_PRINCIPAL
public static final int CHANGED_AGENT_PRINCIPAL
- See Also:
- Constant Field Values
-
CHANGED_CONTAINER_PRINCIPAL
public static final int CHANGED_CONTAINER_PRINCIPAL
- See Also:
- Constant Field Values
-
FROZEN_AGENT
public static final int FROZEN_AGENT
- See Also:
- Constant Field Values
-
THAWED_AGENT
public static final int THAWED_AGENT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlatformEvent
public PlatformEvent(int id, ContainerID eventSource)This constructor is used to create a PlatformEvent when a container is added, deleted, or requested to be killed. If the id parameter is not eitherADDED_CONTAINERorREMOVED_CONTAINER, anInternalErrorexception will be thrown.The
getContainer()method can be used to get the target container. ThegetAgent()andgetNewContainer()methods will both return null.- Parameters:
id- The event ID must be eitherADDED_CONTAINERorREMOVED_CONTAINER.eventSource- The container id of the source of the event.- See Also:
getContainer()
-
PlatformEvent
public PlatformEvent(int id, AID aid, ContainerID eventSource)This constructor is used to create a PlatformEvent when an agent is born or dies. If the id parameter is not eitherBORN_AGENT,DEAD_AGENT,SUSPENDED_AGENTorRESUMED_AGENT, anInternalErrorexception will be thrown.The
getContainer()method can be used to get the event source. ThegetNewContainer()method will return null for aBORN_AGENT,DEAD_AGENT,SUSPENDED_AGENTorRESUMED_AGENTevent.- Parameters:
id- The event ID must be eitherBORN_AGENT,DEAD_AGENT,SUSPENDED_AGENTorRESUMED_AGENT.The-AIDof the new or dead agent.eventSource- The container id of the source of the event. The container ID of the container where the agent was born or died should be passed, even though the main container is the object that will acutally generate the event.- See Also:
getContainer(),getAgent()
-
PlatformEvent
public PlatformEvent(int id, AID aid, ContainerID eventSource, boolean cr)
-
PlatformEvent
public PlatformEvent(AID aid, ContainerID eventSource, ContainerID to)
This constructor is used to create a PlatformEvent when an agent moves from one container to another.The event source is the container from which the agent departed. The
getContainer()method can be used to get the event source. ThegetNewContainer()method will return the container ID of the container to which agent is moved.- Parameters:
The-AIDof the moved agent.eventSource- The container id from which the agent departed.to- The container id of the container to which the agent moved.- See Also:
getContainer(),getNewContainer(),getAgent()
-
PlatformEvent
public PlatformEvent(int id, AID aid, ContainerID from, ContainerID to)
-
PlatformEvent
public PlatformEvent(int id, AID aid, ContainerID eventSource, String oldOwnership, String newOwnership)
-
-
Method Detail
-
getContainer
public ContainerID getContainer()
Returns theContainerIDof the event source.In the case of
ADDED_CONTAINERorREMOVED_CONTAINERthe event source will always be the main container since the addition or deletion of a container is essentially an action in the main container.In the case of the a
BORN_AGENTorDEAD_AGENTevent, the event source will be the container where the agent was born or died.In the case a
MOVED_AGENTevent, the event source is the container from which the agent departed. The container to which the agent moved can be retrieved using thegetNewContainer()method.- Returns:
- The
ContainerIDof the event source. - See Also:
getNewContainer()
-
getNewContainer
public ContainerID getNewContainer()
Returns theContainerIDof the container to which an agent moved when the event type isMOVED_AGENT. For all other event types, this method returns null.- Returns:
- The
ContainerIDof the container to which an agent moved. - See Also:
getContainer()
-
getAgent
public AID getAgent()
Returns theAIDof the agent that was born, died, or moved. If the event type is eitherADDED_CONTAINERorREMOVED_CONTAINER, this method returns null since there is no agent involved.- Returns:
- The
AIDof the agent that was born, died, or moved. - See Also:
getContainer()
-
getOldOwnership
public String getOldOwnership()
-
getNewOwnership
public String getNewOwnership()
-
getContainerRemoved
public boolean getContainerRemoved()
-
isContainerBD
public boolean isContainerBD()
Returns a boolean to indicate if the event type is eitherADDED_CONTAINERorREMOVED_CONTAINER.- Returns:
- True if the event type is either
ADDED_CONTAINERorREMOVED_CONTAINER, otherwise, false is returned.
-
isAgentBD
public boolean isAgentBD()
Returns a boolean to indicate if the event type is eitherBORN_AGENTorDEAD_AGENT.- Returns:
- True if the event type is either
BORN_AGENTorDEAD_AGENT, otherwise, false is returned.
-
getEventType
public int getEventType()
Returns the event type which will be one ofADDED_CONTAINER,REMOVED_CONTAINER,BORN_AGENT,DEAD_AGENT,SUSPENDED_AGENT,RESUMED_AGENT, orMOVED_AGENT.- Specified by:
getEventTypein interfacePlatformEvent- Returns:
- The event type.
-
setSource
public void setSource(Object s)
-
getPlatformName
public String getPlatformName()
Description copied from interface:PlatformEventRetrieve the platform name.- Specified by:
getPlatformNamein interfacePlatformEvent- Returns:
- The name of the platform this event refers to.
-
getAgentGUID
public String getAgentGUID()
Description copied from interface:PlatformEventRetrieve the global agent name (i.e. the local name and the platform ID).- Specified by:
getAgentGUIDin interfacePlatformEvent- Returns:
- The global name of the agent this event refers to.
-
toString
public String toString()
Returns a string representation of this event.- Overrides:
toStringin classEventObject- Returns:
- A sring representation of this event.
-
-