com.sun.jini.lookup
Class JoinManager

java.lang.Object
  |
  +--com.sun.jini.lookup.JoinManager

public class JoinManager
extends java.lang.Object

This class manages the join protocol for a service. It discovers and keeps track of which lookup services to join, registers with them, keeps the registration leases renewed, and keeps the attributes up to date.


Constructor Summary
JoinManager(java.lang.Object obj, Entry[] attrSets, ServiceIDListener callback, LeaseRenewalManager leaseMgr)
          Use this constructor when the service does not yet have a service ID, and has not been specially pre-configured with respect to joins.
JoinManager(java.lang.Object obj, Entry[] attrSets, java.lang.String[] groups, LookupLocator[] locators, ServiceIDListener callback, LeaseRenewalManager leaseMgr)
          Use this constructor when the service does not have a service ID, but has been specially pre-configured with respect to joins.
JoinManager(ServiceID serviceID, java.lang.Object obj, Entry[] attrSets, java.lang.String[] groups, LookupLocator[] locators, LeaseRenewalManager leaseMgr)
          Use this constructor when the service already has a service ID.
 
Method Summary
 void addAttributes(Entry[] attrSets)
          Add attribute sets for the service.
 void addAttributes(Entry[] attrSets, boolean checkSC)
          Add attribute sets for the service.
 void addGroups(java.lang.String[] groups)
          Add new groups to to the set to join.
 void addLocators(LookupLocator[] locators)
          Add new locators for specific lookup services to join.
 Entry[] getAttributes()
          Get the current attribute sets.
 java.lang.String[] getGroups()
          Get the list of groups to join.
 ServiceRegistrar[] getJoinSet()
          Get the list of lookup services that have currently been joined.
 LookupLocator[] getLocators()
          Get the list of locators of specific lookup services to join.
 void modifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets)
          Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes.
 void modifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets, boolean checkSC)
          Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes.
 void removeGroups(java.lang.String[] groups)
          Remove groups from the set to join.
 void removeLocators(LookupLocator[] locators)
          Remove locators for specific lookup services from the set to join.
 void setAttributes(Entry[] attrSets)
          Set the complete attribute sets for the service.
 void setGroups(java.lang.String[] groups)
          Replace the list of groups to join with a new list.
 void setLocators(LookupLocator[] locators)
          Replace the list of locators of specific lookup services to join with a new list.
 void terminate()
          Cancel leases at all joined lookup services.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoinManager

public JoinManager(java.lang.Object obj,
                   Entry[] attrSets,
                   ServiceIDListener callback,
                   LeaseRenewalManager leaseMgr)
            throws java.io.IOException
Use this constructor when the service does not yet have a service ID, and has not been specially pre-configured with respect to joins. Initially there are no specific lookup services to join, and groups is set to {""}.
Parameters:
obj - the service object
attrSets - the attribute sets for the service
callback - gets passed the assigned service ID so that the service can make it persistent.
See Also:
ServiceIDListener

JoinManager

public JoinManager(java.lang.Object obj,
                   Entry[] attrSets,
                   java.lang.String[] groups,
                   LookupLocator[] locators,
                   ServiceIDListener callback,
                   LeaseRenewalManager leaseMgr)
            throws java.io.IOException
Use this constructor when the service does not have a service ID, but has been specially pre-configured with respect to joins.
Parameters:
obj - the service object
attrSets - the attribute sets for the service
groups - groups to join. Null (or empty) means join no groups, not join all groups.
locators - locators of specific lookup services to join
callback - gets called with the assigned service ID so that the service can make it persistent
See Also:
ServiceIDListener

JoinManager

public JoinManager(ServiceID serviceID,
                   java.lang.Object obj,
                   Entry[] attrSets,
                   java.lang.String[] groups,
                   LookupLocator[] locators,
                   LeaseRenewalManager leaseMgr)
            throws java.io.IOException
