Package org.apache.torque.manager
Klasse AbstractBaseManager<T extends Persistent>
java.lang.Object
org.apache.torque.manager.AbstractBaseManager<T>
- Typparameter:
T
- the class of the database object managed by this class.
- Alle implementierten Schnittstellen:
Serializable
public abstract class AbstractBaseManager<T extends Persistent>
extends Object
implements Serializable
This class contains common functionality of a Manager for
instantiating OM's.
- Version:
- $Id: AbstractBaseManager.java 1917245 2024-04-21 14:06:23Z tv $
- Autor:
- John McNally
- Siehe auch:
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungused to cache the om objects. cache is set by the region propertyprotected org.apache.commons.jcs3.access.GroupCacheAccess<MethodCacheKey,
Object> used to cache the method result objects. cache is set by the region propertyprotected static final org.apache.logging.log4j.Logger
the logprotected MethodResultCache
method results cache -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
addCacheListenerImpl
(CacheListener<?> listener) Add a new listenerprotected void
addValidField
(Column... columns) Add variable number of fields to the list potentially monitored by a listenerprotected T
Get an object from cacheprotected void
Clears the cachevoid
dispose()
Disposes of the manager.Get the classname to instantiate for getInstance()Get the object usable for result cachingGet the Class instanceprotected T
Get a fresh instance of an omprotected T
getOMInstance
(ObjectKey<?> id) Return an instance of an om based on the idprotected T
getOMInstance
(ObjectKey<?> key, boolean fromCache) Return an instance of an om based on the idGets a list of om's based on id's.Gets a list of om's based on id's.Gets a list of om's based on id's.Get the cache region used for JCS.protected <TT extends Persistent>
voidnotifyListeners
(Column column, TT oldOm, TT om) Notify all listeners associated to the column that an object has changedprotected T
putInstanceImpl
(ObjectKey<?> key, T om) Put an object into the cacheprotected T
putInstanceImpl
(T om) Put an object into the cacheprotected void
NoOp version.protected T
removeInstanceImpl
(ObjectKey<?> key) Remove an object from the cacheprotected abstract T
retrieveStoredOM
(ObjectKey<?> id) Retrieve an object from persistent storageretrieveStoredOMs
(List<? extends ObjectKey<?>> ids) Gets a list of om's based on id's.void
Set the classname to instantiate for getInstance()protected void
setOMClass
(Class<T> omClass) Set the Class that will be instantiated by this managervoid
Set the cache region used for JCS.
-
Felddetails
-
log
protected static final org.apache.logging.log4j.Logger logthe log -
cache
protected transient org.apache.commons.jcs3.access.CacheAccess<ObjectKey<?>,T extends Persistent> cacheused to cache the om objects. cache is set by the region property -
groupCache
protected transient org.apache.commons.jcs3.access.GroupCacheAccess<MethodCacheKey,Object> groupCacheused to cache the method result objects. cache is set by the region property -
mrCache
method results cache
-
-
Konstruktordetails
-
AbstractBaseManager
public AbstractBaseManager()
-
-
Methodendetails
-
getOMClass
Get the Class instance- Gibt zurück:
- the om class
-
setOMClass
Set the Class that will be instantiated by this manager- Parameter:
omClass
- the om class
-
addValidField
Add variable number of fields to the list potentially monitored by a listener- Parameter:
columns
- array of columns
-
getOMInstance
Get a fresh instance of an om- Gibt zurück:
- an instance of the om class
- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getClassName
Get the classname to instantiate for getInstance()- Gibt zurück:
- value of className.
-
setClassName
Set the classname to instantiate for getInstance()- Parameter:
v
- Value to assign to className.- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getOMInstance
Return an instance of an om based on the id- Parameter:
id
- the primary key of the object- Gibt zurück:
- the object from persistent storage or from cache
- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getOMInstance
Return an instance of an om based on the id- Parameter:
key
- the primary key of the objectfromCache
- true if the object should be retrieved from cache- Gibt zurück:
- the object from persistent storage or from cache
- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
cacheGet
Get an object from cache- Parameter:
key
- the primary key of the object- Gibt zurück:
- the object from cache
-
clearImpl
Clears the cache- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
dispose
public void dispose()Disposes of the manager. 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
Remove an object from the cache- Parameter:
key
- the cache key for the object- Gibt zurück:
- the object one last time
- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
putInstanceImpl
Put an object into the cache- Parameter:
om
- the object- Gibt zurück:
- if an object with the same key already is in the cache this object will be returned, else null
- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
putInstanceImpl
Put an object into the cache- Parameter:
key
- the cache key for the objectom
- the object- Gibt zurück:
- if an object with this key already is in the cache this object will be returned, else null
- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
retrieveStoredOM
Retrieve an object from persistent storage- Parameter:
id
- the primary key of the object- Gibt zurück:
- the object
- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getOMs
Gets a list of om's based on id's.- Parameter:
ids
- a number of object ids- Gibt zurück:
- a
List
of objects - Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getOMs
Gets a list of om's based on id's.- Parameter:
ids
- aList
ofObjectKey
's- Gibt zurück:
- a
List
value - Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getOMs
protected List<T> getOMs(List<? extends ObjectKey<?>> ids, boolean fromCache) throws TorqueException Gets a list of om's based on id's.- Parameter:
ids
- aList
ofObjectKey
's.fromCache
- boolean flag if we are to use the cache- Gibt zurück:
- a
List
value, not null. - Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
retrieveStoredOMs
protected abstract List<T> retrieveStoredOMs(List<? extends ObjectKey<?>> ids) throws TorqueException Gets a list of om's based on id's. This method must be implemented in the derived class- Parameter:
ids
- aList
ofObjectKey
's- Gibt zurück:
- a
List
value - Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getRegion
Get the cache region used for JCS.- Gibt zurück:
- the cache region used for JCS.
-
setRegion
Set the cache region used for JCS.- Parameter:
v
- Value to assign to region.- Löst aus:
TorqueException
- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-
getMethodResultCache
Get the object usable for result caching- Gibt zurück:
- 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
Add a new listener- Parameter:
listener
- A new listener for cache events.
-
notifyListeners
Notify all listeners associated to the column that an object has changed- Typparameter:
TT
- column type class- Parameter:
column
- the column related to the listenersoldOm
- the previous object, null if the object has been addedom
- the new object, null if the object has been removed
-