Class Caching.CachingProviderRegistry
- Enclosing class:
Caching
CachingProviders scoped by
ClassLoader.- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WeakHashMap<ClassLoader, LinkedHashMap<String, CachingProvider>> TheCachingProviders by Class Name organized by theClassLoaderwas used to load them.private ClassLoaderThe defaultClassLoader. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObtains the onlyCachingProviderdefined by thegetDefaultClassLoader().getCachingProvider(ClassLoader classLoader) Obtains the onlyCachingProviderdefined by the specifiedClassLoader.getCachingProvider(String fullyQualifiedClassName) Obtain theCachingProviderthat is implemented by the specified fully qualified class name using thegetDefaultClassLoader().getCachingProvider(String fullyQualifiedClassName, ClassLoader classLoader) Obtain theCachingProviderthat is implemented by the specified fully qualified class name using the providedClassLoader.Obtain theCachingProviders that are available via thegetDefaultClassLoader().getCachingProviders(ClassLoader classLoader) Obtain theCachingProviders that are available via the specifiedClassLoader.Obtains theClassLoaderto use for API methods that don't explicitly require aClassLoaderbut internally require one.protected CachingProviderloadCachingProvider(String fullyQualifiedClassName, ClassLoader classLoader) Load and instantiate theCachingProviderwith the specified fully qualified class name using the providedClassLoadervoidsetDefaultClassLoader(ClassLoader classLoader) Set theClassLoaderto use for API methods that don't explicitly require aClassLoader, but internally use one.
-
Field Details
-
cachingProviders
TheCachingProviders by Class Name organized by theClassLoaderwas used to load them. -
classLoader
-
-
Constructor Details
-
CachingProviderRegistry
public CachingProviderRegistry()Constructs a CachingProviderManager.
-
-
Method Details
-
getDefaultClassLoader
Obtains theClassLoaderto use for API methods that don't explicitly require aClassLoaderbut internally require one.By default this is the
Thread.getContextClassLoader().- Returns:
- the default
ClassLoader
-
setDefaultClassLoader
Set theClassLoaderto use for API methods that don't explicitly require aClassLoader, but internally use one.- Parameters:
classLoader- theClassLoaderornullif the callingThread.getContextClassLoader()should be used
-
getCachingProvider
Obtains the onlyCachingProviderdefined by thegetDefaultClassLoader().Should zero or more than one
CachingProviders be available, a CacheException is thrown.- Returns:
- the
CachingProvider - Throws:
CacheException- should zero or more than oneCachingProviderbe available or aCachingProvidercould not be loaded- See Also:
-
getCachingProvider
Obtains the onlyCachingProviderdefined by the specifiedClassLoader.Should zero or more than one
CachingProviders be available, a CacheException is thrown.- Parameters:
classLoader- theClassLoaderto use for loading theCachingProvider- Returns:
- the
CachingProvider - Throws:
CacheException- should zero or more than oneCachingProviderbe available or aCachingProvidercould not be loaded- See Also:
-
getCachingProviders
Obtain theCachingProviders that are available via thegetDefaultClassLoader().If a
javax.cache.spi.cachingprovidersystem property is defined, only thatCachingProviderspecified by that property is returned. Otherwise allCachingProviders that are available via aServiceLoaderforCachingProviders using the defaultClassLoader(and those explicitly requested viagetCachingProvider(String)) are returned.- Returns:
- an
IterableofCachingProviders loaded by the defaultClassLoader
-
getCachingProviders
Obtain theCachingProviders that are available via the specifiedClassLoader.If a
javax.cache.spi.cachingprovidersystem property is defined, only thatCachingProviderspecified by that property is returned. Otherwise allCachingProviders that are available via aServiceLoaderforCachingProviders using the specifiedClassLoader(and those explicitly requested viagetCachingProvider(String, ClassLoader)) are returned.- Parameters:
classLoader- theClassLoaderof the returnedCachingProviders- Returns:
- an
IterableofCachingProviders loaded by the specifiedClassLoader
-
getCachingProvider
Obtain theCachingProviderthat is implemented by the specified fully qualified class name using thegetDefaultClassLoader(). Should thisCachingProvideralready 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 theCachingProvidercan't be created
-
loadCachingProvider
protected CachingProvider loadCachingProvider(String fullyQualifiedClassName, ClassLoader classLoader) throws CacheException Load and instantiate theCachingProviderwith the specified fully qualified class name using the providedClassLoader- Parameters:
fullyQualifiedClassName- the name of theCachingProviderclassclassLoader- theClassLoaderto use- Returns:
- a new
CachingProviderinstance - Throws:
CacheException- if the specifiedCachingProvidercould not be loaded or the specified class is not aCachingProvider
-
getCachingProvider
Obtain theCachingProviderthat is implemented by the specified fully qualified class name using the providedClassLoader. Should thisCachingProvideralready 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 theCachingProviderclassLoader- theClassLoaderto load theCachingProvider- Returns:
- the
CachingProvider - Throws:
CacheException- when theCachingProvidercan't be created
-