Use this constructor when the service already has a service ID.
Parameters:
serviceID - the service ID (must not be null)
obj - the service object
attrSets - the attribute sets for the service
groups - groups to join. Null (or empty) means join no groups, not join all groups.
locators - locators of specific lookup services to join
Method Detail

getJoinSet

public ServiceRegistrar[] getJoinSet()
Get the list of lookup services that have currently been joined. A new array is returned each time.

getLocators

public LookupLocator[] getLocators()
Get the list of locators of specific lookup services to join. A new array is returned each time.

addLocators

public void addLocators(LookupLocator[] locators)
Add new locators for specific lookup services to join.
Parameters:
locators - locators of specific lookup services to join

removeLocators

public void removeLocators(LookupLocator[] locators)
Remove locators for specific lookup services from the set to join. Any leases held at the lookup services are cancelled.
Parameters:
locators - locators of specific lookup services to leave

setLocators

public void setLocators(LookupLocator[] locators)
Replace the list of locators of specific lookup services to join with a new list. Leases are cancelled at lookup services that were in the old list but are not in the new list.
Parameters:
locators - locators of specific lookup services to join

getGroups

public java.lang.String[] getGroups()
Get the list of groups to join. A new array is returned each time.

addGroups

public void addGroups(java.lang.String[] groups)
               throws java.io.IOException
Add new groups to to the set to join.
Parameters:
groups - groups to join
Throws:
java.io.IOException - if cannot create the MulticastSocket

removeGroups

public void removeGroups(java.lang.String[] groups)
                  throws java.io.IOException
Remove groups from the set to join. Leases are cancelled at lookup services that are not members of any of the remaining groups.
Parameters:
groups - groups to leave

setGroups

public void setGroups(java.lang.String[] groups)
               throws java.io.IOException
Replace the list of groups to join with a new list. Leases are cancelled at lookup services that are not members of any of the new groups.
Parameters:
groups - groups to join
Throws:
java.io.IOException - if cannot create the MulticastSocket

getAttributes

public Entry[] getAttributes()
Get the current attribute sets. A new array is returned each time.

addAttributes

public void addAttributes(Entry[] attrSets)
Add attribute sets for the service. The resulting set will be used for all future joins. The attribute sets are also added at all currently joined lookup services.
Parameters:
attrSets - the attribute sets to add

modifyAttributes

public void modifyAttributes(Entry[] attrSetTemplates,
                             Entry[] attrSets)
Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes. The resulting set will be used for all future joins. The same modifications are also made at all currently joined lookup services.
Parameters:
attrSetTemplates - the templates for matching attribute sets
attrSets - the modifications to make to matching sets
See Also:
ServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])

setAttributes

public void setAttributes(Entry[] attrSets)
Set the complete attribute sets for the service. The new sets will be used for all future joins. The attribute sets at all currently joined lookup services are replaced with the new sets.
Parameters:
attrSets - the attribute sets for the service

addAttributes

public void addAttributes(Entry[] attrSets,
                          boolean checkSC)
Add attribute sets for the service. The resulting set will be used for all future joins. The attribute sets are also added at all currently joined lookup services. If checkSC is true, then throw a SecurityException if any elements of attrSets are instanceof ServiceControlled.
Parameters:
attrSets - the attribute sets to add
checkSC - check for instanceof ServiceControlled if true

modifyAttributes

public void modifyAttributes(Entry[] attrSetTemplates,
                             Entry[] attrSets,
                             boolean checkSC)
Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes. The resulting set will be used for all future joins. The same modifications are also made at all currently joined lookup services. If checkSC is true, then throw a SecurityException if any attribute sets that would be deleted or modified are instanceof ServiceControlled.
Parameters:
attrSetTemplates - the templates for matching attribute sets
attrSets - the modifications to make to matching sets
checkSC - check for instanceof ServiceControlled if true
See Also:
ServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])

terminate

public void terminate()
Cancel leases at all joined lookup services. Terminate all threads within the JoinManager class. The semantics of subsequent operations on this JoinManager are undefined.


Copyright © 1999 Sun Microsystems, Inc. All rights reserved