25.

previous chapter table of contents next chapter
  

Finding Lookup Locators

Both services and clients need to find lookup locators. Services will register with these locators, and clients will query them for suitable services. Finding these lookup locators involves three components :

  • A list of lookup locators for unicast discovery
  • A list of groups for lookup locators using multicast discovery
  • Listeners whose methods are invoked when a service locator is found

Chapter 3 considered the cases of a single unicast lookup service and a set of multicast lookup services. This was all that was available in Jini 1.0. Jini 1.1 has been extended to handle a set of unicast lookup services and a set of multicast lookup services. The Jini 1.1 Helper Utilities document (part of the Jini 1.1 specification) defines three interfaces:

  • DiscoveryManagement , which looks after discovery events
  • DiscoveryGroupManagement , which looks after groups and multicast searches
  • DiscoveryLocatorManagement , which looks after unicast discovery

Different classes may implement different combinations of these three interfaces. The LookupDiscovery class was changed in Jini 1.1 to use DiscoveryGroupManagement and DiscoveryManagement . The LookupDiscovery class performs multicast searches, informing its listeners when lookup services are discovered . The LookupLocatorDiscovery class is new in Jini 1.1 and is discussed later in this chapter. It performs a similar task for unicast discovery and implements the two interfaces DiscoveryLocatorManagement and DiscoveryManagement . Another class discussed later is LookupDiscoveryManager , which handles both unicast and broadcast discovery, and so implements all three interfaces. With these three cases covered, it is unlikely that you will need to implement these interfaces yourself.

The DiscoveryManagement interface is as follows :

 package net.jini.discovery; public interface DiscoveryManagement {     public void addDiscoveryListener(DiscoveryListener l);     public void removeDiscoveryListener(DiscoveryListener l);     public ServiceRegistrar[] getRegistrars();     public void discard(ServiceRegistrar proxy);     public void terminate(); } 

The addDiscoveryListener() method is the most important method, as it allows a listener object to be informed whenever a new lookup service is discovered.

The DiscoveryGroupManagement interface is shown next :

 package net.jini.discovery; public interface DiscoveryGroupManagement {     public static final String[] ALL_GROUPS = null;     public static final String[] NO_GROUPS = new String[0];     public String[] getGroups();     public void addGroups(String[] groups) throws IOException;     public void setGroups(String[] groups) throws IOException;     public void removeGroups(String[] groups); } 

The most important of these methods is setGroups() . If the groups have initially been set to NO_GROUPS , no multicast search is performed. If it is later changed by setGroups() , then this initiates a search. Similarly, addGroups() will also initiate a search. (This is why they may throw remote exceptions.)

The third interface is DiscoveryLocatorManagement:

 package net.jini.discovery; public interface DiscoveryLocatorManagement {     public LookupLocator[] getLocators();     public void addLocators(LookupLocator[] locators);     public void setLocators(LookupLocator[] locators);     public void removeLocators(LookupLocator[] locators); } 

A client or service will generally set the locators in its own constructor, so these methods will probably only be useful if you need to change the set of unicast addresses for the lookup services.

  


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