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:
  • Felddetails

    • log

      protected static final org.apache.logging.log4j.Logger log
      the log
    • cache

      protected transient org.apache.commons.jcs3.access.CacheAccess<ObjectKey<?>,T extends Persistent> cache
      used to cache the om objects. cache is set by the region property
    • groupCache

      protected transient org.apache.commons.jcs3.access.GroupCacheAccess<MethodCacheKey,Object> groupCache
      used to cache the method result objects. cache is set by the region property
    • mrCache

      protected transient MethodResultCache mrCache
      method results cache
  • Konstruktordetails

    • AbstractBaseManager

      public AbstractBaseManager()
  • Methodendetails

    • getOMClass

      protected Class<T> getOMClass()
      Get the Class instance
      Gibt zurück:
      the om class
    • setOMClass

      protected void setOMClass(Class<T> omClass)
      Set the Class that will be instantiated by this manager
      Parameter:
      omClass - the om class
    • addValidField

      protected void addValidField(Column... columns)
      Add variable number of fields to the list potentially monitored by a listener
      Parameter:
      columns - array of columns
    • getOMInstance

      protected T getOMInstance() throws TorqueException
      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

      public String getClassName()
      Get the classname to instantiate for getInstance()
      Gibt zurück:
      value of className.
    • setClassName

      public void setClassName(String v) throws TorqueException
      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

      protected T getOMInstance(ObjectKey<?> id) throws TorqueException
      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

      protected T getOMInstance(ObjectKey<?> key, boolean fromCache) throws TorqueException
      Return an instance of an om based on the id
      Parameter:
      key - the primary key of the object
      fromCache - 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

      protected T cacheGet(ObjectKey<?> key)
      Get an object from cache
      Parameter:
      key - the primary key of the object
      Gibt zurück:
      the object from cache
    • clearImpl

      protected void clearImpl() throws TorqueException
      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

      protected T removeInstanceImpl(ObjectKey<?> key) throws TorqueException
      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

      protected T putInstanceImpl(T om) throws TorqueException
      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

      protected T putInstanceImpl(ObjectKey<?> key, T om) throws TorqueException
      Put an object into the cache
      Parameter:
      key - the cache key for the object
      om - 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

      protected abstract T retrieveStoredOM(ObjectKey<?> id) throws TorqueException
      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

      protected List<T> getOMs(ObjectKey<?>... ids) throws TorqueException
      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

      protected List<T> getOMs(List<? extends ObjectKey<?>> ids) throws TorqueException
      Gets a list of om's based on id's.
      Parameter:
      ids - a List of ObjectKey'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 - a List of ObjectKey'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 - a List of ObjectKey's
      Gibt zurück:
      a List value
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • getRegion

      public String getRegion()
      Get the cache region used for JCS.
      Gibt zurück:
      the cache region used for JCS.
    • setRegion

      public void setRegion(String v) throws TorqueException
      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

      public MethodResultCache 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

      public void addCacheListenerImpl(CacheListener<?> listener)
      Add a new listener
      Parameter:
      listener - A new listener for cache events.
    • notifyListeners

      protected <TT extends Persistent> void notifyListeners(Column column, TT oldOm, TT om)
      Notify all listeners associated to the column that an object has changed
      Typparameter:
      TT - column type class
      Parameter:
      column - the column related to the listeners
      oldOm - the previous object, null if the object has been added
      om - the new object, null if the object has been removed