public class CoherenceBasedCachingProvider extends Object implements javax.cache.spi.CachingProvider
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. The Coherence implementation integration is described in ContainerAdapter. Coherence JCache cache configuration and optional pof configuration must be referenced in coherence-application.xml as detailed in ContainerAdapter javadoc.| Constructor and Description |
|---|
CoherenceBasedCachingProvider()
Constructs a
CoherenceBasedCachingProvider. |
| Modifier and Type | Method and 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 a
Configuration into a CoherenceBasedConfiguration so that we may create CoherenceBasedCaches. |
protected javax.cache.CacheManager |
createCacheMananger(URI uri, ClassLoader classLoader, Properties properties)
Constructs a suitable
CacheManager for the specified parameters. |
void |
enableContainerContext()
Place CoherenceBasedCachingProvider into Container Context mode.
|
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 default
CoherenceBasedConfiguration class to use when provided with a JCache Configuration. |
Properties |
getDefaultProperties() |
URI |
getDefaultURI() |
boolean |
isContainerContext() |
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.
|
public CoherenceBasedCachingProvider()
CoherenceBasedCachingProvider.public javax.cache.CacheManager getCacheManager(URI u, ClassLoader cl, Properties p)
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.
Note: the jcache container unit CoherenceBasedCacheManagerTest#testJCacheContainerActivation confirms that if the getCacheManager call within the container has the cache config uri that exactly matches the one in the GAR configuration, the code does work correctly and the CoherenceBasedCacheManager.isContainerManaged() returns true.
If this method is called from a container context with a non-null URI, the returned CacheManager is considered unmanaged.
getCacheManager in interface javax.cache.spi.CachingProvideru - 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 - classloaderp - Coherence JCache implementation specific PropertiesCacheManagerpublic ClassLoader getDefaultClassLoader()
getDefaultClassLoader in interface javax.cache.spi.CachingProviderpublic URI getDefaultURI()
getDefaultURI in interface javax.cache.spi.CachingProviderpublic Properties getDefaultProperties()
getDefaultProperties in interface javax.cache.spi.CachingProviderpublic javax.cache.CacheManager getCacheManager(URI uri, ClassLoader cl)
getCacheManager in interface javax.cache.spi.CachingProviderpublic javax.cache.CacheManager getCacheManager()
getCacheManager in interface javax.cache.spi.CachingProviderpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface javax.cache.spi.CachingProviderpublic void close(ClassLoader cl)
close in interface javax.cache.spi.CachingProviderpublic void close(URI u, ClassLoader cl)
close in interface javax.cache.spi.CachingProviderpublic boolean isSupported(javax.cache.configuration.OptionalFeature feature)
isSupported in interface javax.cache.spi.CachingProviderpublic boolean isContainerContext()
public void release(ClassLoader c, URI u)
This method does nothing if a CacheManager matching the specified parameters is not being tracked.
c - the ClassLoader of the CacheManageru - the URI of the CacheManagerprotected javax.cache.CacheManager createCacheMananger(URI uri, ClassLoader classLoader, Properties properties)
CacheManager for the specified parameters.
This method may be overridden by sub-classes to provide specialized CacheManager implementations.
uri - the CacheManager URIclassLoader - the ClassLoader for the returned CacheManagerproperties - the custom Properties for the CacheManagerCacheManagerprotected <K,V> CoherenceBasedConfiguration<K,V> convertConfiguration(javax.cache.configuration.Configuration<K,V> cfg, ClassLoader classLoader)
Configuration into a CoherenceBasedConfiguration so that we may create CoherenceBasedCaches.K - the key typeV - the value typecfg - the Configuration to convertclassLoader - the ClassLoader to use to locate a suitable CoherenceBasedConfiguration (when necessary)CoherenceBasedConfiguration for use with a CoherenceBasedCacheManagerpublic String getDefaultCoherenceBasedConfigurationClassName()
CoherenceBasedConfiguration class to use when provided with a JCache Configuration.CoherenceBasedConfigurationpublic void enableContainerContext()