net.sourceforge.jtds.jdbc.cache
Class AbstractStatementCache

java.lang.Object
  |
  +--net.sourceforge.jtds.jdbc.cache.AbstractStatementCache
All Implemented Interfaces:
StatementCache
Direct Known Subclasses:
DefaultStatementCache

abstract class AbstractStatementCache
extends java.lang.Object
implements StatementCache

Provides a base implementation for other caches. Statement handle latching is one of the services provided by this class.

Version:
$Id: AbstractStatementCache.java,v 1.3 2004/10/25 19:33:40 bheineman Exp $
Author:
Brian Heineman

Field Summary
private static java.lang.Integer INTEGER_ONE
           
private  java.util.HashMap latches
          A map of statement handle latches and the associated latch count.
protected  int maximumCacheTarget
          An integer representing the maximum cache size.
 
Constructor Summary
protected AbstractStatementCache(int maximumCacheTarget)
          Initializes the maximumCacheTarget.
 
Method Summary
protected  boolean isLatched(java.lang.Object handle)
          Returns true if there are latches for the given statement handle.
protected  void latch(java.lang.Object handle)
          Adds a single latch to the given statement handle.
protected  void removeLatches(java.lang.Object handle)
          Removes all latches from the given statement handle.
protected  void unlatch(java.util.Collection handles)
          Removes a single latch from each handle in the Collection.
protected  void unlatch(java.lang.Object handle)
          Removes a single latch from the given statement handle.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.jtds.jdbc.cache.StatementCache
get, getObsoleteHandles, put, remove
 

Field Detail

INTEGER_ONE

private static final java.lang.Integer INTEGER_ONE

maximumCacheTarget

protected int maximumCacheTarget
An integer representing the maximum cache size. This value is only a target and may be exceeded by a specific caching implementation. However, each cache implementation must make a "best effort" to adhere to this maximum cache limit.

latches

private java.util.HashMap latches
A map of statement handle latches and the associated latch count. Latches provide a mechanism for registering use of a statement handle and preventing a handle from being removed from the cache prematurely. In general, specific cache implementations should add a latch or increment an existing latch count for a statement key when StatementCache.put(java.lang.String, java.lang.Object) is called. Conversely, the latch for a statement handles should be removed of decremented when StatementCache.getObsoleteHandles(java.util.Collection) is called.
Constructor Detail

AbstractStatementCache

protected AbstractStatementCache(int maximumCacheTarget)
Initializes the maximumCacheTarget.
Parameters:
maximumCacheTarget - an integer representing the maximum cache size.
Method Detail

latch

protected void latch(java.lang.Object handle)
Adds a single latch to the given statement handle.
Parameters:
handle - the statement handle to add a single latch for.

unlatch

protected void unlatch(java.util.Collection handles)
Removes a single latch from each handle in the Collection.
Parameters:
handles - the statement handles to remove a single latch from.

unlatch

protected void unlatch(java.lang.Object handle)
Removes a single latch from the given statement handle.
Parameters:
handle - the statement handle to remove a single latch from.

removeLatches

protected void removeLatches(java.lang.Object handle)
Removes all latches from the given statement handle.
Parameters:
handle - the statement handle to remove all latches from.

isLatched

protected boolean isLatched(java.lang.Object handle)
Returns true if there are latches for the given statement handle.
Parameters:
handle - the statement handle to check the latch status of.
Returns:
true if there are latches for the given statement handle; false otherwise.


Generated on April 15 2005