A goal of any well-behaved service is to advertise the facilities and functions it provides by requesting residency within at least one lookup service. Making such a request of a lookup service is known as registering with, or
joining, a lookup service. To demonstrate this good behavior, a service must comply with both the multicast discovery protocol and the unicast discovery protocol in order to discover the lookup services it is interested in joining. The service must also comply with the join protocol to register with the desired lookup services.
In order for a service to maintain its residency in the lookup services it has joined, the service must provide for the coordination, systematic renewal, and overall management of all leases on that residency. In addition to handling all discovery and join duties, as well as managing all leases on lookup service residency, the service must also provide for the coordination and management of any attribute sets with which it may have registered with the lookup services in which it resides.
This class performs all of the functions related to discovery, joining, service lease renewal, and attribute management which is required of a well-behaved service. Each of these activities is intimately involved with the maintenance of a service's residency in one or more lookup services (the service's join state), thus the name JoinManager
.
This class should be employed by services, not clients. The use of this class in a wide variety of services can help minimize the work resulting from having to repeatedly implement this required functionality in each service. Note that this class is not remote. Services that wish to use this class will create an instance of this class in the service's address space to manage the entity's join state locally.
@com.sun.jini.impl The following implementation-specific items are discussed below:
Configuring JoinManager
This implementation of
JoinManager
supports the following configuration entries; where each configuration entry name is associated with the component name
net.jini.lookup.JoinManager
. Note that the configuration entries specified here are specific to this implementation of
JoinManager
. Unless otherwise stated, each entry is retrieved from the configuration only once per instance of this utility, where each such retrieval is performed in the constructor.
• | discoveryManager |
  | Type: | {@link net.jini.discovery.DiscoveryManagement} |
  | Default: | new {@link net.jini.discovery.LookupDiscoveryManager#LookupDiscoveryManager(java.lang.String[],net.jini.core.discovery.LookupLocator[],net.jini.discovery.DiscoveryListener,net.jini.config.Configuration) LookupDiscoveryManager}( new java.lang.String[] {""}, new {@link net.jini.core.discovery.LookupLocator}[0], null, config) |
  | Description: | The object used to manage the discovery processing performed by this utility. This entry will be retrieved from the configuration only if no discovery manager is specified in the constructor. Note that this object should not be shared with other components in the application that employs this utility. |
• | leaseManager |
  | Type: | {@link net.jini.lease.LeaseRenewalManager} |
  | Default: | new {@link net.jini.lease.LeaseRenewalManager#LeaseRenewalManager(net.jini.config.Configuration) LeaseRenewalManager}(config) |
  | Description: | The object used to manage each service lease returned to this utility when the service is registered with the the various discovered lookup services. This entry will be retrieved from the configuration only if no lease renewal manager is specified in the constructor. |
• | maxLeaseDuration |
  | Type: | long |
  | Default: | Lease.FOREVER |
  | Description: | The maximum lease duration (in milliseconds) that is requested from each discovered lookup service on behalf of the service; both when the lease is initially requested, as well as when renewal of that lease is requested. Note that as this value is made smaller, renewal requests will be made more frequently while the service is up, and lease expiration will occur sooner when the service goes down. |
• | registrarPreparer |
  | Type: | {@link net.jini.security.ProxyPreparer} |
  | Default: | new {@link net.jini.security.BasicProxyPreparer}() |
  | Description: | Preparer for the proxies to the lookup services that are discovered and used by this utility. The following methods of the proxy returned by this preparer are invoked by this utility: - {@link net.jini.core.lookup.ServiceRegistrar#register register}
|
• | registrationPreparer |
  | Type: | {@link net.jini.security.ProxyPreparer} |
  | Default: | new {@link net.jini.security.BasicProxyPreparer}() |
  | Description: | Preparer for the proxies to the registrations returned to this utility upon registering the service with each discovered lookup service. The following methods of the proxy returned by this preparer are invoked by this utility: - {@link net.jini.core.lookup.ServiceRegistration#getServiceID getServiceID}
- {@link net.jini.core.lookup.ServiceRegistration#getLease getLease}
- {@link net.jini.core.lookup.ServiceRegistration#addAttributes addAttributes}
- {@link net.jini.core.lookup.ServiceRegistration#modifyAttributes modifyAttributes}
- {@link net.jini.core.lookup.ServiceRegistration#setAttributes setAttributes}
|
• | serviceLeasePreparer |
  | Type: | {@link net.jini.security.ProxyPreparer} |
  | Default: | new {@link net.jini.security.BasicProxyPreparer}() |
  | Description: | Preparer for the leases returned to this utility through the registrations with each discovered lookup service with which this utility has registered the service. Currently, none of the methods on the service lease returned by this preparer are invoked by this implementation of the utility. |
• | taskManager |
  | Type: | {@link com.sun.jini.thread.TaskManager} |
  | Default: | new {@link com.sun.jini.thread.TaskManager#TaskManager() TaskManager}(15, (15*1000), 1.0f) |
  | Description: | The object that pools and manages the various threads executed by this utility. The default manager creates a maximum of 15 threads, waits 15 seconds before removing idle threads, and uses a load factor of 1.0 when determining whether to create a new thread. This object should not be shared with other components in the application that employs this utility. |
• | wakeupManager |
  | Type: | {@link com.sun.jini.thread.WakeupManager} |
  | Default: | new {@link com.sun.jini.thread.WakeupManager#WakeupManager(com.sun.jini.thread.WakeupManager.ThreadDesc) WakeupManager}(new {@link com.sun.jini.thread.WakeupManager.ThreadDesc}(null,true)) |
  | Description: | Object that pools and manages the various tasks that are initially executed by the object corresponding to the taskManager entry of this component, but which fail during that initial execution. This object schedules the re-execution of such a failed task - in the taskManager object - at various times in the future, until either the task succeeds or the task has been executed the maximum number of allowable times, corresponding to the wakeupRetries entry of this component. This object should not be shared with other components in the application that employs this utility. |
• | wakeupRetries |
  | Type: | int |
  | Default: | 6 |
  | Description: | The maximum number of times a failed task is allowed to be executed by the object corresponding to the wakeupManager entry of this component. |
Logging
This implementation of
JoinManager
uses the {@link Logger} named
net.jini.lookup.JoinManager
to log information at the following logging levels:
net.jini.lookup.JoinManager
Level | Description |
{@link java.util.logging.Level#INFO INFO} | when a task is stopped because of a definite exception |
{@link java.util.logging.Level#INFO INFO} | when a task is stopped because it has exceeded the maximum number of times the task is allowed to be tried/re-tried |
{@link java.util.logging.Level#INFO INFO} | when any exception occurs while attempting to prepare a proxy |
{@link java.util.logging.Level#FINER FINER} | when any exception (other than the more serious exceptions logged at higher levels) occurs in a task |
{@link java.util.logging.Level#FINEST FINEST} | when an IllegalStateException occurs upon attempting to discard a lookup service |
{@link java.util.logging.Level#FINEST FINEST} | whenever any task is started |
{@link java.util.logging.Level#FINEST FINEST} | whenever any task completes successfully |
{@link java.util.logging.Level#FINEST FINEST} | whenever a proxy is prepared |
@author Sun Microsystems, Inc.
@see net.jini.discovery.DiscoveryManagement
@see net.jini.lease.LeaseRenewalManager
@see java.util.logging.Level
@see java.util.logging.Logger