|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ibm.aglet.event.MobilityAdapter
com.ibm.agletx.util.SeqItinerary
com.ibm.agletx.util.SlaveItinerary
An Itinerary class to repeatedly perform a specific task in multiple
destinations.
Here is a typical usage of this class.
private boolean lastTask = false;
private SlaveItinerary itinerary = null;
class TaskA extends Task {
public void execute(SeqItinerary itin) throws Exception {
// do some work
}
}
class TaskB extends Task {
public void execute(SeqItinerary itin) throws Exception {
// do some work
}
}
public void onCreation(Object ini) {
itinerary = new SlaveItinerary(this,"atp://yariv.trl.ibm.com",new TaskA());
itinerary.addPlace("atp://tai.trl.ibm.com");
itinerary.startTrip();
}
public void run () {
if (itinerary.atLastDestination()==true) {
if (lastTask==true) {
// completed all tasks.
}
else {
lastTask=true;
itinerary.setTask(new TaskB());
itinerary.startTrip();
}
}
}
The above code defines an aglet which performs 2-phase computation: in the
first phase, the aglet travels among multiple destinations to perform a task
defined by TaskA. Then, the second phase is started, in which the aglet visits
again all these destinations to perform a task of TaskB.
In the above code, the invocation of itinerary.startTrip() causes the owner aglet to be dispatched sequentially among the destinations. In every destination, the execute() of the corresponding Task object (assigned to the SlaveItinerary object via setTask()) is automatically invoked.
| Field Summary | |
private Task |
task
|
| Fields inherited from class com.ibm.agletx.util.SeqItinerary |
aglet, currentTarget, serialVersionUID |
| Constructor Summary | |
SlaveItinerary(Aglet aglet,
java.lang.String address,
Task task)
Constructor. |
|
SlaveItinerary(Aglet aglet,
java.util.Vector addresses,
Task task)
Constructor. |
|
| Method Summary | |
void |
addPlan(java.lang.String address)
Add a new address to the itinerary of the owner aglet |
Task |
getTask()
Return the current task to be preformed by the owner aglet |
void |
setTask(Task task)
Set the task to be preformed by the owner aglet |
| Methods inherited from class com.ibm.agletx.util.SeqItinerary |
addAddress, addresses, addTask, atLastDestination, clear, getAddressAt, getCurrentAddress, getCurrentTask, getOrigin, getOwnerAglet, getTaskAt, goToNext, handleException, handleTripException, incIndex, indexOf, indexOf, isRepeat, onArrival, onTermination, removeTaskAt, setRepeat, size, startTrip |
| 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 |
| Field Detail |
private Task task
| Constructor Detail |
public SlaveItinerary(Aglet aglet,
java.lang.String address,
Task task)
aglet - the owner aglettask - the task to preformaddress - an address where the task should be preformed
public SlaveItinerary(Aglet aglet,
java.util.Vector addresses,
Task task)
aglet - the owner aglettask - the task to preformaddresses - a vector of address where the task should be performed.| Method Detail |
public void addPlan(java.lang.String address)
public Task getTask()
public void setTask(Task task)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||