Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.ibatis.sqlmap.engine.cache
Class CacheModel  view CacheModel download CacheModel.java

java.lang.Object
  extended bycom.ibatis.sqlmap.engine.cache.CacheModel
All Implemented Interfaces:
com.ibatis.sqlmap.engine.mapping.statement.ExecuteListener

public class CacheModel
extends java.lang.Object
implements com.ibatis.sqlmap.engine.mapping.statement.ExecuteListener


Field Summary
private  CacheController controller
           
private  long flushInterval
           
private  long flushIntervalSeconds
           
private  java.util.Set flushTriggerStatements
           
private  int hits
           
private  java.lang.String id
           
private  long lastFlush
           
private static java.util.Map lockMap
           
private static long NO_FLUSH_INTERVAL
          Constant to turn off periodic cache flushes
static java.lang.Object NULL_OBJECT
          This is used to represent null objects that are returned from the cache so that they can be cached, too.
private  boolean readOnly
           
private  int requests
           
private  java.lang.String resource
           
private  boolean serialize
           
private  java.lang.Object STATS_LOCK
           
 
Constructor Summary
CacheModel()
          Default constructor
 
Method Summary
 void addFlushTriggerStatement(java.lang.String statementName)
          Adds a flushTriggerStatment.
 void configure(java.util.Properties props)
          Configures the cache
 void flush()
          Clears the cache
 long getFlushInterval()
          Getter for flushInterval property
 long getFlushIntervalSeconds()
          Getter for flushInterval property
 java.util.Iterator getFlushTriggerStatementNames()
          Gets an Iterator containing all flushTriggerStatment objects for this cache.
 double getHitRatio()
          Returns statistical information about the cache.
 java.lang.String getId()
          Getter for the cache model's id
 java.lang.Object getLock(CacheKey key)
          OK, honestly, i have no idea what this does.
 java.lang.Object getObject(CacheKey key)
          Get an object out of the cache.
 java.lang.String getResource()
          Getter for resource property
 boolean isReadOnly()
          Getter for read-only property
 boolean isSerialize()
          Getter to tell if the cache serializes
 void onExecuteStatement(com.ibatis.sqlmap.engine.mapping.statement.MappedStatement statement)
          ExecuteListener event.
 void putObject(CacheKey key, java.lang.Object value)
          Add an object to the cache
 void setControllerClassName(java.lang.String implementation)
          Sets up the controller for the cache model
 void setFlushInterval(long flushInterval)
          Setter for flushInterval property
 void setId(java.lang.String id)
          Setter for the cache model's id
 void setReadOnly(boolean readOnly)
          Setter for read-only property
 void setResource(java.lang.String resource)
          Setter for resource property
 void setSerialize(boolean serialize)
          Setter to tell the cache to serialize objects
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockMap

private static final java.util.Map lockMap

NULL_OBJECT

public static final java.lang.Object NULL_OBJECT
This is used to represent null objects that are returned from the cache so that they can be cached, too.


STATS_LOCK

private final java.lang.Object STATS_LOCK

requests

private int requests

hits

private int hits

NO_FLUSH_INTERVAL

private static final long NO_FLUSH_INTERVAL
Constant to turn off periodic cache flushes

See Also:
Constant Field Values

id

private java.lang.String id

readOnly

private boolean readOnly

serialize

private boolean serialize

lastFlush

private long lastFlush

flushInterval

private long flushInterval

flushIntervalSeconds

private long flushIntervalSeconds

flushTriggerStatements

private java.util.Set flushTriggerStatements

controller

private CacheController controller

resource

private java.lang.String resource
Constructor Detail

CacheModel

public CacheModel()
Default constructor

Method Detail

getId

public java.lang.String getId()
Getter for the cache model's id


setId

public void setId(java.lang.String id)
Setter for the cache model's id


isReadOnly

public boolean isReadOnly()
Getter for read-only property


setReadOnly

public void setReadOnly(boolean readOnly)
Setter for read-only property


isSerialize

public boolean isSerialize()
Getter to tell if the cache serializes


setSerialize

public void setSerialize(boolean serialize)
Setter to tell the cache to serialize objects


getResource

public java.lang.String getResource()
Getter for resource property


setResource

public void setResource(java.lang.String resource)
Setter for resource property


setControllerClassName

public void setControllerClassName(java.lang.String implementation)
                            throws java.lang.ClassNotFoundException,
                                   java.lang.InstantiationException,
                                   java.lang.IllegalAccessException
Sets up the controller for the cache model


getFlushInterval

public long getFlushInterval()
Getter for flushInterval property


getFlushIntervalSeconds

public long getFlushIntervalSeconds()
Getter for flushInterval property


setFlushInterval

public void setFlushInterval(long flushInterval)
Setter for flushInterval property


addFlushTriggerStatement

public void addFlushTriggerStatement(java.lang.String statementName)
Adds a flushTriggerStatment. When a flushTriggerStatment is executed, the cache is flushed (cleared).


getFlushTriggerStatementNames

public java.util.Iterator getFlushTriggerStatementNames()
Gets an Iterator containing all flushTriggerStatment objects for this cache.


onExecuteStatement

public void onExecuteStatement(com.ibatis.sqlmap.engine.mapping.statement.MappedStatement statement)
ExecuteListener event. This will be called by a MappedStatement for which this cache is registered as a ExecuteListener. It will be called each time an executeXXXXXX method is called. In the case of the Cache class, it is registered in order to flush the cache whenever a certain statement is executed. (i.e. the flushOnExecute cache policy)

Specified by:
onExecuteStatement in interface com.ibatis.sqlmap.engine.mapping.statement.ExecuteListener

getHitRatio

public double getHitRatio()
Returns statistical information about the cache.


configure

public void configure(java.util.Properties props)
Configures the cache


flush

public void flush()
Clears the cache


getObject

public java.lang.Object getObject(CacheKey key)
Get an object out of the cache. A side effect of this method is that is may clear the cache if it has not been cleared in the flushInterval.


putObject

public void putObject(CacheKey key,
                      java.lang.Object value)
Add an object to the cache


getLock

public final java.lang.Object getLock(CacheKey key)
OK, honestly, i have no idea what this does.