As explained in org.exolab.castor.jdo.persist, LockEngine implements a persistence engine that caches objects in memory for performance reasons and thus eliminates the number of operations against the persistence storage.
See: Description
Interface Summary | |
---|---|
Cache | Interface specification for performance caches as used in Castor. |
CacheFactory | A factory for instantiating Cache implementations. |
Class Summary | |
---|---|
AbstractBaseCache | Base implementation of all LRU cache types. |
AbstractCacheFactory | Base implementation of CacheFactory. |
CacheAcquireException | Exception that indicates that a performance cache instance can not be acquired. |
CacheRegistry | Registry for CacheFactory implementations obtained from the Castor properties file and used by the JDO mapping configuration file. |
CountLimited | CustomCache is a count limted least-recently-used Map. |
CountLimitedFactory | Implements CacheFactory for CustomCache. |
InvalidCacheTypeException | Exception that indicates that an invalid cache type has been specified. |
MethodNotImplementedException | Exception specific to Castor JDO cache implementations. |
NoCache | NoCache is a Map which dispose all object right the way. |
NoCacheFactory | Implements CacheFactory for the NoCache implementation of Cache. |
TimeLimited | TimeLimited is a time limted least-recently-used Map. |
TimeLimitedFactory | Implements CacheFactory for the TimeLimited implementation of Cache. |
Unlimited | UnLimited is Map which implements the Unlimited interface. |
UnlimitedFactory | Implements CacheFactory for the Unlimited implementation of Cache. |
As explained in org.exolab.castor.jdo.persist, LockEngine implements a persistence engine that caches objects in memory for performance reasons and thus eliminates the number of operations against the persistence storage.
The main component of this package is the interface Cache.java, which declares the external functionality of a performance cache. Existing (and future) cache engines have to implement this interface, which is closely modelled after java.util.Map. To obtain an instance of a particular cache engine (from client code), client code is instructed to use CacheRegistry and its factory methods.
The remainder of this package are exceptions associated with cache interaction, an enumeration of all (currently) available cache types and a prototype for an (abstract) base class to assist future cache engine additions.
Castor (as of release 0.9.6) allows for addition of user-defined cache implementations.
By default, the file castor.properties includes a section as follows:
# # Cache implementations # org.exolab.castor.jdo.cacheFactories=\ org.exolab.castor.persist.cache.NoCacheFactory,\ org.exolab.castor.persist.cache.TimeLimitedFactory,\ org.exolab.castor.persist.cache.CountLimitedFactory,\ org.exolab.castor.persist.cache.UnlimitedFactory
To add your own performance cache implementation, please append the fully-qualified class name to this list as shown here:
# # Cache implementations # org.exolab.castor.jdo.cacheFactories=\ org.exolab.castor.persist.cache.NoCacheFactory,\ org.exolab.castor.persist.cache.TimeLimitedFactory,\ org.exolab.castor.persist.cache.CountLimitedFactory,\ org.exolab.castor.persist.cache.UnlimitedFactory,\ org.whatever.somewhere.nevermind.CustomCache
In addition, you will have to provide the cache implementation and a CacheFactory implementation for your new cache instance. For this, please add an implementation of CacheFactory and make sure that you provide valid values for the two properties name and className.
To assist users in this task, a AbstractCacheFactory class has been supplied, which users should derive their custom CacheFactory instances from, if they wish so. Please consult existing CacheFactory implementations such as TimeLimitedFactory or CountLimitedFactory for code samples.
/** * My own cache implementation */ public class CustomCache extends AbstractBaseCache { ... }
/** * My own cache factory implementation */ public class CustomCacheFactory extends AbstractCacheFactory { /** * The name of the factory */ private static final String NAME = "custom"; /** * Full class name of the underlying cache implementation. */ private static final String CLASS_NAME = "my.company.project.CustomCache"; /** * Returns the short alias for this factory instance. * @return The short alias name. */ public String getName() { return NAME; } /** * Returns the full class name of the underlying cache implementation. * @return The full cache class name. */ public String getCacheClassName() { return CLASS_NAME; } }