com.sun.jini.outrigger
Class StorableEventWatcher

java.lang.Object
  extended by com.sun.jini.outrigger.TransitionWatcher
      extended by com.sun.jini.outrigger.EventRegistrationWatcher
          extended by com.sun.jini.outrigger.StorableEventWatcher
All Implemented Interfaces:
LeasedResource, EventRegistrationRecord, StorableObject, StorableResource, Comparable

 class StorableEventWatcher
extends EventRegistrationWatcher
implements StorableResource

Subclass of EventRegistrationWatcher for non-transactional persistent event registrations.


Field Summary
private  StorableReference listener
          The listener that should be notified of matches
 
Fields inherited from class com.sun.jini.outrigger.EventRegistrationWatcher
cookie, eventID, expiration, handback, lastSeqNumDelivered
 
Fields inherited from class com.sun.jini.outrigger.TransitionWatcher
startOrdinal
 
Constructor Summary
StorableEventWatcher(long timestamp, long startOrdinal, long currentSeqNum)
          Used during log recovery to create a mostly empty StorableEventWatcher.
StorableEventWatcher(long timestamp, long startOrdinal, Uuid cookie, MarshalledObject handback, long eventID, RemoteEventListener listener)
          Create a new StorableEventWatcher.
 
Method Summary
(package private)  void cleanup(TemplateHandle owner, boolean expired)
          Overridden by subclasses if there is any cleanup work they need to do as part of cancel or removeIfExpired.
(package private)  RemoteEventListener getListener(ProxyPreparer preparer)
          Return the remote listener associated with this EventRegistrationWatcher.
(package private)  boolean isInterested(EntryTransition transition, long ordinal)
          Return true if this watcher cares about a given visibility transition.
 void restore(ObjectInputStream in)
          Restore the persistent fields
 void store(ObjectOutputStream out)
          Store the persistent fields
 
Methods inherited from class com.sun.jini.outrigger.EventRegistrationWatcher
addTemplateHandle, cancel, getCookie, getExpiration, process, removeIfExpired, setExpiration
 
Methods inherited from class com.sun.jini.outrigger.TransitionWatcher
compareTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.jini.landlord.LeasedResource
getCookie, getExpiration, setExpiration
 

Field Detail

listener

private StorableReference listener
The listener that should be notified of matches

Constructor Detail

StorableEventWatcher

StorableEventWatcher(long timestamp,
                     long startOrdinal,
                     long currentSeqNum)
Used during log recovery to create a mostly empty StorableEventWatcher.

Note, we set the time stamp and tie-breaker here instead of getting them from the log. This means they will be inconstant with their value from the last VM we were in, but since they never leak out and events are read-only anyway this should not be a problem (this also allows us to keep the tie-breaker and time stamp in final fields).

Parameters:
timestamp - the value that is used to sort TransitionWatchers.
startOrdinal - the highest ordinal associated with operations that are considered to have occurred before the operation associated with this watcher.
currentSeqNum - Sequence number to start with.
Throws:
NullPointerException - if the notifier argument is null.

StorableEventWatcher

StorableEventWatcher(long timestamp,
                     long startOrdinal,
                     Uuid cookie,
                     MarshalledObject handback,
                     long eventID,
                     RemoteEventListener listener)
Create a new StorableEventWatcher.

Parameters:
timestamp - the value that is used to sort TransitionWatchers.
startOrdinal - the highest ordinal associated with operations that are considered to have occurred before the operation associated with this watcher.
cookie - The unique identifier associated with this watcher. Must not be null.
handback - The handback object that should be sent along with event notifications to the the listener.
eventID - The event ID for event type represented by this object.
listener - The object to notify of matches.
Throws:
NullPointerException - if the cookie, or listener arguments are null.
Method Detail

isInterested

boolean isInterested(EntryTransition transition,
                     long ordinal)
Description copied from class: TransitionWatcher
Return true if this watcher cares about a given visibility transition. Assumes the transitioning entry matches the template in the TemplateHandle associated with this watcher. This method should return a value even if the expiration time has been reached or remove has been called. This call should not obtain any locks.

Specified by:
isInterested in class TransitionWatcher
Parameters:
transition - A EntryTransition that describes the transition and what entry is transitioning. This method will assume that transition.getHandle returns a non-null value.
ordinal - The ordinal associated with transition.
Returns:
true if this watcher is interested in the indicated transition and false otherwise.

getListener

RemoteEventListener getListener(ProxyPreparer preparer)
                          throws ClassNotFoundException,
                                 IOException
Description copied from class: EventRegistrationWatcher
Return the remote listener associated with this EventRegistrationWatcher. Optionally prepare the listener if it has been recovered from the store and not yet re-prepared.

Specified by:
getListener in class EventRegistrationWatcher
Returns:
the remote listener associated with this EventRegistrationWatcher.
Throws:
ClassNotFoundException - if the listener needs to be unmarshalled and a necessary class can not be found.
IOException - if the listener can not be unmarshalled. May throw RemoteException if the call to the preparer does

cleanup

void cleanup(TemplateHandle owner,
             boolean expired)
Overridden by subclasses if there is any cleanup work they need to do as part of cancel or removeIfExpired. Called after releasing the lock on this. Will be called at most once.

Overrides:
cleanup in class EventRegistrationWatcher
Parameters:
owner - A reference to the owner.
expired - true if being called from removeIfExpired and false otherwise.

store

public void store(ObjectOutputStream out)
           throws IOException
Store the persistent fields

Specified by:
store in interface StorableObject
Throws:
IOException

restore

public void restore(ObjectInputStream in)
             throws IOException,
                    ClassNotFoundException
Restore the persistent fields

Specified by:
restore in interface StorableObject
Throws:
IOException
ClassNotFoundException


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