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 aCachingProvider. 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 Constructor Description CoherenceBasedCachingProvider()Constructs aCoherenceBasedCachingProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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.CacheManagergetCacheManager()javax.cache.CacheManagergetCacheManager(URI uri, ClassLoader cl)javax.cache.CacheManagergetCacheManager(URI u, ClassLoader cl, Properties p)Return a CacheManager.ClassLoadergetDefaultClassLoader()Returns a non-null ClassLoader.StringgetDefaultCoherenceBasedConfigurationClassName()Determines the fully-qualified-class-name of the defaultCoherenceBasedConfigurationclass to use when provided with a JCacheConfiguration.PropertiesgetDefaultProperties()URIgetDefaultURI()booleanisSupported(javax.cache.configuration.OptionalFeature feature)voidrelease(ClassLoader c, URI u)Releases the CacheManager with the specified URI and ClassLoader from this CachingProvider.
-
-
-
Constructor Detail
-
CoherenceBasedCachingProvider
public CoherenceBasedCachingProvider()
Constructs aCoherenceBasedCachingProvider.
-
-
Method Detail
-
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 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
public ClassLoader getDefaultClassLoader()
Returns a non-null ClassLoader.- Specified by:
getDefaultClassLoaderin interfacejavax.cache.spi.CachingProvider- Returns:
- a ClassLoader
-
getDefaultURI
public URI getDefaultURI()
- Specified by:
getDefaultURIin interfacejavax.cache.spi.CachingProvider
-
getDefaultProperties
public Properties getDefaultProperties()
- Specified by:
getDefaultPropertiesin interfacejavax.cache.spi.CachingProvider
-
getCacheManager
public javax.cache.CacheManager getCacheManager(URI uri, ClassLoader cl)
- 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
public void close(ClassLoader cl)
- Specified by:
closein interfacejavax.cache.spi.CachingProvider
-
close
public void close(URI u, ClassLoader cl)
- Specified by:
closein interfacejavax.cache.spi.CachingProvider
-
isSupported
public boolean isSupported(javax.cache.configuration.OptionalFeature feature)
- Specified by:
isSupportedin interfacejavax.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 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
public String 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
-
-