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).


Constructor Index

 o AlternateItinerary(Aglet)

Method Index

 o addAlternate(String)
 o go()
Go to one available destination
 o go(Message)
Go to one available destination where the message is processed
 o go(String)
Go to one available destination where the message is processed
 o onArrival(MobilityEvent)
This is not normally used by aglets programmers.
 o removeAlternate(String)

Constructors

 o AlternateItinerary
 public AlternateItinerary(Aglet aglet)

Methods

 o addAlternate
 public void addAlternate(String address)
 o removeAlternate
 public void removeAlternate(String address)
 o 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.
 o 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.
 o 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.
 o 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