com.sun.jini.reggie
Class AdminProxy

java.lang.Object
  extended by com.sun.jini.reggie.AdminProxy
All Implemented Interfaces:
DestroyAdmin, Serializable, JoinAdmin, ReferentUuid, DiscoveryAdmin
Direct Known Subclasses:
ConstrainableAdminProxy

 class AdminProxy
extends Object
implements DiscoveryAdmin, JoinAdmin, DestroyAdmin, ReferentUuid, Serializable

Proxy for administering a registrar, returned from the getAdmin method of the main registrar proxy. Clients only see instances via the DiscoveryAdmin, JoinAdmin, DestroyAdmin and ReferentUuid interfaces.

Author:
Sun Microsystems, Inc.

Field Summary
(package private)  ServiceID registrarID
          The registrar's service ID.
private static long serialVersionUID
           
(package private)  Registrar server
          The registrar.
 
Constructor Summary
AdminProxy(Registrar server, ServiceID registrarID)
          Constructor for use by getInstance(), ConstrainableAdminProxy.
 
Method Summary
 void addLookupAttributes(Entry[] attrSets)
          Add attribute sets for the service.
 void addLookupGroups(String[] groups)
          Add new groups to the set to join.
 void addLookupLocators(LookupLocator[] locators)
          Add locators for specific new lookup services to join.
 void addMemberGroups(String[] groups)
          Adds the given set of names to the set whose elements are the names of the groups in which the lookup service is currently a member.
 void destroy()
          Destroy the service, if possible, including its persistent storage.
 boolean equals(Object obj)
          Proxies for servers with the same service ID are considered equal.
(package private) static AdminProxy getInstance(Registrar server, ServiceID registrarID)
          Returns AdminProxy or ConstrainableAdminProxy instance, depending on whether given server implements RemoteMethodControl.
 Entry[] getLookupAttributes()
          Get the current attribute sets for the service.
 String[] getLookupGroups()
          Get the list of groups to join.
 LookupLocator[] getLookupLocators()
          Get the list of locators of specific lookup services to join.
 String[] getMemberGroups()
          Returns an array consisting of the names of the groups in which the lookup service is a member.
 Uuid getReferentUuid()
          Return the Uuid that has been assigned to the resource this proxy represents.
 int getUnicastPort()
          Returns the port number on which the lookup service listens for unicast discovery queries.
 int hashCode()
          Returns service ID hash code.
 void modifyLookupAttributes(Entry[] attrSetTemplates, Entry[] attrSets)
          Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes.
private  void readObject(ObjectInputStream in)
          Reads the default serializable field value for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method.
private  void readObjectNoData()
          Throws InvalidObjectException, since data for this class is required.
 void removeLookupGroups(String[] groups)
          Remove groups from the set to join.
 void removeLookupLocators(LookupLocator[] locators)
          Remove locators for specific lookup services from the set to join.
 void removeMemberGroups(String[] groups)
          Deletes the elements of the given set of names from the set whose elements are the names of the groups in which the lookup service is currently a member.
 void setLookupGroups(String[] groups)
          Replace the list of groups to join with a new list.
 void setLookupLocators(LookupLocator[] locators)
          Replace the list of locators of specific lookup services to join with a new list.
 void setMemberGroups(String[] groups)
          Replaces the set whose elements are the names of the groups in which the lookup service is currently a member with the given set of group names.
 void setUnicastPort(int port)
          Changes the number of the port on which the lookup service is currently listening for unicast discovery queries to the given port number.
 String toString()
          Returns a string created from the proxy class name, the registrar's service ID, and the result of the underlying proxy's toString method.
private  void writeObject(ObjectOutputStream out)
          Writes the default serializable field value for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

server

final Registrar server
The registrar.


registrarID

transient ServiceID registrarID
The registrar's service ID.

Constructor Detail

AdminProxy

AdminProxy(Registrar server,
           ServiceID registrarID)
Constructor for use by getInstance(), ConstrainableAdminProxy.

Method Detail

getInstance

static AdminProxy getInstance(Registrar server,
                              ServiceID registrarID)
Returns AdminProxy or ConstrainableAdminProxy instance, depending on whether given server implements RemoteMethodControl.


getLookupAttributes

public Entry[] getLookupAttributes()
                            throws RemoteException
Description copied from interface: JoinAdmin
Get the current attribute sets for the service.

