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 void
close()
void
close(ClassLoader cl)
void
close(URI u, ClassLoader cl)
protected <K,V>
CoherenceBasedConfiguration<K,V>convertConfiguration(javax.cache.configuration.Configuration<K,V> cfg, ClassLoader classLoader)
Converts aConfiguration
into aCoherenceBasedConfiguration
so that we may createCoherenceBasedCache
s.protected javax.cache.CacheManager
createCacheMananger(URI uri, ClassLoader classLoader, Properties properties)
Constructs a suitableCacheManager
for the specified parameters.javax.cache.CacheManager
getCacheManager()
javax.cache.CacheManager
getCacheManager(URI uri, ClassLoader cl)
javax.cache.CacheManager
getCacheManager(URI u, ClassLoader cl, Properties p)
Return a CacheManager.ClassLoader
getDefaultClassLoader()
Returns a non-null ClassLoader.String
getDefaultCoherenceBasedConfigurationClassName()
Determines the fully-qualified-class-name of the defaultCoherenceBasedConfiguration
class to use when provided with a JCacheConfiguration
.Properties
getDefaultProperties()
URI
getDefaultURI()
boolean
isSupported(javax.cache.configuration.OptionalFeature feature)
void
release(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
CacheManager
is considered unmanaged.- Specified by:
getCacheManager
in interfacejavax.cache.spi.CachingProvider
- Parameters:
u
- AURI
referencing 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:
getDefaultClassLoader
in interfacejavax.cache.spi.CachingProvider
- Returns:
- a ClassLoader
-
getDefaultURI
public URI getDefaultURI()
- Specified by:
getDefaultURI
in interfacejavax.cache.spi.CachingProvider
-
getDefaultProperties
public Properties getDefaultProperties()
- Specified by:
getDefaultProperties
in interfacejavax.cache.spi.CachingProvider
-
getCacheManager
public javax.cache.CacheManager getCacheManager(URI uri, ClassLoader cl)
- Specified by:
getCacheManager
in interfacejavax.cache.spi.CachingProvider
-
getCacheManager
public javax.cache.CacheManager getCacheManager()
- Specified by:
getCacheManager
in interfacejavax.cache.spi.CachingProvider
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacejavax.cache.spi.CachingProvider
- Specified by:
close
in interfaceCloseable
-
close
public void close(ClassLoader cl)
- Specified by:
close
in interfacejavax.cache.spi.CachingProvider
-
close
public void close(URI u, ClassLoader cl)
- Specified by:
close
in interfacejavax.cache.spi.CachingProvider
-
isSupported
public boolean isSupported(javax.cache.configuration.OptionalFeature feature)
- Specified by:
isSupported
in 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 suitableCacheManager
for the specified parameters.This method may be overridden by sub-classes to provide specialized
CacheManager
implementations.- Parameters:
uri
- theCacheManager
URI
classLoader
- theClassLoader
for the returnedCacheManager
properties
- the customProperties
for theCacheManager
- Returns:
- a new
CacheManager
-
convertConfiguration
protected <K,V> CoherenceBasedConfiguration<K,V> convertConfiguration(javax.cache.configuration.Configuration<K,V> cfg, ClassLoader classLoader)
Converts aConfiguration
into aCoherenceBasedConfiguration
so that we may createCoherenceBasedCache
s.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
cfg
- theConfiguration
to convertclassLoader
- theClassLoader
to use to locate a suitableCoherenceBasedConfiguration
(when necessary)- Returns:
- a
CoherenceBasedConfiguration
for use with aCoherenceBasedCacheManager
-
getDefaultCoherenceBasedConfigurationClassName
public String getDefaultCoherenceBasedConfigurationClassName()
Determines the fully-qualified-class-name of the defaultCoherenceBasedConfiguration
class to use when provided with a JCacheConfiguration
.- Returns:
- the fully-qualified-class-name of a
CoherenceBasedConfiguration
-
-