public final class Caching extends Object
ServiceLoader
class.
To be automatically discoverable, its fully qualified class name must be declared in the following file:
META-INF/services/javax.cache.spi.CachingProviderThe file must be available on the classpath. For example, in the reference implementation the contents of this file are:
org.jsr107.ri.RICachingProvider
javax.cache.CachingProvider
, in which case the
specified value is used instead to resolve the CachingProvider implementation.
getCachingProvider(String)
or getCachingProvider(String, ClassLoader)
javax.cache.CachingProvider
system propertygetCachingProvider(String)
or getCachingProvider(String, ClassLoader)
.
Where multiple CachingProviders are present the CachingProvider returned by getters getCachingProvider()
and
getCachingProvider(ClassLoader)
is undefined. As a result a CacheException
will be thrown.
ServiceLoader
,
CachingProvider
Modifier and Type | Class and Description |
---|---|
static class |
Caching.CachingProviderRegistry
Maintains a registry of loaded CachingProviders scoped by ClassLoader.
|
Modifier and Type | Field and Description |
---|---|
static String |
JAVAX_CACHE_CACHING_PROVIDER
The javax.cache.CachingProvider constant.
|
Modifier and Type | Method and Description |
---|---|
static CachingProvider |
getCachingProvider()
Obtains the single CachingProvider visible to the default ClassLoader, which is
Thread.getContextClassLoader() . |
static CachingProvider |
getCachingProvider(ClassLoader classLoader)
Obtains the single CachingProvider visible to the specified ClassLoader.
|
static CachingProvider |
getCachingProvider(String fullyQualifiedClassName)
Obtain the CachingProvider that is implemented by the specified class
name using the
getDefaultClassLoader() . |
static CachingProvider |
getCachingProvider(String fullyQualifiedClassName,
ClassLoader classLoader)
Obtain the CachingProvider that is implemented by the specified class
name using the provided ClassLoader.
|
static Iterable<CachingProvider> |
getCachingProviders()
Obtains the CachingProviders that are available via the
getDefaultClassLoader() . |
static Iterable<CachingProvider> |
getCachingProviders(ClassLoader classLoader)
Obtains the CachingProviders that are available via the specified ClassLoader.
|
static ClassLoader |
getDefaultClassLoader()
Obtains the ClassLoader to use for API methods that don't explicitly require
a ClassLoader but internally require one.
|
public static final String JAVAX_CACHE_CACHING_PROVIDER
public static ClassLoader getDefaultClassLoader()
Thread.getContextClassLoader()
.public static CachingProvider getCachingProvider()
Thread.getContextClassLoader()
.CacheException
- should zero, or more than one CachingProvider be available on the classpath,
or it could not be loadedpublic static CachingProvider getCachingProvider(ClassLoader classLoader)
classLoader
- the ClassLoader to use for loading the CachingProviderCacheException
- should zero, or more than one CachingProvider be available on the classpath,
or it could not be loadedgetCachingProviders(ClassLoader)
public static Iterable<CachingProvider> getCachingProviders()
getDefaultClassLoader()
.
If a javax.cache.cachingprovider
system property is defined,
only that CachingProvider specified by that property is returned.
Otherwise all CachingProviders that are available via a ServiceLoader
for CachingProviders using the default ClassLoader (plus those previously
requested via getCachingProvider(String)
) are returned.public static Iterable<CachingProvider> getCachingProviders(ClassLoader classLoader)
javax.cache.cachingprovider
system property is defined,
only that CachingProvider specified by that property is returned.
Otherwise all CachingProviders that are available via a ServiceLoader
for CachingProviders using the specified ClassLoader (plus those previously
requested via getCachingProvider(String, ClassLoader)
) are
returned.classLoader
- the ClassLoader of the returned CachingProviderspublic static CachingProvider getCachingProvider(String fullyQualifiedClassName)
getDefaultClassLoader()
. Should this CachingProvider
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).fullyQualifiedClassName
- the fully qualified class name of the CachingProviderCacheException
- if the CachingProvider cannot be createdpublic static CachingProvider getCachingProvider(String fullyQualifiedClassName, ClassLoader classLoader)
fullyQualifiedClassName
- the fully qualified class name of the CachingProviderclassLoader
- the ClassLoader to load the CachingProviderCacheException
- if the CachingProvider cannot be createdCopyright © 2013. All Rights Reserved.