|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--SmiTest
MobiliTools $Name: $, $Id: SmiTest.java,v 1.1.1.1 2003/03/28 14:47:58 dillense Exp $
This example class shows MobileObject lifecycle through a console-based user interaction, as well as resource loading.
The easiest way to use this example is to use GUI-enabled agencies.
Note that this agent has no autonomous activity.
Field Summary | |
(package private) Agency |
my_agency
reference to current host agency, set after each move - must be transient because non-serializable |
(package private) java.lang.String |
my_name
display-friendly name, set once for all at creation |
(package private) boolean |
running
true if the agent is currently active, false if it is suspended |
Constructor Summary | |
SmiTest()
Default constructor is invoked when no argument is provided for agent creation. |
|
SmiTest(java.lang.Object arg)
(Generic) Example of specific constructor. |
Method Summary | |
void |
afterBirth(AgentSystem agency,
AgentInfo entry,
java.lang.Object argument)
Displays a message and plays a sound on agent creation. |
void |
afterMove(AgentSystem agency,
Location location,
java.lang.String place)
Plays a sound and asks installation confirmation after deserialization in the target agency. |
void |
afterMoveFailed(Location location,
java.lang.String place,
int reason,
java.lang.String message)
Plays a sound and displays a message in the source agency after the agent has been serialized but its installation in the target agency has failed (probably rejected by the agent itself) |
void |
beforeDeath()
Displays a message on termination |
void |
beforeMove(Location location,
java.lang.String place)
Asks confirmation before moving. |
void |
beforeResume()
Displays an acknowledgement message on agent activity resumption if and only if it was suspended, otherwise the resume-caller gets an exception. |
void |
beforeShutdown()
Displays a message on host agency shutdown |
void |
beforeSuspend()
Displays an acknowledgement message on agent activity suspension if and only if it was active, otherwise the suspend-caller gets an exception. |
(package private) boolean |
confirm(java.lang.String message,
boolean defaultYes)
Displays a message and reads a confirmation ('y' or 'n' whatever upper or lower case) in the attached console/terminal |
(package private) void |
playSound(java.lang.String resourcename)
Loads a sound designated by the provided resource name using the agent's class classloader and plays it. |
Methods inherited from class java.lang.Object |
|
Field Detail |
java.lang.String my_name
boolean running
transient Agency my_agency
Constructor Detail |
public SmiTest()
public SmiTest(java.lang.Object arg)
Method Detail |
public void afterBirth(AgentSystem agency, AgentInfo entry, java.lang.Object argument) throws BadOperation
afterBirth
in interface MobileObject
public void beforeMove(Location location, java.lang.String place) throws BadOperation
beforeMove
in interface MobileObject
public void afterMove(AgentSystem agency, Location location, java.lang.String place) throws BadOperation
afterMoveFailed()
on the agent in source agency.afterMove
in interface MobileObject
public void afterMoveFailed(Location location, java.lang.String place, int reason, java.lang.String message)
afterMoveFailed
in interface MobileObject
public void beforeShutdown()
beforeShutdown
in interface MobileObject
public void beforeDeath()
beforeDeath
in interface MobileObject
public void beforeResume() throws BadOperation
beforeResume
in interface MobileObject
public void beforeSuspend() throws BadOperation
beforeSuspend
in interface MobileObject
boolean confirm(java.lang.String message, boolean defaultYes)
message
- confirmation question to be displayeddefaultYes
- default answer (i.e. when neither 'y' nor 'n' is entered)void playSound(java.lang.String resourcename)
resourcename
- the name of the resource (should be an audio file)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |