Aglets Workbench

To Aglets Workbench Home pageThe Finger Application

Description

How to run Finger

Troubleshooting

Program Description

This program is composed of the following classes:

The Finger Class

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

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

Source Code

You can study the Finger aglet in more detail by directly traversing the source code:


IBM home page | IBM Japan home page | Copyright | Trademark
Last modified: Fri December 27 12:00:00 JST 1996