com.ibm.agletx.util
Class SimpleItinerary

java.lang.Object
  |
  +--com.ibm.aglet.event.MobilityAdapter
        |
        +--com.ibm.agletx.util.SimpleItinerary
All Implemented Interfaces:
java.util.EventListener, java.io.Externalizable, MobilityListener, java.io.Serializable

public class SimpleItinerary
extends MobilityAdapter
implements java.io.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.

Version:
1.00 $Date: 2001/07/28 06:33:39 $
Author:
Mitsuru Oshima
See Also:
Serialized Form

Constructor Summary
SimpleItinerary()
          For Manual Serialization
SimpleItinerary(Aglet aglet)
          Constructs a SimpleItinerary with the specified owner aglet.
 
Method Summary
 void go(java.lang.String address, Message msg)
          Goes to the destination given by name and the message processed at the destination.
 void go(java.lang.String address, java.lang.String msg)
          Goes to the destination given by name and the message processed at the destination.
 void onArrival(MobilityEvent ev)
          This is not normally used by aglets programmers.
 void readExternal(java.io.ObjectInput in)
           
 void writeExternal(java.io.ObjectOutput oo)
           
 
Methods inherited from class com.ibm.aglet.event.MobilityAdapter
onDispatching, onReverting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleItinerary

public SimpleItinerary()
For Manual Serialization

SimpleItinerary

public SimpleItinerary(Aglet aglet)
Constructs a SimpleItinerary with the specified owner aglet.
Parameters:
aglet - the owner of this itinerary.
Method Detail

go

public void go(java.lang.String address,
               Message msg)
        throws java.io.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:
java.io.IOException - if dispatch completely failed
AgletException - if dispatch completely failed

go

public void go(java.lang.String address,
               java.lang.String msg)
        throws java.io.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:
java.io.IOException - if dispatch completely failed
AgletException - if dispatch completely failed

onArrival

public void onArrival(MobilityEvent ev)
This is not normally used by aglets programmers.
Overrides:
onArrival in class MobilityAdapter
Parameters:
ev - a mobility event

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput oo)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable