com.objectwave.persist.sqlConstruction
Class ExpandingSQLObjectCache

java.lang.Object
  |
  +--com.objectwave.persist.sqlConstruction.ExpandingSQLObjectCache

public class ExpandingSQLObjectCache
extends java.lang.Object

Maintain a collection of SQLObject objects. There is a cache per thread. This elminates the need to have synchronized checkin and check out for getting and returning cached objects. Of course, this could pose a problem if one thread checks out objects, and the other returns objects. If that is your situation, an instance of this class must be managed by your application and not via the static methods in this class.

Version:
1.1
Author:
Craig Murphy, Dave Hoag

Constructor Summary
ExpandingSQLObjectCache()
          Initialize this instance to be ready to cache Objects.
 
Method Summary
 SQLObject getSQLObjectFromCacheWork()
          The entry point to the instance related to the current thread, and to get the cached object.
 void returnSQLObjectToCacheWork(SQLObject value)
          Return a checked out instance to this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpandingSQLObjectCache

public ExpandingSQLObjectCache()
Initialize this instance to be ready to cache Objects.

Method Detail

getSQLObjectFromCacheWork

public SQLObject getSQLObjectFromCacheWork()
The entry point to the instance related to the current thread, and to get the cached object. public static SQLObject getSQLObjectFromCache() { ExpandingSQLObjectCache cacheObject = (ExpandingSQLObjectCache) threadContext.get(); if(cacheObject == null) { cacheObject = new ExpandingSQLObjectCache(); threadContext.set(cacheObject); } return cacheObject.getSQLObjectFromCacheWork(); } /** The intended entry point for returning instances. public static final void returnSQLObjectToCache(final SQLObject value ) { ExpandingSQLObjectCache cacheObject = (ExpandingSQLObjectCache) threadContext.get(); if(cacheObject == null) return; cacheObject.returnSQLObjectToCacheWork(value); } /** Get the cached object from this instance of ExpandingSQLObjectCache.


returnSQLObjectToCacheWork

public void returnSQLObjectToCacheWork(SQLObject value)
Return a checked out instance to this cache.

Parameters:
value - ObjectModifed - Hopefully and instance that was obtained via the getSQLObjectCacheWork method.