Specified by:
getLookupAttributes in interface JoinAdmin
Returns:
the current attribute sets for the service
Throws:
RemoteException

addLookupAttributes

public void addLookupAttributes(Entry[] attrSets)
                         throws RemoteException
Description copied from interface: JoinAdmin
Add attribute sets for the service. The resulting set will be used for all future joins. The attribute sets are also added to all currently-joined lookup services.

Specified by:
addLookupAttributes in interface JoinAdmin
Parameters:
attrSets - the attribute sets to add
Throws:
RemoteException

modifyLookupAttributes

public void modifyLookupAttributes(Entry[] attrSetTemplates,
                                   Entry[] attrSets)
                            throws RemoteException
Description copied from interface: JoinAdmin
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 to all currently-joined lookup services.

Specified by:
modifyLookupAttributes in interface JoinAdmin
Parameters:
attrSetTemplates - the templates for matching attribute sets
attrSets - the modifications to make to matching sets
Throws:
RemoteException
See Also:
ServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])

getLookupGroups

public String[] getLookupGroups()
                         throws RemoteException
Description copied from interface: JoinAdmin
Get the list of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).

Specified by:
getLookupGroups in interface JoinAdmin
Returns:
an array of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).
Throws:
RemoteException
See Also:
JoinAdmin.setLookupGroups(java.lang.String[])

addLookupGroups

public void addLookupGroups(String[] groups)
                     throws RemoteException
Description copied from interface: JoinAdmin
Add new groups to the set to join. Lookup services in the new groups will be discovered and joined.

Specified by:
addLookupGroups in interface JoinAdmin
Parameters:
groups - groups to join
Throws:
RemoteException
See Also:
JoinAdmin.removeLookupGroups(java.lang.String[])

removeLookupGroups

public void removeLookupGroups(String[] groups)
                        throws RemoteException
Description copied from interface: JoinAdmin
Remove groups from the set to join. Leases are cancelled at lookup services that are not members of any of the remaining groups.

Specified by:
removeLookupGroups in interface JoinAdmin
Parameters:
groups - groups to leave
Throws:
RemoteException
See Also:
JoinAdmin.addLookupGroups(java.lang.String[])

setLookupGroups

public void setLookupGroups(String[] groups)
                     throws RemoteException
Description copied from interface: JoinAdmin
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. Lookup services in the new groups will be discovered and joined.

Specified by:
setLookupGroups in interface JoinAdmin
Parameters:
groups - groups to join
Throws:
RemoteException
See Also:
JoinAdmin.getLookupGroups()

getLookupLocators

public LookupLocator[] getLookupLocators()
                                  throws RemoteException
Description copied from interface: JoinAdmin
Get the list of locators of specific lookup services to join.

Specified by:
getLookupLocators in interface JoinAdmin
Returns:
the list of locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.setLookupLocators(net.jini.core.discovery.LookupLocator[])

addLookupLocators

public void addLookupLocators(LookupLocator[] locators)
                       throws RemoteException
Description copied from interface: JoinAdmin
Add locators for specific new lookup services to join. The new lookup services will be discovered and joined.

Specified by:
addLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.removeLookupLocators(net.jini.core.discovery.LookupLocator[])

removeLookupLocators

public void removeLookupLocators(LookupLocator[] locators)
                          throws RemoteException
Description copied from interface: JoinAdmin
Remove locators for specific lookup services from the set to join. Any leases held at the lookup services are cancelled.

Specified by:
removeLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to leave
Throws:
RemoteException
See Also:
JoinAdmin.addLookupLocators(net.jini.core.discovery.LookupLocator[])

setLookupLocators

public void setLookupLocators(LookupLocator[] locators)
                       throws RemoteException
Description copied from interface: JoinAdmin
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. Any new lookup services will be discovered and joined.

Specified by:
setLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.getLookupLocators()

addMemberGroups

public void addMemberGroups(String[] groups)
                     throws RemoteException
Description copied from interface: DiscoveryAdmin
Adds the given set of names to the set whose elements are the names of the groups in which the lookup service is currently a member. Elements in the input set that duplicate names of groups in which the lookup service is already a member will be ignored. If the empty array (NO_GROUPS) is input, this method takes no action.

Specified by:
addMemberGroups in interface DiscoveryAdmin
Parameters:
groups - String array consisting of the names of the new, additional groups in which the lookup service is to be a member.
Throws:
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server.

removeMemberGroups

