previous chapter table of contents next chapter


The ServiceRegistration object is created by the lookup service and is returned to run in the service provider. This object acts as a proxy object that will maintain the state information for the service object exported to the lookup service.

Actually, the ServiceRegistration object can be used to make changes to the entire ServiceItem stored on the lookup service. The ServiceRegistration object maintains a serviceID field, which is used to identify the ServiceItem on the lookup service. The serviceID value can be retrieved by getServiceID() for reuse by the server if it needs to do so (which it should, so that it can use as the same identifier for the service across all lookup services). These objects are shown in Figure 5-1.

Figure 5-1: Objects in service registration

Other methods can be used to change the entry attributes stored on the lookup service, such as the following:

 void addAttributes(Entry[] attrSets); void modifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets); void setAttributes(Entry[] attrSets); 

The final public method for the ServiceRegistration class is getLease() , which returns a Lease object that allows renewal or cancellation of the lease. This is discussed in more detail in Chapter 7.

The major task of the server is then over. It will have successfully exported the service to a number of lookup services. What the server then does depends on how long it needs to keep the service alive or registered. If the exported service can do everything that the service needs to do, and does not need to maintain long- term registration, then the server can simply exit. More commonly, if the exported service object acts as a proxy and needs to communicate back to the service, then the server can sleep so that it maintains the existence of the service. If the service needs to be re-registered before timeout occurs, the server can also sleep in this situation.


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

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