com.sun.jini.reggie
Class Registration

java.lang.Object
  extended by com.sun.jini.reggie.Registration
All Implemented Interfaces:
Serializable, ServiceRegistration, ReferentUuid
Direct Known Subclasses:
ConstrainableRegistration

 class Registration
extends Object
implements ServiceRegistration, ReferentUuid, Serializable

Implementation class for the ServiceRegistration interface.

Author:
Sun Microsystems, Inc.

Field Summary
(package private)  ServiceLease lease
          The service lease
private static long serialVersionUID
           
(package private)  Registrar server
          The registrar
 
Constructor Summary
Registration(Registrar server, ServiceLease lease)
          Constructor for use by getInstance(), ConstrainableRegistration.
 
Method Summary
 void addAttributes(Entry[] attrSets)
          Adds the specified attribute sets (those that aren't duplicates of existing attribute sets) to the registered service item.
 boolean equals(Object obj)
          Returns true if registration Uuids match, false otherwise.
(package private) static Registration getInstance(Registrar server, ServiceLease lease)
          Returns Registration or ConstrainableRegistration instance, depending on whether given server implements RemoteMethodControl.
 Lease getLease()
          Returns the lease that controls the service registration, allowing the lease to be renewed or cancelled.
 Uuid getReferentUuid()
          Return the Uuid that has been assigned to the resource this proxy represents.
 ServiceID getServiceID()
          Returns the service ID for this service.
 int hashCode()
          Returns the registration Uuid's hash code.
 void modifyAttributes(Entry[] attrSetTmpls, Entry[] attrSets)
          Modifies existing attribute sets.
private  void readObject(ObjectInputStream in)
          Verifies that member fields are non-null.
private  void readObjectNoData()
          Throws InvalidObjectException, since data for this class is required.
 void setAttributes(Entry[] attrSets)
          Deletes all of the service item's existing attributes, and replaces them with the specified attribute sets.
 String toString()
          Returns a string created from the proxy class name and the result of calling toString on the contained lease.
 
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


lease

final ServiceLease lease
The service lease

Constructor Detail

Registration

Registration(Registrar server,
             ServiceLease lease)
Constructor for use by getInstance(), ConstrainableRegistration.

Method Detail

getInstance

static Registration getInstance(Registrar server,
                                ServiceLease lease)
Returns Registration or ConstrainableRegistration instance, depending on whether given server implements RemoteMethodControl.


getServiceID

public ServiceID getServiceID()
Description copied from interface: ServiceRegistration
Returns the service ID for this service. Note that this method does not make a remote call.

Specified by:
getServiceID in interface ServiceRegistration
Returns:
the ServiceID for this service.

getLease

public Lease getLease()
Description copied from interface: ServiceRegistration
Returns the lease that controls the service registration, allowing the lease to be renewed or cancelled. Note that this does not make a remote call.

Specified by:
getLease in interface ServiceRegistration
Returns:
the lease that controls this service registration.

addAttributes

public void addAttributes(Entry[] attrSets)
                   throws UnknownLeaseException,
                          RemoteException
Description copied from interface: ServiceRegistration
Adds the specified attribute sets (those that aren't duplicates of existing attribute sets) to the registered service item. Note that this operation has no effect on existing attribute sets of the service item, and can be repeated in an idempotent fashion.

Specified by:
addAttributes in interface ServiceRegistration
Parameters:
attrSets - attribute sets to add
Throws:
UnknownLeaseException - the registration lease has expired or been cancelled.
RemoteException

modifyAttributes

public void modifyAttributes(Entry[] attrSetTmpls,
                             Entry[] attrSets)
                      throws UnknownLeaseException,
                             RemoteException
Description copied from interface: ServiceRegistration
Modifies existing attribute sets. The lengths of attrSetTemplates and attrSets must be equal, or IllegalArgumentException is thrown. The service item's attribute sets are modified as follows. For each array index i: if attrSets[i] is null, then every entry that matches attrSetTemplates[i] is deleted; otherwise, for every non-null field in attrSets[i], the value of that field is stored into the corresponding field of every entry that matches attrSetTemplates[i]. The class of attrSets[i] must be the same as, or a superclass of, the class of attrSetTemplates[i], or IllegalArgumentException is thrown. If the modifications result in duplicate entries within the service item, the duplicates are eliminated.

Note that it is possible to use modifyAttributes in ways that are not idempotent. The attribute schema should be designed in such a way that all intended uses of this method can be performed in an idempotent fashion. Also note that modifyAttributes does not provide a means for setting a field to null; it is assumed that the attribute schema is designed in such a way that this is not necessary.

Specified by:
modifyAttributes in interface ServiceRegistration
Parameters:
attrSetTmpls - attribute set templates to match
attrSets - modifications to make to matching attribute sets
Throws:
UnknownLeaseException - the registration lease has expired or been cancelled
RemoteException

setAttributes

public void setAttributes(Entry[] attrSets)
                   throws UnknownLeaseException,
                          RemoteException
Description copied from interface: ServiceRegistration
Deletes all of the service item's existing attributes, and replaces them with the specified attribute sets. Any duplicate attribute sets are eliminated in the stored representation of the item.

Specified by:
setAttributes in interface ServiceRegistration
Parameters:
attrSets - attribute sets to use
Throws:
UnknownLeaseException - the registration lease has expired or been cancelled
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 the registration Uuid's hash code.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Returns true if registration Uuids match, false otherwise.

Overrides:
equals in class Object

toString

public String toString()
Returns a string created from the proxy class name and the result of calling toString on the contained lease.

Overrides:
toString in class Object
Returns:
String

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Verifies that member fields are 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.