Class CoherenceBasedCachingProvider

java.lang.Object
com.tangosol.coherence.jcache.CoherenceBasedCachingProvider
All Implemented Interfaces:
Closeable, AutoCloseable, javax.cache.spi.CachingProvider

public class CoherenceBasedCachingProvider extends Object implements javax.cache.spi.CachingProvider
The Coherence-based implementation of a CachingProvider. Added support to recognize and work within a container environment. Calls to JCache API from container code should call CachingProvider#getCacheManager(null, null, null) in order that container descriptor file coherence-application.xml is used to initialize CacheManager.
Author:
bb 2013.04.08, bo 2013.12.17, jf 2014.06.24
  • Constructor Details

  • Method Details

    • getCacheManager

      public javax.cache.CacheManager getCacheManager(URI u, ClassLoader cl, Properties p)
      Return a CacheManager.

      To get a container managed CacheManager, any container code calling this method MUST call this method with a null uri parameter. Calling with a non-null value results in a non-container managed CacheManager. Container managed instances are configured via GAR configuration and are created/closed by container.

      If this method is called from a container context with a non-null URI, the returned CacheManager is considered unmanaged.

      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
      Parameters:
      u - A URI referencing a coherence cache config containing JCacheNamespace or JCacheExtendNamespace. A value of null denotes to compute the default URI for this CacheManager.
      cl - classloader
      p - Coherence JCache implementation specific Properties
      Returns:
      CacheManager
    • getDefaultClassLoader

      public ClassLoader getDefaultClassLoader()
      Returns a non-null ClassLoader.
      Specified by:
      getDefaultClassLoader in interface javax.cache.spi.CachingProvider
      Returns:
      a ClassLoader
    • getDefaultURI

      public URI getDefaultURI()
      Specified by:
      getDefaultURI in interface javax.cache.spi.CachingProvider
    • getDefaultProperties

      public Properties getDefaultProperties()
      Specified by:
      getDefaultProperties in interface javax.cache.spi.CachingProvider
    • getCacheManager

      public javax.cache.CacheManager getCacheManager(URI uri, ClassLoader cl)
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • getCacheManager

      public javax.cache.CacheManager getCacheManager()
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface javax.cache.spi.CachingProvider
      Specified by:
      close in interface Closeable
    • close

      public void close(ClassLoader cl)
      Specified by:
      close in interface javax.cache.spi.CachingProvider
    • close

      public void close(URI u, ClassLoader cl)
      Specified by:
      close in interface javax.cache.spi.CachingProvider
    • isSupported

      public boolean isSupported(javax.cache.configuration.OptionalFeature feature)
      Specified by:
      isSupported in interface javax.cache.spi.CachingProvider
    • release

      public void release(ClassLoader c, URI u)
      Releases the CacheManager with the specified URI and ClassLoader from this CachingProvider. This does not close the CacheManager. It simply releases it from being tracked by the CachingProvider.

      This method does nothing if a CacheManager matching the specified parameters is not being tracked.

      Parameters:
      c - the ClassLoader of the CacheManager
      u - the URI of the CacheManager
    • createCacheMananger

      protected javax.cache.CacheManager createCacheMananger(URI uri, ClassLoader classLoader, Properties properties)
      Constructs a suitable CacheManager for the specified parameters.

      This method may be overridden by sub-classes to provide specialized CacheManager implementations.

      Parameters:
      uri - the CacheManager URI
      classLoader - the ClassLoader for the returned CacheManager
      properties - the custom Properties for the CacheManager
      Returns:
      a new CacheManager
    • convertConfiguration

      protected <K, V> CoherenceBasedConfiguration<K,V> convertConfiguration(javax.cache.configuration.Configuration<K,V> cfg, ClassLoader classLoader)
      Converts a Configuration into a CoherenceBasedConfiguration so that we may create CoherenceBasedCaches.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      cfg - the Configuration to convert
      classLoader - the ClassLoader to use to locate a suitable CoherenceBasedConfiguration (when necessary)
      Returns:
      a CoherenceBasedConfiguration for use with a CoherenceBasedCacheManager
    • getDefaultCoherenceBasedConfigurationClassName

      public String getDefaultCoherenceBasedConfigurationClassName()
      Determines the fully-qualified-class-name of the default CoherenceBasedConfiguration class to use when provided with a JCache Configuration.
      Returns:
      the fully-qualified-class-name of a CoherenceBasedConfiguration