115.

previous chapter table of contents next chapter
  

Service Registration

A service is a logical concept and can be anything, such as a blender , a chat service, a disk. A service is usually defined by a Java interface, and this interface is used to advertise the service. This interface is also used to locate a service. Each service can be implemented in many ways, by many different vendors . For example, there may be Joe's dating service, Mary's dating service, and many others. What makes them the same service is that they implement the same interface; what distinguishes one from another is that each different implementation uses a different set of objects (or maybe just one object) belonging to different classes.

A service is created by a service provider, and a service provider plays a number of roles:

  • It creates the objects that implement the service.
  • It registers one of these ”the service object ”with lookup services. The service object is the publicly visible part of the service, and it will be downloaded to clients .
  • It stays alive in a server role, performing various tasks such as keeping the service " alive ."

In order for the service provider to register the service object with a lookup service, the server must first find the lookup service. This can be done in two ways. If the location of the lookup service is known, then the service provider can use unicast TCP to connect directly to it. If the location is not known, the service provider will make UDP multicast requests, and lookup services may respond to these requests. Lookup services will be listening on port 4160 for both the unicast and multicast requests . (4160 is the decimal representation of hexadecimal (CAFE-BABE). Oh well, these numbers have to come from somewhere.) This process is illustrated in Figure 1-2.

click to expand
Figure 1-2: Querying for a service locator

When the lookup service gets a request on this port, it sends an object back to the server, as shown in Figure 1-3. This object, known as a registrar, acts as a proxy to the lookup service and runs in the service's JVM. Any requests that the service provider needs to make of the lookup service are made through this proxy registrar. Any suitable protocol may be used to do this, but in practice the implementations of the lookup service that you get (such as those from Sun) will probably use RMI.

click to expand
Figure 1-3: Registrar returned

What the service provider does with the registrar is register the service with the lookup service. This involves taking a copy of the service object and storing it on the lookup service, as shown in Figure 1-4.

click to expand
Figure 1-4: Service uploaded
  


A Programmer[ap]s Guide to Jini Technology
A Programmer[ap]s Guide to Jini Technology
ISBN: 1893115801
EAN: N/A
Year: 2000
Pages: 189

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net