com.sun.jini.outrigger
Class TransitionWatchers

java.lang.Object
  extended by com.sun.jini.outrigger.TransitionWatchers

 class TransitionWatchers
extends Object

Given an EntryHandle who's entry is making a visibility transition this class will find all the TransitionWatchers who are interested in that transition. The TransitionWatchers are organized into groups using TemplateHandle. Each TemplateHandle aggregates a number of watchers all interested in the same template.

Author:
Sun Microsystems, Inc.
See Also:
TransitionWatcher

Field Summary
private  Map holders
          A map from class names to WatchersForTemplateClass objects
private  OutriggerServerImpl server
          The server we are working for
 
Constructor Summary
TransitionWatchers(OutriggerServerImpl server)
          Create a new TransitionWatchers object for the specified server.
 
Method Summary
(package private)  void add(TransitionWatcher watcher, EntryRep template)
          Add a TransitionWatcher to the list of watchers looking for visibility transitions in entries that match the specified template.
(package private)  SortedSet allMatches(EntryTransition transition, long ordinal)
          Return a SortedSet of all the TransitionWatcher who's isInterested methods return true when asked about the specified visibility transition.
(package private)  OutriggerServerImpl getServer()
          Return the OutriggerServerImpl this TransitionWatchers object is part of.
(package private)  void reap()
          Visit each TransitionWatcher and check to see if it has expired, removing it if it has.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

holders

private final Map holders
A map from class names to WatchersForTemplateClass objects


server

private final OutriggerServerImpl server
The server we are working for

Constructor Detail

TransitionWatchers

TransitionWatchers(OutriggerServerImpl server)
Create a new TransitionWatchers object for the specified server.

Parameters:
server - The server the new TransitionWatchers object is working for.
Throws:
NullPointerException - if server is null
Method Detail

add

void add(TransitionWatcher watcher,
         EntryRep template)
Add a TransitionWatcher to the list of watchers looking for visibility transitions in entries that match the specified template. Associates a TemplateHandle using TransitionWatcher.setTemplateHandle method.

This method is thread safe. The watcher added in this call is guaranteed to be consulted by the next call to allMatches that starts after this call completes even if that call is made from another thread. Also, all of of the assigned values in the calling thread's working memory will be copied out to main memory as part of the process of making the passed watcher visible to future allMatches and findTransitionWatcher calls.

Parameters:
watcher - The TransitionWatcher being added.
template - The EntryRep that represents the template of interest.
Throws:
NullPointerException - if either argument is null.

allMatches

SortedSet allMatches(EntryTransition transition,
                     long ordinal)
Return a SortedSet of all the TransitionWatcher who's isInterested methods return true when asked about the specified visibility transition.

This method is thread safe. This call is guaranteed to check unremoved watchers that were added by add calls that completed before this call started, even if the calls were made from different threads. Before the isInterested method of the first watcher is called the working memory of this thread will be flushed so any changes made to main memory before this call started will be visible.

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:
A new SortedSet of all the TransitionWatchers interested in the specified visibility transition. If none are interested an empty map will be returned.
Throws:
NullPointerException - if transition is null.

reap

void reap()
Visit each TransitionWatcher and check to see if it has expired, removing it if it has. Also reap the FastLists.


getServer

OutriggerServerImpl getServer()
Return the OutriggerServerImpl this TransitionWatchers object is part of.

Returns:
The OutriggerServerImpl this TransitionWatchers is part of.


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