org.ow2.jonas.resource.internal.cm.sql.cache
Class AbstractPreparedStatementCacheImpl

java.lang.Object
  extended by org.ow2.jonas.resource.internal.cm.sql.cache.AbstractPreparedStatementCacheImpl
All Implemented Interfaces:
PreparedStatementCache
Direct Known Subclasses:
PreparedStatementListCacheImpl, PreparedStatementMapCacheImpl

public abstract class AbstractPreparedStatementCacheImpl
extends Object
implements PreparedStatementCache

Abstract class for the prepared statement cache implementation

Author:
pelletib

Field Summary
protected static org.objectweb.util.monolog.api.Logger cacheLogger
          Logger
static String LOCAL_STATISTIC_KEY
          Local statistic key
protected  int maxPstmtCacheSize
          max cache size
protected  int pstmtCacheSize
          current cache size
protected  PreparedStatementCacheStatistics stats
          Statistics
 
Fields inherited from interface org.ow2.jonas.resource.internal.cm.sql.cache.PreparedStatementCache
CACHE_POLICY_LIST, CACHE_POLICY_MAP
 
Constructor Summary
AbstractPreparedStatementCacheImpl(int maxCacheSize, PreparedStatementCacheStatistics pstmtStats, org.objectweb.util.monolog.api.Logger logger)
          Constructor
 
Method Summary
abstract  void close()
          Close logically the cache entries
abstract  void destroy()
          Destroy the cache entries
abstract  PreparedStatementWrapper get(PreparedStatementWrapper psw)
          Retrieve an entry in the cache
 int getMaxPstmtCacheSize()
          Get the max pstmt cache size
 int getPstmtCacheSize()
          Get the current pstmt cache size
abstract  String getState(String prefix)
          Dump the pstmt cache state
abstract  void put(PreparedStatementWrapper psw)
          Add an entry in the cache
abstract  void reallyClose()
          Close really the cache entries
 void setMaxPstmtCacheSize(int maxSize)
          Set the max pstmt cache size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheLogger

protected static org.objectweb.util.monolog.api.Logger cacheLogger
Logger


maxPstmtCacheSize

protected int maxPstmtCacheSize
max cache size


pstmtCacheSize

protected int pstmtCacheSize
current cache size


stats

protected PreparedStatementCacheStatistics stats
Statistics


LOCAL_STATISTIC_KEY

public static String LOCAL_STATISTIC_KEY
Local statistic key

Constructor Detail

AbstractPreparedStatementCacheImpl

public AbstractPreparedStatementCacheImpl(int maxCacheSize,
                                          PreparedStatementCacheStatistics pstmtStats,
                                          org.objectweb.util.monolog.api.Logger logger)
Constructor

Parameters:
maxCacheSize - : max cache size
logger - : logger
Method Detail

get

public abstract PreparedStatementWrapper get(PreparedStatementWrapper psw)
Description copied from interface: PreparedStatementCache
Retrieve an entry in the cache

Specified by:
get in interface PreparedStatementCache
Parameters:
psw - : parameters of the prepared statement to retrieve
Returns:
wrapped prepared statement or null if not found

put

public abstract void put(PreparedStatementWrapper psw)
                  throws CacheException,
                         SQLException
Description copied from interface: PreparedStatementCache
Add an entry in the cache

Specified by:
put in interface PreparedStatementCache
Parameters:
psw - : wrapped prepared statement to add
Throws:
CacheException - no more space in cache
SQLException

setMaxPstmtCacheSize

public final void setMaxPstmtCacheSize(int maxSize)
Set the max pstmt cache size

Specified by:
setMaxPstmtCacheSize in interface PreparedStatementCache
Parameters:
maxSize - The max size to set.

getMaxPstmtCacheSize

public int getMaxPstmtCacheSize()
Get the max pstmt cache size

Specified by:
getMaxPstmtCacheSize in interface PreparedStatementCache
Returns:
Get the max cache size.

getPstmtCacheSize

public int getPstmtCacheSize()
Get the current pstmt cache size

Specified by:
getPstmtCacheSize in interface PreparedStatementCache
Returns:
Get the current cache size.

getState

public abstract String getState(String prefix)
Dump the pstmt cache state

Specified by:
getState in interface PreparedStatementCache
Parameters:
prefix - indentation
Returns:
a string with a cache state (dump)

destroy

public abstract void destroy()
Destroy the cache entries

Specified by:
destroy in interface PreparedStatementCache

reallyClose

public abstract void reallyClose()
Close really the cache entries

Specified by:
reallyClose in interface PreparedStatementCache

close

public abstract void close()
Close logically the cache entries

Specified by:
close in interface PreparedStatementCache


Copyright © 2011 OW2 Consortium. All Rights Reserved.