Class Caching.CachingProviderRegistry
- java.lang.Object
-
- javax.cache.Caching.CachingProviderRegistry
-
- Enclosing class:
- Caching
private static class Caching.CachingProviderRegistry extends java.lang.Object
Maintains a registry of loadedCachingProvider
s scoped byClassLoader
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.WeakHashMap<java.lang.ClassLoader,java.util.LinkedHashMap<java.lang.String,CachingProvider>>
cachingProviders
TheCachingProvider
s by Class Name organized by theClassLoader
was used to load them.private java.lang.ClassLoader
classLoader
The defaultClassLoader
.
-
Constructor Summary
Constructors Constructor Description CachingProviderRegistry()
Constructs a CachingProviderManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CachingProvider
getCachingProvider()
Obtains the onlyCachingProvider
defined by thegetDefaultClassLoader()
.CachingProvider
getCachingProvider(java.lang.ClassLoader classLoader)
Obtains the onlyCachingProvider
defined by the specifiedClassLoader
.CachingProvider
getCachingProvider(java.lang.String fullyQualifiedClassName)
Obtain theCachingProvider
that is implemented by the specified fully qualified class name using thegetDefaultClassLoader()
.CachingProvider
getCachingProvider(java.lang.String fullyQualifiedClassName, java.lang.ClassLoader classLoader)
Obtain theCachingProvider
that is implemented by the specified fully qualified class name using the providedClassLoader
.java.lang.Iterable<CachingProvider>
getCachingProviders()
Obtain theCachingProvider
s that are available via thegetDefaultClassLoader()
.java.lang.Iterable<CachingProvider>
getCachingProviders(java.lang.ClassLoader classLoader)
Obtain theCachingProvider
s that are available via the specifiedClassLoader
.java.lang.ClassLoader
getDefaultClassLoader()
Obtains theClassLoader
to use for API methods that don't explicitly require aClassLoader
but internally require one.protected CachingProvider
loadCachingProvider(java.lang.String fullyQualifiedClassName, java.lang.ClassLoader classLoader)
Load and instantiate theCachingProvider
with the specified fully qualified class name using the providedClassLoader
void
setDefaultClassLoader(java.lang.ClassLoader classLoader)
Set theClassLoader
to use for API methods that don't explicitly require aClassLoader
, but internally use one.
-
-
-
Field Detail
-
cachingProviders
private java.util.WeakHashMap<java.lang.ClassLoader,java.util.LinkedHashMap<java.lang.String,CachingProvider>> cachingProviders
TheCachingProvider
s by Class Name organized by theClassLoader
was used to load them.
-
classLoader
private volatile java.lang.ClassLoader classLoader
The defaultClassLoader
. Whennull
theThread.getContextClassLoader()
will be used.
-
-
Method Detail
-
getDefaultClassLoader
public java.lang.ClassLoader getDefaultClassLoader()
Obtains theClassLoader
to use for API methods that don't explicitly require aClassLoader
but internally require one.By default this is the
Thread.getContextClassLoader()
.- Returns:
- the default
ClassLoader
-
setDefaultClassLoader
public void setDefaultClassLoader(java.lang.ClassLoader classLoader)
Set theClassLoader
to use for API methods that don't explicitly require aClassLoader
, but internally use one.- Parameters:
classLoader
- theClassLoader
ornull
if the callingThread.getContextClassLoader()
should be used
-
getCachingProvider
public CachingProvider getCachingProvider()
Obtains the onlyCachingProvider
defined by thegetDefaultClassLoader()
.Should zero or more than one
CachingProvider
s be available, a CacheException is thrown.- Returns:
- the
CachingProvider
- Throws:
CacheException
- should zero or more than oneCachingProvider
be available or aCachingProvider
could not be loaded- See Also:
getCachingProvider(ClassLoader)
,getCachingProviders(ClassLoader)
-
getCachingProvider
public CachingProvider getCachingProvider(java.lang.ClassLoader classLoader)
Obtains the onlyCachingProvider
defined by the specifiedClassLoader
.Should zero or more than one
CachingProvider
s be available, a CacheException is thrown.- Parameters:
classLoader
- theClassLoader
to use for loading theCachingProvider
- Returns:
- the
CachingProvider
- Throws:
CacheException
- should zero or more than oneCachingProvider
be available or aCachingProvider
could not be loaded- See Also:
getCachingProviders(ClassLoader)
-
getCachingProviders
public java.lang.Iterable<CachingProvider> getCachingProviders()
Obtain theCachingProvider
s that are available via thegetDefaultClassLoader()
.If a
javax.cache.spi.cachingprovider
system property is defined, only thatCachingProvider
specified by that property is returned. Otherwise allCachingProvider
s that are available via aServiceLoader
forCachingProvider
s using the defaultClassLoader
(and those explicitly requested viagetCachingProvider(String)
) are returned.- Returns:
- an
Iterable
ofCachingProvider
s loaded by the defaultClassLoader
-
getCachingProviders
public java.lang.Iterable<CachingProvider> getCachingProviders(java.lang.ClassLoader classLoader)
Obtain theCachingProvider
s that are available via the specifiedClassLoader
.If a
javax.cache.spi.cachingprovider
system property is defined, only thatCachingProvider
specified by that property is returned. Otherwise allCachingProvider
s that are available via aServiceLoader
forCachingProvider
s using the specifiedClassLoader
(and those explicitly requested viagetCachingProvider(String, ClassLoader)
) are returned.- Parameters:
classLoader
- theClassLoader
of the returnedCachingProvider
s- Returns:
- an
Iterable
ofCachingProvider
s loaded by the specifiedClassLoader
-
getCachingProvider
public CachingProvider getCachingProvider(java.lang.String fullyQualifiedClassName)
Obtain theCachingProvider
that is implemented by the specified fully qualified class name using thegetDefaultClassLoader()
. Should thisCachingProvider
already be loaded it is simply returned, otherwise an attempt will be made to load and instantiate the specified class name (using a no-args constructor).- Parameters:
fullyQualifiedClassName
- the fully qualified class name of theCachingProvider
- Returns:
- the
CachingProvider
- Throws:
CacheException
- when theCachingProvider
can't be created
-
loadCachingProvider
protected CachingProvider loadCachingProvider(java.lang.String fullyQualifiedClassName, java.lang.ClassLoader classLoader) throws CacheException
Load and instantiate theCachingProvider
with the specified fully qualified class name using the providedClassLoader
- Parameters:
fullyQualifiedClassName
- the name of theCachingProvider
classclassLoader
- theClassLoader
to use- Returns:
- a new
CachingProvider
instance - Throws:
CacheException
- if the specifiedCachingProvider
could not be loaded or the specified class is not aCachingProvider
-
getCachingProvider
public CachingProvider getCachingProvider(java.lang.String fullyQualifiedClassName, java.lang.ClassLoader classLoader)
Obtain theCachingProvider
that is implemented by the specified fully qualified class name using the providedClassLoader
. Should thisCachingProvider
already be loaded it is returned, otherwise an attempt will be made to load and instantiate the specified class (using a no-args constructor).- Parameters:
fullyQualifiedClassName
- the fully qualified class name of theCachingProvider
classLoader
- theClassLoader
to load theCachingProvider
- Returns:
- the
CachingProvider
- Throws:
CacheException
- when theCachingProvider
can't be created
-
-