All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----com.ibm.aglet.event.MobilityAdapter | +----com.ibm.agletx.util.SeqItinerary | +----com.ibm.agletx.util.SlaveItinerary
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.
public SlaveItinerary(Aglet aglet, String address, Task task)
public SlaveItinerary(Aglet aglet, Vector addresses, Task task)
public void addPlan(String address)
public Task getTask()
public void setTask(Task task)
All Packages Class Hierarchy This Package Previous Next Index