com.sun.jini.mercury
Class Registration

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

 class Registration
extends Object
implements MailboxPullRegistration, Serializable, ReferentUuid

The Registration class is the client-side proxy returned to event mailbox clients as the result of the registration process. It implements the MailboxRegistration interface and delegates functionality to the mailbox service where necessary.

Since:
1.1
Author:
Sun Microsystems, Inc.

Nested Class Summary
(package private) static class Registration.ConstrainableRegistration
          A subclass of Registration that implements RemoteMethodControl.
 
Field Summary
(package private)  Lease lease
          The service's registration lease
(package private)  ListenerProxy listener
          Reference to service provided RemoteEventListener implementation
(package private)  MailboxBackEnd mailbox
          Reference to service implementation
(package private)  Uuid registrationID
          Unique identifier for this registration
private static long serialVersionUID
           
 
Constructor Summary
private Registration(Uuid id, MailboxBackEnd srv, Lease l)
          Convenience constructor
 
Method Summary
 void addUnknownEvents(Collection unknownEvents)
          Adds the provided collection of unknown events to this registration.
(package private) static Registration create(Uuid id, MailboxBackEnd server, Lease lease)
          Creates a mailbox registration proxy, returning an instance that implements RemoteMethodControl if the server does too.
 void disableDelivery()
          Ceases delivery of stored notifications to the existing target listener, if any.
 void enableDelivery(RemoteEventListener target)
          Initiates delivery of stored notifications to the supplied target listener, if any.
 boolean equals(Object o)
          Proxies with the same registrationID are considered equal.
 Lease getLease()
          Returns the Lease object associated with this registration.
 RemoteEventListener getListener()
          Returns the RemoteEventListener associated with this registration.
 Uuid getReferentUuid()
          Returns the universally unique identifier that has been assigned to the resource this proxy represents.
 RemoteEventIterator getRemoteEvents()
          Retrieves stored notifications, if any.
 int hashCode()
          Proxies with the same registrationID have the same hash code.
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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

registrationID

final Uuid registrationID
Unique identifier for this registration


mailbox

final MailboxBackEnd mailbox
Reference to service implementation


listener

final ListenerProxy listener
Reference to service provided RemoteEventListener implementation


lease

final Lease lease
The service's registration lease

Constructor Detail

Registration

private Registration(Uuid id,
                     MailboxBackEnd srv,
                     Lease l)
Convenience constructor

Method Detail

create

static Registration create(Uuid id,
                           MailboxBackEnd server,
                           Lease lease)
Creates a mailbox registration proxy, returning an instance that implements RemoteMethodControl if the server does too.

Parameters:
server - the server proxy
id - the ID of the lease set
lease - the lease set's lease

getLease

public Lease getLease()
Description copied from interface: MailboxRegistration
Returns the Lease object associated with this registration. The client can renew or cancel the registration with the mailbox service through this lease object.

Specified by:
getLease in interface MailboxRegistration
Returns:
The lease object associated with this registration

getListener

public RemoteEventListener getListener()
Description copied from interface: MailboxRegistration
Returns the RemoteEventListener associated with this registration. This listener can then be submitted as the RemoteEventListener argument to an event generator's registration method(s).

Specified by:
getListener in interface MailboxRegistration
Returns:
The RemoteEventListener associated with this registration.

enableDelivery

public void enableDelivery(RemoteEventListener target)
                    throws RemoteException
Description copied from interface: MailboxRegistration
Initiates delivery of stored notifications to the supplied target listener, if any. If a target listener already exists, then it will be replaced with the specified target listener. Passing null as the target parameter has the same effect as calling the disableDelivery method.

Specified by:
enableDelivery in interface MailboxRegistration
Parameters:
target - The listener to be notified of stored events, if any.
Throws:
RemoteException - if there is a communication failure between the client and the service.

disableDelivery

public void disableDelivery()
                     throws RemoteException
Description copied from interface: MailboxRegistration
Ceases delivery of stored notifications to the existing target listener, if any. It is acceptable to call this method even if no target listener is currently enabled.

Specified by:
disableDelivery in interface MailboxRegistration
Throws:
RemoteException - if there is a communication failure between the client and the service.

getRemoteEvents

public RemoteEventIterator getRemoteEvents()
                                    throws RemoteException
Description copied from interface: MailboxPullRegistration
Retrieves stored notifications, if any.

Specified by:
getRemoteEvents in interface MailboxPullRegistration
Returns:
A RemoteEventIterator that can be used to retrieve event notifications from the mailbox service.
Throws:
RemoteException - if there is a communication failure between the client and the service.

addUnknownEvents

public void addUnknownEvents(Collection unknownEvents)
                      throws RemoteException
Description copied from interface: MailboxPullRegistration
Adds the provided collection of unknown events to this registration. The mailbox will then propagate an UnknownEventException back to any event generator that attempts to deliver an event with an identifier-source combination held in a registration's unknown exception list.

Specified by:
addUnknownEvents in interface MailboxPullRegistration
Parameters:
unknownEvents - A Collection of unknown events to be associated with this registration.
Throws:
RemoteException - if there is a communication failure between the client and the service.

getReferentUuid

public Uuid getReferentUuid()
Returns the universally unique identifier that has been assigned to the resource this proxy represents.

Specified by:
getReferentUuid in interface ReferentUuid
Returns:
the instance of Uuid that is associated with the resource this proxy represents. This method will not return null.
See Also:
ReferentUuid

hashCode

public int hashCode()
Proxies with the same registrationID have the same hash code.

Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Proxies with the same registrationID are considered equal.

Overrides:
equals in class Object

readObject

private void readObject(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
When an instance of this class is deserialized, this method is automatically invoked. This implementation of this method validates the state of the deserialized instance.

Throws:
InvalidObjectException - if the state of the deserialized instance of this class is found to be invalid.
IOException
ClassNotFoundException

readObjectNoData

private void readObjectNoData()
                       throws ObjectStreamException
During deserialization of an instance of this class, if it is found that the stream contains no data, this method is automatically invoked. Because it is expected that the stream should always contain data, this implementation of this method simply declares that something must be wrong.

Throws:
InvalidObjectException - to indicate that there was no data in the stream during deserialization of an instance of this class; declaring that something is wrong.
ObjectStreamException


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