Package com.tangosol.coherence.jcache
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidclose(ClassLoader cl) voidclose(URI u, ClassLoader cl) protected <K,V> CoherenceBasedConfiguration<K, V> convertConfiguration(javax.cache.configuration.Configuration<K, V> cfg, ClassLoader classLoader) Converts aConfigurationinto aCoherenceBasedConfigurationso that we may createCoherenceBasedCaches.protected javax.cache.CacheManagercreateCacheMananger(URI uri, ClassLoader classLoader, Properties properties) Constructs a suitableCacheManagerfor the specified parameters.javax.cache.CacheManagerjavax.cache.CacheManagergetCacheManager(URI uri, ClassLoader cl) javax.cache.CacheManagergetCacheManager(URI u, ClassLoader cl, Properties p) Return a CacheManager.Returns a non-null ClassLoader.Determines the fully-qualified-class-name of the defaultCoherenceBasedConfigurationclass to use when provided with a JCacheConfiguration.booleanisSupported(javax.cache.configuration.OptionalFeature feature) voidrelease(ClassLoader c, URI u) Releases the CacheManager with the specified URI and ClassLoader from this CachingProvider.
-
Constructor Details
-
CoherenceBasedCachingProvider
public CoherenceBasedCachingProvider()Constructs aCoherenceBasedCachingProvider.
-
-
Method Details
-
getCacheManager
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 managedCacheManager. 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
CacheManageris considered unmanaged.- Specified by:
getCacheManagerin interfacejavax.cache.spi.CachingProvider- Parameters:
u- AURIreferencing a coherence cache config containing JCacheNamespace or JCacheExtendNamespace. A value of null denotes to compute the default URI for thisCacheManager.cl- classloaderp- Coherence JCache implementation specificProperties- Returns:
CacheManager
-
getDefaultClassLoader
Returns a non-null ClassLoader.- Specified by:
getDefaultClassLoaderin interfacejavax.cache.spi.CachingProvider- Returns:
- a ClassLoader
-
getDefaultURI
- Specified by:
getDefaultURIin interfacejavax.cache.spi.CachingProvider
-
getDefaultProperties
- Specified by:
getDefaultPropertiesin interfacejavax.cache.spi.CachingProvider
-
getCacheManager
- Specified by:
getCacheManagerin interfacejavax.cache.spi.CachingProvider
-
getCacheManager
public javax.cache.CacheManager getCacheManager()- Specified by:
getCacheManagerin interfacejavax.cache.spi.CachingProvider
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacejavax.cache.spi.CachingProvider- Specified by:
closein interfaceCloseable
-
close
- Specified by:
closein interfacejavax.cache.spi.CachingProvider
-
close
- Specified by:
closein interfacejavax.cache.spi.CachingProvider
-
isSupported
public boolean isSupported(javax.cache.configuration.OptionalFeature feature) - Specified by:
isSupportedin interfacejavax.cache.spi.CachingProvider
-
release
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 CacheManageru- the URI of the CacheManager
-
createCacheMananger
protected javax.cache.CacheManager createCacheMananger(URI uri, ClassLoader classLoader, Properties properties) Constructs a suitableCacheManagerfor the specified parameters.This method may be overridden by sub-classes to provide specialized
CacheManagerimplementations.- Parameters:
uri- theCacheManagerURIclassLoader- theClassLoaderfor the returnedCacheManagerproperties- the customPropertiesfor theCacheManager- Returns:
- a new
CacheManager
-
convertConfiguration
protected <K,V> CoherenceBasedConfiguration<K,V> convertConfiguration(javax.cache.configuration.Configuration<K, V> cfg, ClassLoader classLoader) Converts aConfigurationinto aCoherenceBasedConfigurationso that we may createCoherenceBasedCaches.- Type Parameters:
K- the key typeV- the value type- Parameters:
cfg- theConfigurationto convertclassLoader- theClassLoaderto use to locate a suitableCoherenceBasedConfiguration(when necessary)- Returns:
- a
CoherenceBasedConfigurationfor use with aCoherenceBasedCacheManager
-
getDefaultCoherenceBasedConfigurationClassName
Determines the fully-qualified-class-name of the defaultCoherenceBasedConfigurationclass to use when provided with a JCacheConfiguration.- Returns:
- the fully-qualified-class-name of a
CoherenceBasedConfiguration
-