All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.agletx.util.SimpleItinerary

java.lang.Object
   |
   +----com.ibm.aglet.event.MobilityAdapter
           |
           +----com.ibm.agletx.util.SimpleItinerary

public class SimpleItinerary
extends MobilityAdapter
implements Externalizable
SimpleItinerary class is an itinerary object which can specify a destination and a message which will be sent to the owner aglet when it arrived at the destination.
   SimpleItinerary itinerary;
   public void onCreation(Object init) {
   	itinerary = new SimpleItinerary(this);
      itinerary.go("atp://first", "job1");
   }
   public boolean handleMessage(Message msg) {
       if (msg.sameKind("job1")) {
           // job at the first place
           itinerary.go("atp://second", "job2");
       } else if (msg.sameKind("job2")) {
           // job at the second place
           itinerary.go("atp://third", "job3");
       } else if (msg.sameKind("job3")) {
           // job at the third place
           dispose();
       } else return false;
return true;
   }
 
In above case, what the call itinerary.go("atp://second", "job2") does is
dispatches the owner aglet (specified in the argument of constructor) to "atp://second" .
sends new Message("job2") message to the owner aglet when arrived at the destination In this way, an aglet can specify both a destination to go and a message to be handled at the destination.


Constructor Index

 o SimpleItinerary()
For Manual Serialization
 o SimpleItinerary(Aglet)
Constructs a SimpleItinerary with the specified owner aglet.

Method Index

 o go(String, Message)
Goes to the destination given by name and the message processed at the destination.
 o go(String, String)
Goes to the destination given by name and the message processed at the destination.
 o onArrival(MobilityEvent)
This is not normally used by aglets programmers.
 o readExternal(ObjectInput)
 o writeExternal(ObjectOutput)

Constructors

 o SimpleItinerary
 public SimpleItinerary(Aglet aglet)
Constructs a SimpleItinerary with the specified owner aglet.

Parameters:
aglet - the owner of this itinerary.
 o SimpleItinerary
 public SimpleItinerary()
For Manual Serialization

Methods

 o go
 public void go(String address,
                Message msg) throws IOException, AgletException
Goes to the destination given by name and the message processed at the destination.

Parameters:
address - the address of the destination
msg - the message being sent to the aglet at the destination
Throws: IOException
if dispatch completely failed
Throws: AgletException
if dispatch completely failed
 o go
 public void go(String address,
                String msg) throws IOException, AgletException
Goes to the destination given by name and the message processed at the destination.

Parameters:
address - the address of the destination
msg - the message being sent to the aglet at the destination
Throws: IOException
if dispatch completely failed
Throws: AgletException
if dispatch completely failed
 o onArrival
 public void onArrival(MobilityEvent ev)
This is not normally used by aglets programmers.

Parameters:
ev - a mobility event
Overrides:
onArrival in class MobilityAdapter
 o writeExternal
 public void writeExternal(ObjectOutput oo) throws IOException
 o readExternal
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

All Packages  Class Hierarchy  This Package  Previous  Next  Index