Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.agletx.util
Class SlaveItinerary

    java.lang.Object
      |
      +--com.ibm.aglet.event.MobilityAdapter
            |
            +--com.ibm.agletx.util.SeqItinerary
                  |
                  +--com.ibm.agletx.util.SlaveItinerary

All Implemented Interfaces:
  java.util.EventListener, MobilityListener, java.io.Serializable

public class SlaveItinerary
extends SeqItinerary

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.

Version:
  1.20 $Date: 2001/07/28 06:33:35 $
Author:
  Yariv Aridor
See Also:
  Serialized Form

Fields inherited from class com.ibm.agletx.util.SeqItinerary
`aglet, currentTarget`

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, 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`

Constructor Detail

### SlaveItinerary

    public SlaveItinerary(Aglet aglet,
                          java.lang.String address,
                          Task task)

  Constructor.
  Parameters:
    `aglet` - the owner aglet
    `task` - the task to preform
    `address` - an address where the task should be preformed

### SlaveItinerary

    public SlaveItinerary(Aglet aglet,
                          java.util.Vector addresses,
                          Task task)

  Constructor.
  Parameters:
    `aglet` - the owner aglet
    `task` - the task to preform
    `addresses` - a vector of address where the task should be performed.

Method Detail

### addPlan

    public void addPlan(java.lang.String address)

  Add a new address to the itinerary of the owner aglet

### getTask

    public Task getTask()

  Return the current task to be preformed by the owner aglet

### setTask

    public void setTask(Task task)

  Set the task to be preformed by the owner aglet

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD