Interface CacheProvider


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.

  • Method Summary

    Modifier and Type
    Method
    Description
    createCache(CacheConfig cacheConfig)
    Returns the CoreCache object which is created by cache provider according to the cache config settings.
    Provides the Dynacache features supported by the CacheProvider.
    Returns the name of the cache provider.
    void
    This method is called before any caches are created.
    void
    This method is called when the cache provder is no longer being used.
  • Method Details

    • createCache

      CoreCache createCache(CacheConfig cacheConfig)
      Returns the CoreCache object which is created by cache provider according to the cache config settings. If the CoreCache has already been created it returns the previously created instance of the CoreCache.
      Parameters:
      cacheConfig - The configuration of the cache instance
      Returns:
      The object that implements the CoreCache interface return null if there were any errors or exceptions when creating the cache. If null is returned Dynacache will use the default Dynacache provider for creating the cache instance.
    • getName

      String getName()
      Returns the name of the cache provider.

      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

      Returns:
      The name of the Cache Provider
    • getCacheFeatureSupport

      CacheFeatureSupport getCacheFeatureSupport()
      Provides the Dynacache features supported by the CacheProvider. The features supported determines the methods of CoreCache that will be called.
      Returns:
      The CacheFeatureSupport object.
    • start

      void start()
      This method is called before any caches are created. All initialization of the cache provider internal implementation must occur here. Throw relevant exceptions if there are any errors during 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.
    • stop

      void stop()
      This method is called when the cache provder is no longer being used. All resource cleanup must occur in this method. Throw relevant exceptions if there are any errors when stopping the CacheProvider.