public interface CacheProvider
Dynacache is the default cache provider for the WebSphere Application Server. This interface is used to provide an alternate cache provider for a cache instance, and provides the methods necessary to properly interact with the WebSpehre Application Server.
The same cache provider must be configured for a cache instance across all the members of a cluster in a ND environment. Each cache instance must be configured with a cache provider. If a provider is not explicitly specified using the techniques described below, the default Dynacache cache provider is used.
There are two ways of packaging a cache provider to make it available to the WebSphere Application Server:
@since WAS 7.0.0.0
OSGI Bundle
A bundle is a software module packaged as a JAR. The bundle adheres to the JAR specification,
but also contains additional metadata as defined by the OSGi specification.
Among other things, a bundle's manifest contains lists of packages to be exported from the bundle
and imported into the bundle. For further details, refer to http://www.osgi.org.
The cache provider bundle should define an extension for the com.ibm.wsspi.extension.cache-provider
extension point. The plugin.xml of the cache provider bundle must contain a stanza similar to:
<extension id="cache-provider" point="com.ibm.wsspi.extension.cache-provider">
<cache-provider name="ObjectGrid" class="com.companyx.CacheProviderImpl" />
</extension>
The specified class must implement this interface.
At startup, the com.ibm.wsspi.extension.cache-provider
extension point will be processed, and
org.eclipse.core.runtime.IConfigurationElement.createExecutableExtension(String propertyName)
will be used to create an instance of the cache provider.
NOTE: The name attribute of the cache-provider extension point should match the name of the
cache provider configured via the admin-console or via wsadmin scripting.
@since WAS 6.1.0.27
Jar File
An alternative means of configuring the CacheProvider
is via the WAS ExtensionClassloader.
The cache provider implementation and its dependencies must be packaged as a jar file placed in
the $WAS_INSTALL_ROOT\lib directory. The implementation of the CacheProvider will be loaded
reflectively using the cache provider name and its implementation class name. The cache provider name
and the fully qualified implementation class to be used for a cache instance can be specified using
the admin console, cacheinstances.properties file or DistributedObjectCacheFactory
Custom property/cache-instance property name:
com.ibm.ws.cache.CacheConfig.cacheProviderName
Custom property/cache-instance property value: com.ibm.ws.objectgrid.dynacache.CacheProviderImpl
After obtaining an instance of the CacheProvider via a bundle or jar, createCache(CacheConfig)
will be called to instantiate and obtain a reference to
CoreCache
, which implements the core functionality of the cache.
A cache provider will also need to implement/extend the classes CacheProvider
, CacheEntry
, CoreCache
, CacheStatistics
, and
CacheFeatureSupport
to create a complete solution.
Modifier and Type | Method and Description |
---|---|
CoreCache |
createCache(CacheConfig cacheConfig)
Returns the CoreCache object which is created by cache provider according to
the cache config settings.
|
CacheFeatureSupport |
getCacheFeatureSupport()
Provides the Dynacache features supported by the
CacheProvider . |
java.lang.String |
getName()
Returns the name of the cache provider.
|
void |
start()
This method is called before any caches are created.
|
void |
stop()
This method is called when the cache provder is no longer being used.
|
CoreCache createCache(CacheConfig cacheConfig)
CoreCache
.cacheConfig
- The configuration of the cache instancejava.lang.String getName()
NOTE:The name returned by this method should match the name configured in the cache-provider plugin extension and the cache provider name attribute in the Dynacache configuration specified in the server.xml
CacheFeatureSupport getCacheFeatureSupport()
CacheProvider
.
The features supported determines the methods of CoreCache
that will be called.CacheFeatureSupport
object.void start()
CacheProvider
startup.
Dynacache cannot recover from these fatal errors and will let cache creation fail if errors or exceptions are thrown during
cache provider startup.void stop()
CacheProvider
.