com.ibm.agletx.util
Class AlternateItinerary
java.lang.Object
|
+--com.ibm.aglet.event.MobilityAdapter
|
+--com.ibm.agletx.util.AlternateItinerary
- All Implemented Interfaces:
- java.util.EventListener, MobilityListener, java.io.Serializable
- public class AlternateItinerary
- extends MobilityAdapter
- implements java.io.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:4434");
itinerary.addAlternate("atp://yariv.trl.ibm.com:4434");
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).
- Version:
- 1.20 $Date: 2001/07/28 06:33:38 $
- Author:
- Yariv Aridor
- See Also:
- Serialized Form
Method Summary |
void |
addAlternate(java.lang.String address)
|
void |
go()
Go to one available destination |
void |
go(Message msg)
Go to one available destination where the message is processed |
void |
go(java.lang.String msg)
Go to one available destination where the message is processed |
void |
onArrival(MobilityEvent ev)
This is not normally used by aglets programmers. |
void |
removeAlternate(java.lang.String address)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AlternateItinerary
public AlternateItinerary(Aglet aglet)
addAlternate
public void addAlternate(java.lang.String address)
go
public void go()
throws java.io.IOException
- Go to one available destination
- Throws:
java.io.IOException
- if dispatch failed due to communication problemsAgletException
- if dispatch failed due to aglet specific problems.
go
public void go(Message msg)
throws java.io.IOException
- Go to one available destination where the message is processed
- Parameters:
msg
- the message being sent to the aglet at the destination- Throws:
java.io.IOException
- if dispatch failed due to communication problemsAgletException
- if dispatch failed due to aglet specific problems.
go
public void go(java.lang.String msg)
throws java.io.IOException
- Go to one available destination where the message is processed
- Parameters:
msg
- the message being sent to the aglet at the destination- Throws:
java.io.IOException
- if dispatch failed due to communication problemsAgletException
- if dispatch failed due to aglet specific problems.
onArrival
public void onArrival(MobilityEvent ev)
- This is not normally used by aglets programmers.
- Overrides:
onArrival
in class MobilityAdapter
- Parameters:
ev
- a mobility event
removeAlternate
public void removeAlternate(java.lang.String address)