Class Caching.CachingProviderRegistry
- Enclosing class:
Caching
CachingProvider
s scoped by
ClassLoader
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WeakHashMap
<ClassLoader, LinkedHashMap<String, CachingProvider>> TheCachingProvider
s by Class Name organized by theClassLoader
was used to load them.private ClassLoader
The defaultClassLoader
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObtains the onlyCachingProvider
defined by thegetDefaultClassLoader()
.getCachingProvider
(ClassLoader classLoader) Obtains the onlyCachingProvider
defined by the specifiedClassLoader
.getCachingProvider
(String fullyQualifiedClassName) Obtain theCachingProvider
that is implemented by the specified fully qualified class name using thegetDefaultClassLoader()
.getCachingProvider
(String fullyQualifiedClassName, ClassLoader classLoader) Obtain theCachingProvider
that is implemented by the specified fully qualified class name using the providedClassLoader
.Obtain theCachingProvider
s that are available via thegetDefaultClassLoader()
.getCachingProviders
(ClassLoader classLoader) Obtain theCachingProvider
s that are available via the specifiedClassLoader
.Obtains theClassLoader
to use for API methods that don't explicitly require aClassLoader
but internally require one.protected CachingProvider
loadCachingProvider
(String fullyQualifiedClassName, ClassLoader classLoader) Load and instantiate theCachingProvider
with the specified fully qualified class name using the providedClassLoader
void
setDefaultClassLoader
(ClassLoader classLoader) Set theClassLoader
to use for API methods that don't explicitly require aClassLoader
, but internally use one.
-
Field Details
-
cachingProviders
TheCachingProvider
s by Class Name organized by theClassLoader
was used to load them. -
classLoader
-
-
Constructor Details
-
CachingProviderRegistry
public CachingProviderRegistry()Constructs a CachingProviderManager.
-
-
Method Details
-
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
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
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
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
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
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
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(String fullyQualifiedClassName, 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
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
-