jade.core.event
Class PlatformEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--jade.util.Event
              |
              +--jade.core.event.JADEEvent
                    |
                    +--jade.core.event.PlatformEvent

public class PlatformEvent
extends JADEEvent
implements PlatformEvent

This class represents an event related to the platform life cycle and configuration.

Version:
$Date: 2002/12/13 13:05:10 $ $Revision: 1.14 $
Author:
Giovanni Rimassa - Universita` di Parma, David I. Bell, Dick Cowan - Hewlett-Packard
See Also:
Serialized Form

Field Summary
static int ADDED_CONTAINER
           
static int CHANGED_AGENT_PRINCIPAL
           
static int CHANGED_CONTAINER_PRINCIPAL
           
static int MOVED_AGENT
           
static int REMOVED_CONTAINER
           
static int RESUMED_AGENT
           
static int SUSPENDED_AGENT
           
 
Fields inherited from class jade.util.Event
type
 
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
PlatformEvent(AID aid, ContainerID eventSource, ContainerID to)
          This constructor is used to create a PlatformEvent when an agent moves from one container to another.
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, jade.security.JADEPrincipal from, jade.security.JADEPrincipal to)
           
PlatformEvent(int id, ContainerID eventSource)
          This constructor is used to create a PlatformEvent when a container is added or deleted.
 
Method Summary
 AID getAgent()
          Returns the AID of the agent that was born, died, or moved.
 java.lang.String getAgentGUID()
           
 ContainerID getContainer()
          Returns the ContainerID of the event source.
 int getEventType()
          Returns the event type which will be one of ADDED_CONTAINER, REMOVED_CONTAINER, BORN_AGENT, DEAD_AGENT, SUSPENDED_AGENT, RESUMED_AGENT, or MOVED_AGENT.
 ContainerID getNewContainer()
          Returns the ContainerID of the container to which an agent moved when the event type is MOVED_AGENT.
 jade.security.JADEPrincipal getNewPrincipal()
           
 jade.security.JADEPrincipal getOldPrincipal()
           
 java.lang.String getPlatformName()
           
 boolean isAgentBD()
          Returns a boolean to indicate if the event type is either BORN_AGENT or DEAD_AGENT.
 boolean isContainerBD()
          Returns a boolean to indicate if the event type is either ADDED_CONTAINER or REMOVED_CONTAINER.
 void setSource(java.lang.Object s)
           
 java.lang.String toString()
          Returns a string representation of this event.
 
Methods inherited from class jade.core.event.JADEEvent
getPlace, getTime
 
Methods inherited from class jade.util.Event
addParameter, getParameter, getType, notifyProcessed, resetProcessed, waitUntilProcessed
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADDED_CONTAINER

public static final int ADDED_CONTAINER

REMOVED_CONTAINER

public static final int REMOVED_CONTAINER

MOVED_AGENT

public static final int MOVED_AGENT

SUSPENDED_AGENT

public static final int SUSPENDED_AGENT

RESUMED_AGENT

public static final int RESUMED_AGENT

CHANGED_AGENT_PRINCIPAL

public static final int CHANGED_AGENT_PRINCIPAL

CHANGED_CONTAINER_PRINCIPAL

public static final int CHANGED_CONTAINER_PRINCIPAL
Constructor Detail

PlatformEvent

public PlatformEvent(int id,
                     ContainerID eventSource)
This constructor is used to create a PlatformEvent when a container is added or deleted. If the id parameter is not either ADDED_CONTAINER or REMOVED_CONTAINER, an InternalError exception will be thrown.

The getContainer() method can be used to get the event source. The getAgent() and getNewContainer() methods will both return null values for a ADDED_CONTAINER or REMOVED_CONTAINER event.

Parameters:
id - The event ID must be either ADDED_CONTAINER or REMOVED_CONTAINER.
eventSource - The container id of the source of the event. The container ID of the main container should always be passed as the event source since only the main container generates a PlatformEvent when a container is added or removed.

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 either BORN_AGENT, DEAD_AGENT, SUSPENDED_AGENT or RESUMED_AGENT, an InternalError exception will be thrown.

The getContainer() method can be used to get the event source. The getNewContainer() method will return null for a BORN_AGENT, DEAD_AGENT, SUSPENDED_AGENT or RESUMED_AGENT event.

Parameters:
id - The event ID must be either BORN_AGENT, DEAD_AGENT, SUSPENDED_AGENT or RESUMED_AGENT.
The - AID of 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(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. The getNewContainer() method will return the container ID of the container to which agent is moved.

Parameters:
The - AID of 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 eventSource,
                     jade.security.JADEPrincipal from,
                     jade.security.JADEPrincipal to)
Method Detail

getContainer

public ContainerID getContainer()
Returns the ContainerID of the event source.

In the case of ADDED_CONTAINER or REMOVED_CONTAINER the 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_AGENT or DEAD_AGENT event, the event source will be the container where the agent was born or died.

In the case a MOVED_AGENT event, the event source is the container from which the agent departed. The container to which the agent moved can be retrieved using the getNewContainer() method.

Returns:
The ContainerID of the event source.
See Also:
getNewContainer()

getNewContainer

public ContainerID getNewContainer()
Returns the ContainerID of the container to which an agent moved when the event type is MOVED_AGENT. For all other event types, this method returns null.

Returns:
The ContainerID of the container to which an agent moved.
See Also:
getContainer()

getAgent

public AID getAgent()
Returns the AID of the agent that was born, died, or moved. If the event type is either ADDED_CONTAINER or REMOVED_CONTAINER, this method returns null since there is no agent involved.

Returns:
The AID of the agent that was born, died, or moved.
See Also:
getContainer()

getOldPrincipal

public jade.security.JADEPrincipal getOldPrincipal()

getNewPrincipal

public jade.security.JADEPrincipal getNewPrincipal()

isContainerBD

public boolean isContainerBD()
Returns a boolean to indicate if the event type is either ADDED_CONTAINER or REMOVED_CONTAINER.

Returns:
True if the event type is either ADDED_CONTAINER or REMOVED_CONTAINER, otherwise, false is returned.

isAgentBD

public boolean isAgentBD()
Returns a boolean to indicate if the event type is either BORN_AGENT or DEAD_AGENT.

Returns:
True if the event type is either BORN_AGENT or DEAD_AGENT, otherwise, false is returned.

getEventType

public int getEventType()
Returns the event type which will be one of ADDED_CONTAINER, REMOVED_CONTAINER, BORN_AGENT, DEAD_AGENT, SUSPENDED_AGENT, RESUMED_AGENT, or MOVED_AGENT.

Specified by:
getEventType in interface PlatformEvent
Returns:
The event type.

setSource

public void setSource(java.lang.Object s)

getPlatformName

public java.lang.String getPlatformName()
Specified by:
getPlatformName in interface PlatformEvent

getAgentGUID

public java.lang.String getAgentGUID()
Specified by:
getAgentGUID in interface PlatformEvent

toString

public java.lang.String toString()
Returns a string representation of this event.

Overrides:
toString in class java.util.EventObject
Returns:
A sring representation of this event.