org.apache.torque.manager
Class AbstractBaseManager

java.lang.Object
  extended by org.apache.torque.manager.AbstractBaseManager
All Implemented Interfaces:
java.io.Serializable

public abstract class AbstractBaseManager
extends java.lang.Object
implements java.io.Serializable

This class contains common functionality of a Manager for instantiating OM's.

Version:
$Id: AbstractBaseManager.java 571790 2007-09-01 12:40:44Z tv $
Author:
John McNally
See Also:
Serialized Form

Field Summary
protected  org.apache.jcs.access.GroupCacheAccess cache
          used to cache the om objects.
protected  java.util.Map listenersMap
           
protected static org.apache.commons.logging.Log log
          the log
protected  MethodResultCache mrCache
          method results cache
protected  java.util.Map validFields
           
 
Constructor Summary
AbstractBaseManager()
           
 
Method Summary
 void addCacheListenerImpl(CacheListener listener)
           
protected  Persistent cacheGet(java.io.Serializable key)
          Get an object from cache
protected  void clearImpl()
          Clears the cache
 void dispose()
          Disposes of the cache.
 java.lang.String getClassName()
          Get the classname to instantiate for getInstance()
 MethodResultCache getMethodResultCache()
           
protected  java.lang.Class getOMClass()
          Get the Class instance
protected  Persistent getOMInstance()
          Get a fresh instance of an om
protected  Persistent getOMInstance(ObjectKey id)
          Return an instance of an om based on the id
protected  Persistent getOMInstance(ObjectKey key, boolean fromCache)
          Return an instance of an om based on the id
protected  java.util.List getOMs(java.util.List ids)
          Gets a list of om's based on id's.
protected  java.util.List getOMs(java.util.List ids, boolean fromCache)
          Gets a list of om's based on id's.
protected  java.util.List getOMs(ObjectKey[] ids)
          Gets a list of om's based on id's.
 java.lang.String getRegion()
          Get the value of region.
protected  void notifyListeners(java.util.List listeners, Persistent oldOm, Persistent om)
           
protected  Persistent putInstanceImpl(Persistent om)
          Put an object into the cache
protected  Persistent putInstanceImpl(java.io.Serializable key, Persistent om)
          Put an object into the cache
protected  void registerAsListener()
          NoOp version.
protected  Persistent removeInstanceImpl(java.io.Serializable key)
          Remove an object from the cache
protected abstract  Persistent retrieveStoredOM(ObjectKey id)
          Retrieve an object from persistent storage
protected abstract  java.util.List retrieveStoredOMs(java.util.List ids)
          Gets a list of om's based on id's.
 void setClassName(java.lang.String v)
          Set the classname to instantiate for getInstance()
protected  void setOMClass(java.lang.Class omClass)
          Set the Class that will be instantiated by this manager
 void setRegion(java.lang.String v)
          Set the value of region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
the log


cache

protected transient org.apache.jcs.access.GroupCacheAccess cache
used to cache the om objects. cache is set by the region property


mrCache

protected MethodResultCache mrCache
method results cache


validFields

protected java.util.Map validFields

listenersMap

protected java.util.Map listenersMap
Constructor Detail

AbstractBaseManager

public AbstractBaseManager()
Method Detail

getOMClass

protected java.lang.Class getOMClass()
Get the Class instance

Returns:
the om class

setOMClass

protected void setOMClass(java.lang.Class omClass)
Set the Class that will be instantiated by this manager

Parameters:
omClass - the om class

getOMInstance

protected Persistent getOMInstance()
                            throws java.lang.InstantiationException,
                                   java.lang.IllegalAccessException
Get a fresh instance of an om

Returns:
an instance of the om class
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

getClassName

public java.lang.String getClassName()
Get the classname to instantiate for getInstance()

Returns:
value of className.

setClassName

public void setClassName(java.lang.String v)
                  throws TorqueException
Set the classname to instantiate for getInstance()

Parameters:
v - Value to assign to className.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getOMInstance

protected Persistent getOMInstance(ObjectKey id)
                            throws TorqueException
Return an instance of an om based on the id

Parameters:
id - the primary key of the object
Returns:
the object from persistent storage or from cache
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getOMInstance

protected Persistent getOMInstance(ObjectKey key,
                                   boolean fromCache)
                            throws TorqueException
Return an instance of an om based on the id

Parameters:
key - the primary key of the object
fromCache - true if the object should be retrieved from cache
Returns:
the object from persistent storage or from cache
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

cacheGet

protected Persistent cacheGet(java.io.Serializable key)
Get an object from cache

Parameters:
key - the primary key of the object
Returns:
the object from cache

clearImpl

protected void clearImpl()
                  throws TorqueException
Clears the cache

Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

dispose

public void dispose()
Disposes of the cache. This triggers a shutdown of the connected cache instances. This method should only be used during shutdown of Torque. The manager instance will not cache anymore after this call.


removeInstanceImpl

protected Persistent removeInstanceImpl(java.io.Serializable key)
                                 throws TorqueException
Remove an object from the cache

Parameters:
key - the cache key for the object
Returns:
the object one last time
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

putInstanceImpl

protected Persistent putInstanceImpl(Persistent om)
                              throws TorqueException
Put an object into the cache

Parameters:
om - the object
Returns:
if an object with the same key already is in the cache this object will be returned, else null
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

putInstanceImpl

protected Persistent putInstanceImpl(java.io.Serializable key,
                                     Persistent om)
                              throws TorqueException
Put an object into the cache

Parameters:
key - the cache key for the object
om - the object
Returns:
if an object with this key already is in the cache this object will be returned, else null
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

retrieveStoredOM

protected abstract Persistent retrieveStoredOM(ObjectKey id)
                                        throws TorqueException
Retrieve an object from persistent storage

Parameters:
id - the primary key of the object
Returns:
the object
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getOMs

protected java.util.List getOMs(ObjectKey[] ids)
                         throws TorqueException
Gets a list of om's based on id's.

Parameters:
ids - a ObjectKey[] value
Returns:
a List value
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getOMs

protected java.util.List getOMs(java.util.List ids)
                         throws TorqueException
Gets a list of om's based on id's.

Parameters:
ids - a List of ObjectKey's
Returns:
a List value
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getOMs

protected java.util.List getOMs(java.util.List ids,
                                boolean fromCache)
                         throws TorqueException
Gets a list of om's based on id's.

Parameters:
ids - a List of ObjectKey's
Returns:
a List value
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

retrieveStoredOMs

protected abstract java.util.List retrieveStoredOMs(java.util.List ids)
                                             throws TorqueException
Gets a list of om's based on id's. This method must be implemented in the drived class

Parameters:
ids - a List of ObjectKey's
Returns:
a List value
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getRegion

public java.lang.String getRegion()
Get the value of region.

Returns:
value of region.

setRegion

public void setRegion(java.lang.String v)
               throws TorqueException
Set the value of region.

Parameters:
v - Value to assign to region.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

getMethodResultCache

public MethodResultCache getMethodResultCache()
Returns:
The cache instance.

registerAsListener

protected void registerAsListener()
NoOp version. Managers should override this method to notify other managers that they are interested in CacheEvents.


addCacheListenerImpl

public void addCacheListenerImpl(CacheListener listener)
Parameters:
listener - A new listener for cache events.

notifyListeners

protected void notifyListeners(java.util.List listeners,
                               Persistent oldOm,
                               Persistent om)
Parameters:
listeners -
oldOm -
om -


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.