170.

previous chapter table of contents next chapter
  

ServiceItem

The service provider will create a ServiceItem object by using the constructor, shown here:

 package net.jini.core.lookup; public Class ServiceItem {     public ServiceID serviceID;     public java.lang.Object service;     public Entry[] attributeSets;     public ServiceItem(ServiceID serviceID,                    java.lang.Object service,                    Entry[] attrSets); } 

Once the service provider has created the ServiceItem object, it is passed into register() . The first parameter, serviceID , is set to null when the service is registered for the first time. The lookup service will set a non-null value as it registers the service. On subsequent registrations or re-registrations, this non-null value should be used. The serviceID is used as a globally unique identifier for the service.

The second parameter, service , is the service object that is being registered. This object will be serialized and sent to the service locator for storage. When a client later requests a service, this is the object it will be given. There are several things to note about the service object:

  • The object must be serializable. Some objects, such as the graphical user interface JTextArea object are not serializable at present and so cannot be used.
  • The object is created in the service's JVM. However, when it runs, it will do so in the client's JVM, so it may need to be a proxy for the actual service. For example, the object may be able to show a set of toaster controls, but might have to send messages across the network to the real toaster service, which is connected to the physical toaster.
  • If the service object is an RMI proxy, then the object in the ServiceItem is given by the programmer as the UnicastRemoteObject for the proxy stub, not the proxy itself. The Java runtime substitutes the proxy. This subtlety is explored in Chapter 6.

The third parameter in the ServiceItem constructor, attrSets , is a set of entries giving information about the service in addition to the service object/service proxy itself. If there is no additional information, this can be null .

  


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