org.objectweb.mobilitools.smi.api
Interface AgencyPersonality

All Known Implementing Classes:
Agency

public interface AgencyPersonality

MobiliTools $Name: $, $Id: AgencyPersonality.java,v 1.1.1.1 2003/03/28 14:48:06 dillense Exp $

Interface that must be implemented by an agency personality to give hooks to SMI generic Agency. Most of this interface consists in intercepting MobileObject life cycle.

See Also:
Agency, MobileObject

Method Summary
 void afterBirth(MobileObject agent, AgentSystem agency, AgentInfo entry, java.lang.Object arguments)
          Called on agent creation.
 void afterMove(MobileObject agent, AgentSystem agency, Location location, java.lang.String place)
          Called on reinstalling in the target agency after a move.
 void afterMoveFailed(MobileObject agent, Location agency, java.lang.String place, int reason, java.lang.String message)
          Called on move failure. (note that throwing an exception in beforeMove() does not result in afterMoveFailed() being called)
 void agencyShutdown()
          Called before agency shutdown (once all agents have been warned and terminated).
 void beforeDeath(MobileObject agent)
          Called before discarding the agent. (note that an exception in afterBirth() does not result in beforeDeath() being called)
 void beforeMove(MobileObject agent, Location location, java.lang.String place)
          Called before before moving.
 void beforeResume(MobileObject agent)
          Called to resume the agent activity (if any).
 void beforeShutdown(MobileObject agent)
          Called before the agent's hosting agency shutdown.
 void beforeSuspend(MobileObject agent)
          Called to suspend the agent activity (if any).
 

Method Detail

afterBirth

public void afterBirth(MobileObject agent,
                       AgentSystem agency,
                       AgentInfo entry,
                       java.lang.Object arguments)
                throws BadOperation
Called on agent creation.
Parameters:
agent - target agent.
agency - reference to the hosting agency.
entry - a structure of information about the newly created agent.
arguments - arguments for agent initialization.
Throws:
BadOperation - shall be thrown if the agent refuses to settle. Identifier BadOperation.REJECTED must be set for this exception. Note that the agent creation is canceled, and that beforeDeath() is not called.

beforeMove

public void beforeMove(MobileObject agent,
                       Location location,
                       java.lang.String place)
                throws BadOperation
Called before before moving.
Parameters:
agent - target agent
location - location of destination agency
place - name of target place
Throws:
BadOperation - thrown to reject the move. Identifier BadOperation.REJECTED must be set for this exception. The agent move is simply canceled and the thrown exception is re-thrown by moveAgent() (note that afterMoveFailed() is not called).

afterMove

public void afterMove(MobileObject agent,
                      AgentSystem agency,
                      Location location,
                      java.lang.String place)
               throws BadOperation
Called on reinstalling in the target agency after a move.
Parameters:
agent - target agent
agency - reference to the new hosting agency
location - location of new hosting agency
place - the name of the new residing place
Throws:
BadOperation - thrown if the agent can not be correctly reinstalled in the new agency. Identifier BadOperation.REJECTED must be set for this exception. The agent stays in the source agency, afterMoveFailed() is invoked, and moveAgent() throws an exception.

afterMoveFailed

public void afterMoveFailed(MobileObject agent,
                            Location agency,
                            java.lang.String place,
                            int reason,
                            java.lang.String message)
Called on move failure. (note that throwing an exception in beforeMove() does not result in afterMoveFailed() being called)
Parameters:
agent - target agent
agency - location of the target agency
place - the target place name
reason - problem identifier
message - textual explanation

beforeDeath

public void beforeDeath(MobileObject agent)
Called before discarding the agent. (note that an exception in afterBirth() does not result in beforeDeath() being called)
Parameters:
agent - target agent

beforeSuspend

public void beforeSuspend(MobileObject agent)
                   throws BadOperation
Called to suspend the agent activity (if any).
Parameters:
agent - target agent
Throws:
BadOperation - the agent activity was already suspended, or could not be suspended. Identifier BadOperation.REJECTED must be set for this exception. SMI core detects whether the agent is already suspended or not, and throws the corresponding exception if necessary, without invoking this callback.

beforeResume

public void beforeResume(MobileObject agent)
                  throws BadOperation
Called to resume the agent activity (if any).
Parameters:
agent - target agent
Throws:
BadOperation - the agent activity was already running, or could not be resumed. Identifier BadOperation.REJECTED must be set for this exception. SMI core detects whether the agent is already running or not, and throws the corresponding exception if necessary, without invoking this callback.

beforeShutdown

public void beforeShutdown(MobileObject agent)
Called before the agent's hosting agency shutdown. If the agent is still residing in the shutting agency after this callback, it is terminated and callback beforeDeath() is invoked (an agent can't survive the shutdown of its hosting agency).
Parameters:
agent - target agent

agencyShutdown

public void agencyShutdown()
Called before agency shutdown (once all agents have been warned and terminated).