public void removeMemberGroups(String[] groups)
                        throws RemoteException
Description copied from interface: DiscoveryAdmin
Deletes the elements of the given set of names from the set whose elements are the names of the groups in which the lookup service is currently a member. Any element in the input set that is not a name of a group in which the lookup service is currently a member will be ignored. If the empty array (NO_GROUPS) is input, this method takes no action.

Specified by:
removeMemberGroups in interface DiscoveryAdmin
Parameters:
groups - String array consisting of the names to remove from the set whose elements are the names of the groups in which the lookup service is currently a member.
Throws:
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server.

getMemberGroups

public String[] getMemberGroups()
                         throws RemoteException
Description copied from interface: DiscoveryAdmin
Returns an array consisting of the names of the groups in which the lookup service is a member. If the lookup service currently belongs to no groups, this method will return the empty array.

Specified by:
getMemberGroups in interface DiscoveryAdmin
Returns:
String array consisting of the names of the groups in which the lookup service is a member
Throws:
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server.

setMemberGroups

public void setMemberGroups(String[] groups)
                     throws RemoteException
Description copied from interface: DiscoveryAdmin
Replaces the set whose elements are the names of the groups in which the lookup service is currently a member with the given set of group names. Elements in the input set that duplicate other elements in the input set will be ignored. If the empty array (NO_GROUPS) is input, then the lookup service will be a member of no groups.

Specified by:
setMemberGroups in interface DiscoveryAdmin
Parameters:
groups - String array consisting of the names of the new groups in which the lookup service is to be a member.
Throws:
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server.

getUnicastPort

public int getUnicastPort()
                   throws RemoteException
Description copied from interface: DiscoveryAdmin
Returns the port number on which the lookup service listens for unicast discovery queries.

Specified by:
getUnicastPort in interface DiscoveryAdmin
Returns:
an int representing the port number on which the lookup service listens for unicast discovery queries.
Throws:
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server.

setUnicastPort

public void setUnicastPort(int port)
                    throws IOException,
                           RemoteException
Description copied from interface: DiscoveryAdmin
Changes the number of the port on which the lookup service is currently listening for unicast discovery queries to the given port number. If a value of zero is input, then the lookup service will first try to listen on the standard unicast discovery port, but if that fails, the lookup service will listen on an arbitrary port.

Specified by:
setUnicastPort in interface DiscoveryAdmin
Parameters:
port - int representing the new port number on which the lookup service should listen for unicast discovery queries.
Throws:
IOException - because an invocation of this method will result in the re-initiation of the unicast discovery process, which can throw an IOException when socket allocation occurs.
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server.

destroy

public void destroy()
             throws RemoteException
Description copied from interface: DestroyAdmin
Destroy the service, if possible, including its persistent storage. This method should (in effect) spawn a separate thread to do the actual work asynchronously, and make a reasonable attempt to let this remote call return successfully. As such, a successful return from this method does not mean that the service has been destroyed. Although the service should make a reasonable attempt to let this remote call return successfully, the service must not wait indefinitely for other (in-progress and subsequent) remote calls to finish before proceeding to destroy itself. Once this method has been called, the service can, but need not, reject all other (in-progress and subsequent) remote calls to the service.

Specified by:
destroy in interface DestroyAdmin
Throws:
RemoteException

getReferentUuid

public Uuid getReferentUuid()
Description copied from interface: ReferentUuid
Return the Uuid that has been assigned to the resource this proxy represents.

Specified by:
getReferentUuid in interface ReferentUuid
Returns:
the Uuid associated with the resource this proxy represents. Will not return null.

hashCode

public int hashCode()
Returns service ID hash code.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Proxies for servers with the same service ID are considered equal.

Overrides:
equals in class Object

toString

public String toString()
Returns a string created from the proxy class name, the registrar's service ID, and the result of the underlying proxy's toString method.

Overrides:
toString in class Object
Returns:
String

writeObject

private void writeObject(ObjectOutputStream out)
                  throws IOException
Writes the default serializable field value for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method.

Throws:
IOException

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Reads the default serializable field value for this instance, followed by the registrar's service ID encoded as specified by the ServiceID.writeBytes method. Verifies that the deserialized registrar reference is non-null.

Throws:
IOException
ClassNotFoundException

readObjectNoData

private void readObjectNoData()
                       throws ObjectStreamException
Throws InvalidObjectException, since data for this class is required.

Throws:
ObjectStreamException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.