All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.agletx.util.AlternateItinerary
java.lang.Object
|
+----com.ibm.aglet.event.MobilityAdapter
|
+----com.ibm.agletx.util.AlternateItinerary
- public class AlternateItinerary
- extends MobilityAdapter
- implements Serializable
An itinerary class to dispatch an aglet to any one of multiple destination.
The following is a typical usage of this case.
AlternateItinerary itinerary= null;
public boolean handleMessage(Message msg) {
if (msg.sameKind("test")) {
System.out.println("arrived!!!");
return true;
}
return false;
}
public void onCreation(Object ini) {
itinerary = new AlternateItinerary(this);
itinerary.addAlternate("atp://tsdsai.trl.ibm.com:434");
itinerary.addAlternate("atp://yariv.trl.ibm.com:434");
try {
itinerary.go("test");
} catch (SecurityException ex) { // a RuntimeException
// failed to the aglet specific problems.
} catch (IOException ex) {
// failed due to communication problems.
}
}
In the above code, the go() tries to dispatch the owner aglet
to one of the alternative destinations specified by the addAlternate().
If succeeds, it sends Message("test") to the owner aglet upon its
arrival to that destination.
If multiple destinations are available to host the owner aglet, the selection is implementation-dependant.
If fails, it throws an IOException exception (in case of communication
problems) or SecurityException (otherwise).
-
AlternateItinerary(Aglet)
-
-
addAlternate(String)
-
-
go()
- Go to one available destination
-
go(Message)
- Go to one available destination where the message is processed
-
go(String)
- Go to one available destination where the message is processed
-
onArrival(MobilityEvent)
- This is not normally used by aglets programmers.
-
removeAlternate(String)
-
AlternateItinerary
public AlternateItinerary(Aglet aglet)
addAlternate
public void addAlternate(String address)
removeAlternate
public void removeAlternate(String address)
go
public void go(Message msg) throws IOException
- Go to one available destination where the message is processed
- Parameters:
- msg - the message being sent to the aglet at the destination
- Throws: IOException
- if dispatch failed due to communication problems
- Throws: AgletException
- if dispatch failed due to aglet specific problems.
go
public void go(String msg) throws IOException
- Go to one available destination where the message is processed
- Parameters:
- msg - the message being sent to the aglet at the destination
- Throws: IOException
- if dispatch failed due to communication problems
- Throws: AgletException
- if dispatch failed due to aglet specific problems.
go
public void go() throws IOException
- Go to one available destination
- Throws: IOException
- if dispatch failed due to communication problems
- Throws: AgletException
- if dispatch failed due to aglet specific problems.
onArrival
public void onArrival(MobilityEvent ev)
- This is not normally used by aglets programmers.
- Parameters:
- ev - a mobility event
- Overrides:
- onArrival in class MobilityAdapter
All Packages Class Hierarchy This Package Previous Next Index