info.magnolia.module.cache
Class AbstractListeningFlushPolicy

java.lang.Object
  extended by info.magnolia.module.cache.AbstractListeningFlushPolicy
All Implemented Interfaces:
FlushPolicy
Direct Known Subclasses:
FlushAllListeningPolicy

public abstract class AbstractListeningFlushPolicy
extends Object
implements FlushPolicy

Implemenation of the FlushPolicy providing functionality for triggering flush operation based on changes in observed repositories.

Version:
$Revision: $ ($Author: $)
Author:
gjoseph

Nested Class Summary
protected  class AbstractListeningFlushPolicy.CacheCleaner
          Event listener triggering the cleanup of the cache.
 
Constructor Summary
AbstractListeningFlushPolicy()
           
 
Method Summary
 void addRepository(String repository)
           
protected  void flushByUUID(String uuid, String repository, Cache cache)
          Flushes all content related to given uuid&repository combination from provided cache.
 List getRepositories()
          The repositories to which the listener is attached - upon any event on these, the cache is cleared.
protected abstract  void handleSingleEvent(Cache cache, String repository, javax.jcr.observation.Event event)
          Implement this method to react on each and every event on a given cache and repository, even if multiple where buffered.
protected abstract  void postHandleEvents(Cache cache, String repository)
          Implement this method to wrap up flushing process after all single events have been processed.
protected abstract  boolean preHandleEvents(Cache cache, String repository)
          Implement this method to react on buffered events on a given cache and repository.
 void setRepositories(List repositories)
           
 void start(Cache cache)
           
 void stop(Cache cache)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractListeningFlushPolicy

public AbstractListeningFlushPolicy()
Method Detail

getRepositories

public List getRepositories()
The repositories to which the listener is attached - upon any event on these, the cache is cleared.


setRepositories

public void setRepositories(List repositories)

addRepository

public void addRepository(String repository)

start

public void start(Cache cache)
Specified by:
start in interface FlushPolicy

stop

public void stop(Cache cache)
Specified by:
stop in interface FlushPolicy

preHandleEvents

protected abstract boolean preHandleEvents(Cache cache,
                                           String repository)
Implement this method to react on buffered events on a given cache and repository.

Returns:
true if single events should be processed as well, false otherwise.

postHandleEvents

protected abstract void postHandleEvents(Cache cache,
                                         String repository)
Implement this method to wrap up flushing process after all single events have been processed. This method will be invoked only if preHandleEvents(Cache, String) returns true;


handleSingleEvent

protected abstract void handleSingleEvent(Cache cache,
                                          String repository,
                                          javax.jcr.observation.Event event)
Implement this method to react on each and every event on a given cache and repository, even if multiple where buffered. This method will be invoked only if preHandleEvents(Cache, String) returns true;


flushByUUID

protected void flushByUUID(String uuid,
                           String repository,
                           Cache cache)
Flushes all content related to given uuid&repository combination from provided cache. Note that more then only one pages can be flushed when this method is called.

Parameters:
uuid -


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