org.jboss.cache.eviction
Class BaseEvictionPolicy

java.lang.Object
  extended by org.jboss.cache.eviction.BaseEvictionPolicy
All Implemented Interfaces:
EvictionPolicy
Direct Known Subclasses:
FIFOPolicy, LFUPolicy, LRUPolicy, MRUPolicy

public abstract class BaseEvictionPolicy
extends java.lang.Object
implements EvictionPolicy

Base class implementation of EvictionPolicy and TreeCacheListener.

Version:
$Revision: 1.3 $
Author:
Ben Wang 2-2004, Daniel Huang - dhuang@jboss.org

Field Summary
protected  TreeCache cache_
           
 
Constructor Summary
BaseEvictionPolicy()
           
 
Method Summary
 boolean canIgnoreEvent(Fqn fqn)
          This method will be invoked prior to an event being processed for a node with the specified Fqn.
 void configure(TreeCache cache)
          Method called to configure this implementation.
 void evict(Fqn fqn)
          Evict the node under given Fqn from cache.
 java.lang.Object getCacheData(Fqn fqn, java.lang.Object key)
           
 java.util.Set getChildrenNames(Fqn fqn)
          Return a set of child names under a given Fqn.
 boolean hasChild(Fqn fqn)
          Is this a leaf node?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.eviction.EvictionPolicy
getEvictionAlgorithm, getEvictionConfigurationClass
 

Field Detail

cache_

protected TreeCache cache_
Constructor Detail

BaseEvictionPolicy

public BaseEvictionPolicy()
Method Detail

evict

public void evict(Fqn fqn)
           throws java.lang.Exception
Evict the node under given Fqn from cache.

Specified by:
evict in interface EvictionPolicy
Parameters:
fqn - The fqn of a node in cache.
Throws:
java.lang.Exception

getChildrenNames

public java.util.Set getChildrenNames(Fqn fqn)
Return a set of child names under a given Fqn.

Specified by:
getChildrenNames in interface EvictionPolicy
Parameters:
fqn - Get child names for given Fqn in cache.
Returns:
Set of children name as Objects

hasChild

public boolean hasChild(Fqn fqn)
Description copied from interface: EvictionPolicy
Is this a leaf node?

Specified by:
hasChild in interface EvictionPolicy
Returns:
true/false if leaf node.

getCacheData

public java.lang.Object getCacheData(Fqn fqn,
                                     java.lang.Object key)
Specified by:
getCacheData in interface EvictionPolicy

configure

public void configure(TreeCache cache)
Description copied from interface: EvictionPolicy
Method called to configure this implementation.

Specified by:
configure in interface EvictionPolicy

canIgnoreEvent

public boolean canIgnoreEvent(Fqn fqn)
Description copied from interface: EvictionPolicy
This method will be invoked prior to an event being processed for a node with the specified Fqn.

This method provides a way to optimize the performance of eviction by signalling that the node associated with the specified Fqn should not be subject to normal eviction processing.

If this method returns false then then event is processed normally and eviction processing for the node continues. As a result, EvictionPolicy.evict() may be invoked at some later point based on the particular algorirthm of the eviction policy.

If this method returns true, then the event is ignored and eviction processing is bypassed for this node. As a result, EvictionPolicy.evict() will never be invoked for this node.

Specified by:
canIgnoreEvent in interface EvictionPolicy
Parameters:
fqn - The Fqn of the node associated with the event.
Returns:
true to ignore events for this Fqn. false to process events normally.


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.