Finger is an aglet-based implementation of the more well known "finger" application in Unix. It consists of two aglets, one of them is stationary (Finger) and the other mobile (FingerSlave). The latter is dispatched by Finger to a remote location where it will retrieve local user information. Having gathered the information, FingerSlave returns to Finger and delivers the information.
To be written.
Run at least two aglet servers in your network (read here how to run an aglet server).
Use the "new aglet" panel of Tahiti to create your Finger aglet by specifying its class name: "ibm.aglets.samples.Finger"(read Tahiti User's Guide for more information about aglet creation). When Finger is created, its dialog window is displayed:
atp://aglets.trl.ibm.com
or, if your aglet server is running on a port other than the default one (434):
atp://aglets.trl.ibm.com:500
In order to update the AddressBook, click once to display its panel. Then, either select an address and remove it (via the delete button) or add the current address in the "Address" field (via the add button). Click on the close button to hide the AddressBook panel.
The following type of information will be received and displayed in the center of the dialog window (see an example in the dialog window shown above).
Read here about troubleshooting for the sample aglets.
This program is composed of the following classes:
The Finger class inherits the SampleAglet abstract class for a stationary aglet (see a description of the SampleAglet abstract class here). Its go method creates the slave aglet.
private static final String SlaveClassName = "ibm.aglets.samples.FingerSlave"; protected void go(URL url) { super.go(url); try { Slave.create(null, SlaveClassName, getAgletContext(), this, new SeqItinerary(url), new String()); } catch (IOException ae) { ..... } }
The slave is given an itinerary of a single destination (the url parameter). The Finger aglet is considered its master (specified by the this parameter to the Slave.create method).
The Finger aglet, as a master, receives the slave's result (handled by the callback method) and error messages which are sent by the slave whenever its fails to perform its task (handled by the inError method).
protected synchronized void callback(Object arg) { setTheMessage("Finished"); if (arg != null) _msw.setResult( ((FingerInfo)arg).toTextBlock()); }
The callback method is overwritten to receive the result (a FingerInfo object), convert it to a text string (via the toTextBlock method), and display it in the result panel of the interaction window (via the setResult method).
The FingerSlave class implements the abstract methods of the Slave class. These are initializeJob() and doJob().
protected synchronized void doJob() throws AgletException { RESULT = getLocalInfo(); } private Object getLocalInfo() throws AgletException { AgletContext ac = getAgletContext(); String hostname; // compute hostname FingerInfo info = new FingerInfo (hostname, (String)ac.getProperty("aglets.tahiti.user.name", "Unknown"), (String)ac.getProperty("aglets.tahiti.user.organization", "Unknown"), (String)ac.getProperty("aglets.tahiti.user.email", "Unknown"), (String)ac.getProperty("aglets.tahiti.registered", "Unknown"), (new Date()) ); return info; }
In doJob(), the slave retrieves the local user information (via the properties of the local aglet server), organizes the information into a FingerInfo object, and assigns it to the result instance variable of a slave object (which is finally transfered to the master).
You can study the Finger aglet in more detail by directly traversing the source code: