com.sun.jini.mercury
Class ServiceRegistration

java.lang.Object
  extended by com.sun.jini.mercury.ServiceRegistration
All Implemented Interfaces:
LeasedResource, Serializable, Comparable

 class ServiceRegistration
extends Object
implements LeasedResource, Comparable, Serializable

The ServiceRegistration class serves as the server-side abstraction that maintains client registration state information. It implements the LeasedResource interface to allow it to be used with the Landlord framework. It implements the Comparable interface so that it can be used in SortedMap collections.

Since:
1.1
Author:
Sun Microsystems, Inc.

Field Summary
private  Uuid cookie
          Unique identifier object
private  EventLogIterator eventIterator
          Event log iterator.
private  long expiration
          The current expiration for this registration
private  String iteratorNotifier
          Lock object used to coordinate event delivery via the iterator.
private  MarshalledObject marshalledEventTarget
          The marshalled form of the client-provided notification target.
private  RemoteEventListener preparedEventTarget
          The prepared, client-provided notification target.
private  Uuid remoteEventIteratorID
          Unique identifier object for the currently enabled (client-side) remote event iterator.
private static long serialVersionUID
           
private  Map unknownEvents
          Map of collected EventID's that resulted in an UnknownEventException for the current eventTarget.
 
Constructor Summary
ServiceRegistration(Uuid cookie, EventLogIterator eventIterator)
          Convenience constructor
 
Method Summary
 int compareTo(Object obj)
          Primary sort by leaseExpiration, secondary by leaseID.
(package private)  void dumpInfo(Logger logger)
          Utility method to display debugging information to the provided Logger
 Uuid getCookie()
          Returns the universally unique identifier associated with this lease.
 RemoteEventListener getEventTarget()
          Get the reference to the prepared, client-supplied notification target
 long getExpiration()
          Returns the expiration time of the lease.
 Object getIteratorNotifier()
          Get the remote iterator notifier object.
 Uuid getRemoteEventIteratorID()
          Get the remote iterator id
 Map getUnknownEvents()
          Return the identity map of EventIDs that caused an UnknownEventException to be generated for the current notification target.
 boolean hasEventTarget()
          Returns true if an event target is currently set and false otherwise.
 EventLogIterator iterator()
          Get the reference to the registration's associated EventLogIterator
 void restoreTransientState(ProxyPreparer targetPreparer)
           
 void setEventTarget(RemoteEventListener preparedTarget)
          Set the reference to the client-supplied notification target
 void setExpiration(long newExpiration)
          Changes the expiration time of the lease.
 void setIterator(EventLogIterator iter)
          Set the reference for this registration's EventLogIterator
 void setRemoteEventIteratorID(Uuid id)
          Set the remote iterator id
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

cookie

private final Uuid cookie
Unique identifier object


expiration

private long expiration
The current expiration for this registration


preparedEventTarget

private transient RemoteEventListener preparedEventTarget
The prepared, client-provided notification target.


marshalledEventTarget

private MarshalledObject marshalledEventTarget
The marshalled form of the client-provided notification target.


eventIterator

private transient EventLogIterator eventIterator
Event log iterator.


unknownEvents

private Map unknownEvents
Map of collected EventID's that resulted in an UnknownEventException for the current eventTarget. This Map is checked upon each mailbox notification for this registration. If the received event has the same EventID as the one contained in this Map then an UnknownEventException is propagated back to the sender and the event is not logged. This structure is also consulted before each event delivery request. If the event to be delivered has an EventID that is contained in this Map, then event delivery is cancelled for that particular event. Note that this structure gets cleared whenever a target listener is (re)set on the assumption that an active (re)set will provide a new/better target listener that might be able to handle these events.


remoteEventIteratorID

private Uuid remoteEventIteratorID
Unique identifier object for the currently enabled (client-side) remote event iterator.


iteratorNotifier

private final String iteratorNotifier
Lock object used to coordinate event delivery via the iterator. Has to be a serializable object versus just a plain Object.

Constructor Detail

ServiceRegistration

public ServiceRegistration(Uuid cookie,
                           EventLogIterator eventIterator)
Convenience constructor

Method Detail

setExpiration

public void setExpiration(long newExpiration)
Description copied from interface: LeasedResource
Changes the expiration time of the lease.

Specified by:
setExpiration in interface LeasedResource
Parameters:
newExpiration - The new expiration time in milliseconds since the beginning of the epoch

getExpiration

public long getExpiration()
Description copied from interface: LeasedResource
Returns the expiration time of the lease.

Specified by:
getExpiration in interface LeasedResource
Returns:
The expiration time in milliseconds since the beginning of the epoch

getCookie

public Uuid getCookie()
Description copied from interface: LeasedResource
Returns the universally unique identifier associated with this lease. Any proxies for this lease that implement ReferentUuid should return this object from their getReferentUuid method and should base their implementation of equals on this object.

Specified by:
getCookie in interface LeasedResource

getUnknownEvents

public Map getUnknownEvents()
Return the identity map of EventIDs that caused an UnknownEventException to be generated for the current notification target. A Map is used instead of a generic Collection since the space/time tradeoff for searches seems worth it.


getEventTarget

public RemoteEventListener getEventTarget()
Get the reference to the prepared, client-supplied notification target


setEventTarget

public void setEventTarget(RemoteEventListener preparedTarget)
                    throws IOException
Set the reference to the client-supplied notification target

Throws:
IOException

getRemoteEventIteratorID

public Uuid getRemoteEventIteratorID()
Get the remote iterator id


getIteratorNotifier

public Object getIteratorNotifier()
Get the remote iterator notifier object. This is used to coordinate notifications between event delivery and event reception via the iterator.


setRemoteEventIteratorID

public void setRemoteEventIteratorID(Uuid id)
Set the remote iterator id


hasEventTarget

public boolean hasEventTarget()
Returns true if an event target is currently set and false otherwise.


restoreTransientState

public void restoreTransientState(ProxyPreparer targetPreparer)
                           throws IOException,
                                  ClassNotFoundException
Throws:
IOException
ClassNotFoundException

iterator

public EventLogIterator iterator()
Get the reference to the registration's associated EventLogIterator


setIterator

public void setIterator(EventLogIterator iter)
Set the reference for this registration's EventLogIterator


compareTo

public int compareTo(Object obj)
Primary sort by leaseExpiration, secondary by leaseID. The secondary sort is immaterial, except to ensure a total order (required by TreeMap).

Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class Object

dumpInfo

void dumpInfo(Logger logger)
Utility method to display debugging information to the provided Logger



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