Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

THIS WEBPAGE IS DEPRECATED - please visit our new website

Up to DwarfMiddlewareTutorial, forward to DwarfMiddlewareTutorialLesson5, back to DwarfMiddlewareTutorialLesson3

Lesson 4: Attributes for abilities, predicates for needs

In this lesson, you will learn how to perform a finer-grained selection of abilities to fulfill a given need.

Reconfigure the time client and server

Use the installed binaries TimeService and TimeClient of lesson 2, and start up the service manager.

Run make all in (top build directory)/src/tutorials/middleware/lesson4. This will install two new service descriptions:

TimeService TimeClient
<service name="TimeService">
   <ability name="giveTime" type="TimeOfDay">
      <attribute name="accuracy" value="low"/>
      <connector protocol="ObjrefExporter"/>
<service name="TimeClient">
   <need name="time" type="TimeOfDay"
      <connector protocol="ObjrefImporter"/>

An ability may have attributes, specified by name-value pairs. Here, the TimeOfDay ability has the attribute accuracy with a value of low.

Likewise, a need may have a predicate, specified as a boolean expression in LDAP notation. This basically means prefixing operators and a lot of parentheses, e.g. (|(a=1)(!(b=2))). Note that the ampersand, the and operator, must be escaped as & in XML.

Try it out

In one terminal, run TimeClient. In another, run TimeService. Nothing will happen. In DIVE, you will see two services that are not connected:

Non-matching Time Service and Time Client

When you inspect the TimeOfDay need and ability in DIVE, you will see the attribute values and predicate. Note that many attributes are built-in and set by the service manager. Also note that a service itself may have attributes, which are inherited by the ability. Even a need may have attributes, but these are not used for selection of the communication partner.

Now modify TimeService.xml so that the accuracy attribute is high. The service manager will re-read the XML file, but still nothing will happen. In fact, the service manager has disconnected the running TimeService from its service description, since the XML file has changed. Restart the TimeService and the two services will be connected:

Connected Time Service and Time Client

Exercise 4.1 Add another attribute to the TimeService, and try out a matching and a non-matching boolean expression for the TimeClient.

Exercise 4.2 Make the TimeService have three different abilities of type TimeOfDay, differing in their name, each with a different value of accuracy. Create a boolean expression for the TimeClient so that it will connect only to the third of these needs, creating this image in DIVE:

Time Service with three abilities

Exercise 4.3 Predicates may contain wildcards, e.g. fo*ba* matches foobar and foambath. Try this out.

Exercise 4.4 Work with another user on a second machine. Each run a service manager, DIVE, a Time Service and a Time Client. Turn on the "show host name" option in DIVE. By default, each Time Client will connect to the Time Server on its own machine. Reverse this using attributes, creating this image in DIVE:

Time Service on two hosts

The SvcSelection interface

A service may implement the SvcSelection interface, as defined in Service.idl:

   interface SvcSelection {
      void foundPartners(in ActiveServiceDescription serviceDesc,
         in string needabilityname, in PartnerSeq partners);

The service manager calls this for a service that has a need, order to let the service choose its partner on its own. Normally, you have no need to do this; boolean expressions and wildcards will suffice.

Exercise 4.5 Write a NewTimeService that implements the SvcSelection interface and selects partners that have a number attribute which is prime.

Up to DwarfMiddlewareTutorial, forward to DwarfMiddlewareTutorialLesson5, back to DwarfMiddlewareTutorialLesson3

-- AsaMacWilliams - 17 Jul 2003

Edit | Attach | Refresh | Diffs | More | Revision r1.7 - 17 Mar 2005 - 21:10 - NikolasDoerfler

Lehrstuhl für Computer Aided Medical Procedures & Augmented Reality    rss.gif