org.mmbase.cache
Class ReleaseStrategy

java.lang.Object
  extended byorg.mmbase.cache.ReleaseStrategy
Direct Known Subclasses:
BasicReleaseStrategy, BetterStrategy, ChainedReleaseStrategy, ConstraintsMatchingStrategy

public abstract class ReleaseStrategy
extends Object

This class is the base for all cache release strategies. You should extend this to create your own. It will contain a number of usefull utility methods to analyze query objecs and cached search results. Feel free to add those In case you miss one developing your own strategies.

Since:
MMBase-1.8
Version:
$Id: ReleaseStrategy.java,v 1.18 2006/06/28 08:10:59 nklasens Exp $
Author:
Ernst Bunders

Nested Class Summary
static class ReleaseStrategy.StrategyResult
           
protected static class ReleaseStrategy.Timer
           
 
Constructor Summary
ReleaseStrategy()
           
 
Method Summary
 void clear()
           
protected abstract  boolean doEvaluate(NodeEvent event, SearchQuery query, List cachedResult)
          implement this method to create your own strategy.
protected abstract  boolean doEvaluate(RelationEvent event, SearchQuery query, List cachedResult)
          implement this method to create your own strategy.
 boolean equals(Object ob)
           
 ReleaseStrategy.StrategyResult evaluate(NodeEvent event, SearchQuery query, List cachedResult)
          This method checks if evaluation should happen (active), keeps the time of the operation and updates the statistics.
 ReleaseStrategy.StrategyResult evaluate(RelationEvent event, SearchQuery query, List cachedResult)
           
 int getAvgEvaluationTimeInMilis()
           
protected static List getConstraintsForField(String fieldName, MMObjectBuilder builder, Constraint constraint, SearchQuery query)
          utility for specializations: get all the constraints in the query that apply to a certain field
abstract  String getDescription()
           
protected static List getFieldSteps(SearchQuery query)
          utility for specializations: get all the field steps of a query
abstract  String getName()
           
protected static List getSortordersForField(String fieldName, MMObjectBuilder builder, List sortOrders, SearchQuery query)
          utility for specializations: get all the sortorders in the query that apply to a certain field
 int getTotalEvaluated()
           
 long getTotalEvaluationTimeMillis()
           
 int getTotalPreserved()
           
 int hashCode()
           
 boolean isEnabled()
           
 void setEnabled(boolean newStatus)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReleaseStrategy

public ReleaseStrategy()
Method Detail

getName

public abstract String getName()

getDescription

public abstract String getDescription()

getAvgEvaluationTimeInMilis

public int getAvgEvaluationTimeInMilis()

getTotalEvaluationTimeMillis

public long getTotalEvaluationTimeMillis()

evaluate

public final ReleaseStrategy.StrategyResult evaluate(NodeEvent event,
                                                     SearchQuery query,
                                                     List cachedResult)
This method checks if evaluation should happen (active), keeps the time of the operation and updates the statistics. To implement you own strategy override doEvaluate(NodeEvent event, SearchQuery query, List cachedResult).


evaluate

public final ReleaseStrategy.StrategyResult evaluate(RelationEvent event,
                                                     SearchQuery query,
                                                     List cachedResult)

getTotalPreserved

public int getTotalPreserved()

getTotalEvaluated

public int getTotalEvaluated()

doEvaluate

protected abstract boolean doEvaluate(NodeEvent event,
                                      SearchQuery query,
                                      List cachedResult)
implement this method to create your own strategy.

Parameters:
event - a node event
query -
cachedResult -
Returns:
true if the cache entry should be released

doEvaluate

protected abstract boolean doEvaluate(RelationEvent event,
                                      SearchQuery query,
                                      List cachedResult)
implement this method to create your own strategy.

Parameters:
event - a relation event
query -
cachedResult -
Returns:
true if the cache entry should be released

setEnabled

public void setEnabled(boolean newStatus)

isEnabled

public boolean isEnabled()

clear

public void clear()

equals

public boolean equals(Object ob)

hashCode

public int hashCode()

toString

public String toString()

getConstraintsForField

protected static List getConstraintsForField(String fieldName,
                                             MMObjectBuilder builder,
                                             Constraint constraint,
                                             SearchQuery query)
utility for specializations: get all the constraints in the query that apply to a certain field

Parameters:
fieldName -
builder -
constraint -
query -

getSortordersForField

protected static List getSortordersForField(String fieldName,
                                            MMObjectBuilder builder,
                                            List sortOrders,
                                            SearchQuery query)
utility for specializations: get all the sortorders in the query that apply to a certain field

Parameters:
fieldName -
builder -
sortOrders -
query -

getFieldSteps

protected static List getFieldSteps(SearchQuery query)
utility for specializations: get all the field steps of a query

Parameters:
query -


MMBase build 1.8.1.20060716