org.objectweb.mobilitools.smi.api
Interface MobileObject

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
BasicMobileObject

public interface MobileObject
extends java.io.Serializable

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

This interface must be implemented by any agent class in order to be managed by the SMI framework.


Method Summary
 void afterBirth(AgentSystem agency, AgentInfo entry, java.lang.Object arguments)
          Called on agent creation.
 void afterMove(AgentSystem agency, Location location, java.lang.String place)
          Called on reinstalling in the target agency after a move.
 void afterMoveFailed(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 beforeDeath()
          Called before discarding the agent. (note that an exception in afterBirth() does not result in beforeDeath() being called)
 void beforeMove(Location location, java.lang.String place)
          Called before before moving.
 void beforeResume()
          Called to resume the agent activity (if any).
 void beforeShutdown()
          Called before the agent's hosting agency shutdown.
 void beforeSuspend()
          Called to suspend the agent activity (if any).
 

Method Detail

afterBirth

public void afterBirth(AgentSystem agency,
                       AgentInfo entry,
                       java.lang.Object arguments)
                throws BadOperation
Called on agent creation.
Parameters:
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(Location location,
                       java.lang.String place)
                throws BadOperation
Called before before moving.
Parameters:
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(AgentSystem agency,
                      Location location,
                      java.lang.String place)
               throws BadOperation
Called on reinstalling in the target agency after a move.
Parameters:
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(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:
agency - location of the target agency
place - the target place name
reason - problem identifier
message - textual explanation

beforeDeath

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

beforeSuspend

public void beforeSuspend()
                   throws BadOperation
Called to suspend the agent activity (if any).
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()
                  throws BadOperation
Called to resume the agent activity (if any).
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()
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).