info.magnolia.cms.filters
Class SafeDestroyMgnlFilterWrapper.Switcher

java.lang.Object
  extended by info.magnolia.cms.filters.SafeDestroyMgnlFilterWrapper.Switcher
Enclosing class:
SafeDestroyMgnlFilterWrapper

public static class SafeDestroyMgnlFilterWrapper.Switcher
extends Object

Construct for keeping a reference to a SafeDestroyMgnlFilterWrapper and change it with the guarantee that the returned previous reference will not get more read locks. It's then safe to destroy the returned reference.

Version:
$Id$

Constructor Summary
SafeDestroyMgnlFilterWrapper.Switcher()
           
 
Method Summary
 SafeDestroyMgnlFilterWrapper getFilter()
          This method is provided for introspection only.
 SafeDestroyMgnlFilterWrapper getFilterAndAcquireReadLock()
          Returns the current filter with a read lock held for the current thread.
 SafeDestroyMgnlFilterWrapper replaceFilter(SafeDestroyMgnlFilterWrapper newFilter)
          Replaces the current filter with a new one and returns the previous filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeDestroyMgnlFilterWrapper.Switcher

public SafeDestroyMgnlFilterWrapper.Switcher()
Method Detail

replaceFilter

public SafeDestroyMgnlFilterWrapper replaceFilter(SafeDestroyMgnlFilterWrapper newFilter)
Replaces the current filter with a new one and returns the previous filter. The returned filter is possibly still in use by currently executing requests but it will not be used by any more requests after this method returns.

Notes about the returned filter:


getFilterAndAcquireReadLock

public SafeDestroyMgnlFilterWrapper getFilterAndAcquireReadLock()
Returns the current filter with a read lock held for the current thread. After use the thread must relinquish the lock by calling releaseReadLock(). If no filter has been set this method returns null and no lock is taken.


getFilter

public SafeDestroyMgnlFilterWrapper getFilter()
This method is provided for introspection only. It is inherently UNSAFE as using this method and then acquiring the read lock on the returned filter breaks the guarantee that a replaced reference wont get more read locks.



Copyright © 2003-2013 Magnolia International Ltd.. All Rights Reserved.