class FiddlerRegistration extends Object implements LookupDiscoveryRegistration, ReferentUuid, Serializable
When a client requests a registration with a lookup discovery service, an instance of this class is returned. This class is used by the client as a proxy to the registration object created by the lookup discovery service for the client. The remote methods of this class each have a counterpart on the back-end server of the Fiddler implementation of the lookup discovery service. The client can use the methods implemented in this class to manage the parameters of its registration with the lookup discovery service.
LookupDiscoveryRegistration
Modifier and Type | Class and Description |
---|---|
(package private) static class |
FiddlerRegistration.ConstrainableFiddlerRegistration
The constrainable version of
FiddlerRegistration . |
Modifier and Type | Field and Description |
---|---|
(package private) EventRegistration |
eventReg
The object which encapsulates the information used by the client
to identify a notification sent by the lookup discovery service
to the listener registered with the lookup discovery service by
the client's registration, for which the instance of this class
serves as proxy.
|
(package private) Uuid |
registrationID
The unique identifier assigned to the current instance of this
registration proxy class by the lookup discovery service.
|
private static long |
serialVersionUID |
(package private) Fiddler |
server
The reference through which communication occurs between the
client-side and the server-side of the lookup discovery service
|
Modifier | Constructor and Description |
---|---|
private |
FiddlerRegistration(Fiddler server,
Uuid registrationID,
EventRegistration eventReg)
Constructs a new instance of FiddlerRegistration.
|
Modifier and Type | Method and Description |
---|---|
void |
addGroups(String[] groups)
Adds a set of group names to the managed set of groups associated
with the registration corresponding to the current instance of
this class.
|
void |
addLocators(LookupLocator[] locators)
Adds a set of LookupLocator objects to the managed set of locators
associated with the registration corresponding to the current
instance of this class.
|
static FiddlerRegistration |
createRegistration(Fiddler server,
Uuid registrationID,
EventRegistration eventReg)
Public static factory method that creates and returns an instance of
FiddlerRegistration . |
void |
discard(ServiceRegistrar registrar)
Informs the lookup discovery service of the existence of an
unavailable lookup service and requests that the lookup discovery
service discard the unavailable lookup service.
|
boolean |
equals(Object obj)
For any instance of this class, indicates whether the object input
to this method is equal to the current instance of this class; where
equality of proxies to a registration with a lookup discovery service
is defined by reference equality.
|
EventRegistration |
getEventRegistration()
Returns an EventRegistration object that encapsulates the information
needed by the client to identify a notification sent by the lookup
discovery service to the registration's listener.
|
String[] |
getGroups()
Returns an array consisting of the names of the groups whose members
are lookup services the lookup discovery service will attempt to
discover for the registration corresponding to the current instance
of this class.
|
Lease |
getLease()
Returns the Lease object that controls a client's registration with
the lookup discovery service.
|
LookupLocator[] |
getLocators()
Returns an array consisting of the the LookupLocator objects
corresponding to specific lookup services the lookup discovery
service will attempt to discover for for the registration
corresponding to the current instance of this class.
|
Uuid |
getReferentUuid()
Returns the universally unique identifier that has been assigned to the
resource this proxy represents.
|
ServiceRegistrar[] |
getRegistrars()
Returns an array consisting of instances of the ServiceRegistrar
interface.
|
int |
hashCode()
For any instance of this class, returns the hashcode value generated
by the hashCode method of the registration ID associated with the
current instance of this proxy.
|
private static int |
indexFirstNull(Object[] arr)
Finds the index of the first element in the input array that contains
null.
|
private static void |
insertRegistrars(ServiceRegistrar[] regsArray,
ArrayList regsList)
Places the the lookup service reference(s), contained in the input
ArrayList, into the 'empty' slots occurring at the end (indicated
by the first null element) of the input array.
|
private void |
readObject(ObjectInputStream s)
When an instance of this class is deserialized, this method is
automatically invoked.
|
private void |
readObjectNoData()
During deserialization of an instance of this class, if it is found
that the stream contains no data, this method is automatically
invoked.
|
void |
removeGroups(String[] groups)
Deletes a set of group names from the managed set of groups
associated with the registration corresponding to the current
instance of this class.
|
void |
removeLocators(LookupLocator[] locators)
Deletes a set of LookupLocator objects from the managed set of
locators associated with the registration corresponding to the
current instance of this class.
|
void |
setGroups(String[] groups)
Replaces all of the group names in the managed set of groups
associated with the registration corresponding to the current
instance of this class.
|
void |
setLocators(LookupLocator[] locators)
Replaces with a new set of LookupLocator objects, all of the
elements in the managed set of locators associated with the
registration corresponding to the current instance of this class.
|
private static ArrayList |
unmarshalRegistrars(ArrayList marshalledRegs,
ArrayList unmarshalledRegs)
Attempts to unmarshal each element of the first input argument.
|
private static final long serialVersionUID
final Fiddler server
final Uuid registrationID
final EventRegistration eventReg
Note that it is this object that contains the lease object through which the client requests the renewal or cancellation of its registration with this service.
private FiddlerRegistration(Fiddler server, Uuid registrationID, EventRegistration eventReg)
server
- reference to the server object through which
communication occurs between the client-side and
server-side of the lookup discovery service.registrationID
- the unique identifier assigned by the lookup
discovery service to the current instance of
this proxyeventReg
- object which encapsulates the information used
by the client to identify a notification sent by
the lookup discovery service to the listener
registered with the lookup discovery service by
the client's registration, for which the instance
of this class serves as proxy.
It is through this object that the client requests the renewal or cancellation of the registration being constructed.
public static FiddlerRegistration createRegistration(Fiddler server, Uuid registrationID, EventRegistration eventReg)
FiddlerRegistration
. If the server associated with
this registration implements RemoteMethodControl
, then the
object returned by this method will also implement
RemoteMethodControl
.server
- reference to the server object through which
communication occurs between the client-side and
server-side of the lookup discovery service.registrationID
- the unique identifier assigned by the lookup
discovery service to the current instance of
this proxyeventReg
- object which encapsulates the information used
by the client to identify a notification sent by
the lookup discovery service to the listener
registered with the lookup discovery service by
the client's registration, for which the instance
of this class serves as proxy.
It is through this object that the client requests the renewal or cancellation of the registration being constructed.
FiddlerRegistration
that implements
RemoteMethodControl
if the given server
does.public EventRegistration getEventRegistration()
getEventRegistration
in interface LookupDiscoveryRegistration
LookupDiscoveryRegistration.getEventRegistration()
public Lease getLease()
getLease
in interface LookupDiscoveryRegistration
LookupDiscoveryRegistration.getLease()
public ServiceRegistrar[] getRegistrars() throws LookupUnmarshalException, RemoteException
To obtain the desired lookup service proxies, this method sends a request to the the lookup discovery service. Upon receiving the request, the lookup discovery service sends the requested set of proxies as a set of marshalled instances of the ServiceRegistrar interface. Thus, in order to construct the return set, this method attempts to unmarshal each element of the set received from the lookup discovery service. Should a failure occur while attempting to unmarshal any of the elements of the received set of marshalled proxy objects, this method will throw an exception of type LookupUnmarshalException.
When a LookupUnmarshalException is thrown by this method, the contents of the exception provides the client with the following useful information: (1) the knowledge that a problem has occurred while unmarshalling at least one of the elements making up the remote state of this registration's discovered lookup service(s), (2) the set consisting of the proxy objects that were successfully unmarshalled by this method, (3) the set consisting of the marshalled proxy objects that could not be unmarshalled by this method, and (4) the set of exceptions corresponding to each failed attempt at unmarshalling.
Typically, the type of exception that occurs when attempting to unmarshal an element of the set of marshalled proxies is either an IOException or a ClassNotFoundException. A ClassNotFoundException occurs whenever a remote field of the marshalled proxy cannot be retrieved (usually because the codebase of one of the field's classes or interfaces is currently 'down'). To address this situation, the client may wish to proceed with its processing using the successfully unmarshalled proxies; and attempt to unmarshal the unavailable proxies (or re-invoke this method) at some later time.
Note that if this method returns successfully without throwing a LookupUnmarshalException, the client is guaranteed that all marshalled proxies returned to this method by the lookup discovery service have been successfully unmarshalled; and the client then has a snapshot - relative to the point in time when this method is invoked - of the remote state of the lookup service(s) discovered for this registration.
getRegistrars
in interface LookupDiscoveryRegistration
LookupUnmarshalException
- this exception
is thrown when failure occurs while attempting to unmarshal
one or more of the marshalled instances of ServiceRegistrar
received from the lookup discovery service.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service.NoSuchObjectException
- whenever the referenced
registration is invalid or non-existent.LookupDiscoveryRegistration.getRegistrars()
public String[] getGroups() throws RemoteException
If the registration's managed set of groups is currently empty, then the empty array is returned. If the lookup discovery service currently has no managed set of groups for the registration through which the request is being made, then null will be returned.
getGroups
in interface LookupDiscoveryRegistration
RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.getGroups()
public LookupLocator[] getLocators() throws RemoteException
If the registration's managed set of locators is currently empty, then the empty array is returned. If the lookup discovery service currently has no managed set of locators for the registration through which the request is being made, then null will be returned.
getLocators
in interface LookupDiscoveryRegistration
RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.getLocators()
public void addGroups(String[] groups) throws RemoteException
addGroups
in interface LookupDiscoveryRegistration
groups
- a String array, none of whose elements may be null,
consisting of the group names with which to augment
the registration's managed set of groups.
If any element of this parameter duplicates any other element of this parameter, the duplicate will be ignored. If any element of this parameter duplicates any element of the registration's current managed set of groups, the duplicate will be ignored.
If the empty set is input, then the registration's managed set of groups will not change. If null is input, this method will throw a NullPointerException.
UnsupportedOperationException
- this exception occurs
when the lookup discovery service has no managed set of groups
associated with the registration.NullPointerException
- this exception occurs when
either null is input to the groups parameter, or one or more
of the elements of the groups parameter is null.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service. When this exception does occur, the
registration's managed set of groups may or may not have been
successfully augmented.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.addGroups(java.lang.String[])
public void setGroups(String[] groups) throws RemoteException
setGroups
in interface LookupDiscoveryRegistration
groups
- a String array, none of whose elements may be null,
consisting of the group names with which to replace the
names in this registration's managed set of groups.
If any element of this parameter duplicates any other element of this parameter, the duplicate will be ignored.
If the empty set is input, then group discovery for the registration will cease. If null is input, the lookup discovery service will attempt to discover all as yet undiscovered lookup services located within its multicast radius and, upon discovery of any such lookup service, will send to the registration's listener an event signaling that discovery.
NullPointerException
- this exception occurs when one
or more of the elements of the groups parameter is null.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service. When this exception does occur, the
registration's managed set of groups may or may not have been
successfully replaced.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.setGroups(java.lang.String[])
public void removeGroups(String[] groups) throws RemoteException
removeGroups
in interface LookupDiscoveryRegistration
groups
- a String array, none of whose elements may be null,
consisting of the group names to delete from the
registration's managed set of groups.
If any element of this parameter duplicates any other element of this parameter, the duplicate will be ignored.
If the empty set is input, the registration's managed set of groups will not change. If null is input, this method will throw a NullPointerException.
UnsupportedOperationException
- this exception occurs
when the lookup discovery service has no managed set of groups
associated with the registration.NullPointerException
- this exception occurs when
either null is input to the groups parameter, or one or more
of the elements of the groups parameter is null.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service. When this exception does occur, the
registration's managed set of groups may or may not have been
successfully modified.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.removeGroups(java.lang.String[])
public void addLocators(LookupLocator[] locators) throws RemoteException
addLocators
in interface LookupDiscoveryRegistration
locators
- an array, none of whose elements may be null, consisting
of the LookupLocator objects with which to augment
the registration's managed set of locators.
If any element of this parameter duplicates any other element of this parameter, the duplicate will be ignored. If any element of this parameter duplicates any element of the registration's managed set of locators, the duplicate will be ignored.
If the empty array is input, then the registration's managed set of locators will not change. If null is input, this method will throw a NullPointerException.
UnsupportedOperationException
- this exception occurs
when the lookup discovery service has no managed set of
locators associated with the registration.NullPointerException
- this exception occurs when
either null is input to the locators parameter, or one or
more of the elements of the locators parameter is null.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service. When this exception does occur, the
registration's managed set of locators may or may not have
been successfully augmented.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.addLocators(net.jini.core.discovery.LookupLocator[])
public void setLocators(LookupLocator[] locators) throws RemoteException
setLocators
in interface LookupDiscoveryRegistration
locators
- an array, none of whose elements may be null, consisting
of the LookupLocator objects with which to replace the
locators in the registration's managed set of locators.
If any element of this parameter duplicates any other element of this parameter, the duplicate will be ignored.
If the empty array is input, then locator discovery for the registration will cease. If null is input, this method will throw a NullPointerException.
NullPointerException
- this exception occurs when
either null is input to the locators parameter, or one or
more of the elements of the locators parameter is null.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service. When this exception does occur, the
registration's managed set of locators may or may not have
been successfully replaced.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.setLocators(net.jini.core.discovery.LookupLocator[])
public void removeLocators(LookupLocator[] locators) throws RemoteException
removeLocators
in interface LookupDiscoveryRegistration
locators
- an array, none of whose elements may be null, consisting
of the LookupLocator objects to remove from the
registration's managed set of locators.
If any element of this parameter duplicates any other element of this parameter, the duplicate will be ignored.
If the empty set is input, the managed set of locators will not change. If null is input, this method will throw a NullPointerException.
UnsupportedOperationException
- this exception occurs
when the lookup discovery service has no managed set of
locators associated with the registration.NullPointerException
- this exception occurs when
either null is input to the locators parameter, or one or
more of the elements of the locators parameter is null.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service. When this exception does occur, the
registration's managed set of locators may or may not have
been successfully modified.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.removeLocators(net.jini.core.discovery.LookupLocator[])
public void discard(ServiceRegistrar registrar) throws RemoteException
discard
in interface LookupDiscoveryRegistration
registrar
- a reference to the lookup service that the lookup
discovery service is being asked to discard.
If this parameter equals none of the lookup services contained in the managed set of lookup services for this registration, no action will be taken.
NullPointerException
- this exception occurs when
null is input to the registrar parameter.RemoteException
- typically, this exception occurs when
there is a communication failure between the client and the
lookup discovery service. When this exception does occur,
the lookup service may or may not have been successfully
discarded.NoSuchObjectException
- whenever the
registrationID
parameter references an invalid
or non-existent registration.LookupDiscoveryRegistration.discard(net.jini.core.lookup.ServiceRegistrar)
public Uuid getReferentUuid()
getReferentUuid
in interface ReferentUuid
Uuid
that is associated with the
resource this proxy represents. This method will not return
null
.ReferentUuid
public int hashCode()
public boolean equals(Object obj)
private static ArrayList unmarshalRegistrars(ArrayList marshalledRegs, ArrayList unmarshalledRegs)
Note that there is a one-to-one correspondence between the exceptions contained in the return set and the remaining elements in the first set after all unmarshalling attempts have completed.
marshalledRegs
- an ArrayList object consisting of marshalled
instances of ServiceRegistrar, each
corresponding to a proxy to a lookup service.unmarshalledRegs
- an ArrayList object consisting of all
successfully unmarshalled proxies from
the first argument.private static void insertRegistrars(ServiceRegistrar[] regsArray, ArrayList regsList)
regsArray
- array that will receive the new references.regsList
- ArrayList containing the ServiceRegistrar references
to place in regsArray input argument.private static int indexFirstNull(Object[] arr)
If the array is null (or has zero length), -1 will be returned. If every element of the array is non-null, this method will return the length of the array. Thus, after invoking this method, it is important to test for these conditions to avoid the occurrence of an IndexOutOfBoundsException when using the value returned by this method.
arr
- Object array to examine for the first occurrence of nullprivate void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
InvalidObjectException
- if the state of the
deserialized instance of this class is found to be invalid.IOException
ClassNotFoundException
private void readObjectNoData() throws InvalidObjectException
InvalidObjectException
- to indicate that there
was no data in the stream during deserialization of an
instance of this class; declaring that something is wrong.InvalidObjectException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.