Class CaffeineCachingProvider
- java.lang.Object
-
- com.github.benmanes.caffeine.jcache.spi.CaffeineCachingProvider
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,javax.cache.spi.CachingProvider
public final class CaffeineCachingProvider extends java.lang.Object implements javax.cache.spi.CachingProvider
A provider that produces a JCache implementation backed by Caffeine. Typically this provider is instantiated usingCaching.getCachingProvider()
, which discovers this implementation through aServiceLoader
.This provider is expected to be used for application life cycle events, like initialization. It is not expected that all requests flow through the provider to obtain the cache manager and cache instances for request operations. Internally, this implementation is synchronized to avoid using excess memory due to its infrequent usage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CaffeineCachingProvider.JCacheClassLoader
AClassLoader
that combinesThread.currentThread().getContextClassLoader()
andgetClass().getClassLoader()
.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.ClassLoader,java.util.Map<java.net.URI,javax.cache.CacheManager>>
cacheManagers
private static java.lang.ClassLoader
DEFAULT_CLASS_LOADER
private boolean
isOsgiComponent
-
Constructor Summary
Constructors Constructor Description CaffeineCachingProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
activate()
void
close()
void
close(java.lang.ClassLoader classLoader)
void
close(java.net.URI uri, java.lang.ClassLoader classLoader)
javax.cache.CacheManager
getCacheManager()
javax.cache.CacheManager
getCacheManager(java.net.URI uri, java.lang.ClassLoader classLoader)
javax.cache.CacheManager
getCacheManager(java.net.URI uri, java.lang.ClassLoader classLoader, java.util.Properties properties)
java.lang.ClassLoader
getDefaultClassLoader()
java.util.Properties
getDefaultProperties()
java.net.URI
getDefaultURI()
private java.lang.ClassLoader
getManagerClassLoader(java.lang.ClassLoader classLoader)
private java.net.URI
getManagerUri(java.net.URI uri)
boolean
isOsgiComponent()
boolean
isSupported(javax.cache.configuration.OptionalFeature optionalFeature)
-
-
-
Method Detail
-
getDefaultClassLoader
public java.lang.ClassLoader getDefaultClassLoader()
- Specified by:
getDefaultClassLoader
in interfacejavax.cache.spi.CachingProvider
-
getDefaultURI
public java.net.URI getDefaultURI()
- Specified by:
getDefaultURI
in interfacejavax.cache.spi.CachingProvider
-
getDefaultProperties
public java.util.Properties getDefaultProperties()
- Specified by:
getDefaultProperties
in interfacejavax.cache.spi.CachingProvider
-
getCacheManager
public javax.cache.CacheManager getCacheManager()
- Specified by:
getCacheManager
in interfacejavax.cache.spi.CachingProvider
-
getCacheManager
public javax.cache.CacheManager getCacheManager(java.net.URI uri, java.lang.ClassLoader classLoader)
- Specified by:
getCacheManager
in interfacejavax.cache.spi.CachingProvider
-
getCacheManager
public javax.cache.CacheManager getCacheManager(java.net.URI uri, java.lang.ClassLoader classLoader, java.util.Properties properties)
- Specified by:
getCacheManager
in interfacejavax.cache.spi.CachingProvider
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejavax.cache.spi.CachingProvider
- Specified by:
close
in interfacejava.io.Closeable
-
close
public void close(java.lang.ClassLoader classLoader)
- Specified by:
close
in interfacejavax.cache.spi.CachingProvider
-
close
public void close(java.net.URI uri, java.lang.ClassLoader classLoader)
- Specified by:
close
in interfacejavax.cache.spi.CachingProvider
-
isSupported
public boolean isSupported(javax.cache.configuration.OptionalFeature optionalFeature)
- Specified by:
isSupported
in interfacejavax.cache.spi.CachingProvider
-
getManagerUri
private java.net.URI getManagerUri(java.net.URI uri)
-
getManagerClassLoader
private java.lang.ClassLoader getManagerClassLoader(java.lang.ClassLoader classLoader)
-
activate
private void activate()
-
isOsgiComponent
public boolean isOsgiComponent()
-
-