K - the cache key typeV - the cache value typeT - the specific UserManagedCache typepublic class UserManagedCacheBuilder<K,V,T extends UserManagedCache<K,V>> extends java.lang.Object implements Builder<T>
UserManagedCacheBuilder enables building UserManagedCaches using a fluent style.
UserManagedCaches are Caches that are not linked to a CacheManager.
As with all Ehcache builders, all instances are immutable and calling any method on the builder will return a new instance without modifying the one on which the method was called. This enables the sharing of builder instances without any risk of seeing them modified by code elsewhere.
| Modifier and Type | Method and Description |
|---|---|
T |
build()
Builds an unitialized
UserManagedCache. |
T |
build(boolean init)
Builds the
UserManagedCache, initializing it if requested. |
UserManagedCacheBuilder<K,V,T> |
identifier(java.lang.String identifier)
Adds an identifier to the returned builder.
|
static <K,V> UserManagedCacheBuilder<K,V,UserManagedCache<K,V>> |
newUserManagedCacheBuilder(java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Creates a new
UserManagedCacheBuilder. |
UserManagedCacheBuilder<K,V,T> |
using(Service service)
Adds a
Service to be made available to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
using(ServiceCreationConfiguration<?> serviceConfiguration)
Adds a
ServiceCreationConfiguration, to trigger a service loading and its configuration, to the returned
builder. |
<N extends T> |
with(UserManagedCacheConfiguration<K,V,N> cfg)
Specifies the returned
UserManagedCache subtype through a specific UserManagedCacheConfiguration
which will optionally add configurations to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withClassLoader(java.lang.ClassLoader classLoader)
Adds a
ClassLoader, to load non Ehcache types, to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withDispatcherConcurrency(int dispatcherConcurrency)
Adds a configuration for dispatcher concurrency in event processing.
|
UserManagedCacheBuilder<K,V,T> |
withEventDispatcher(org.ehcache.core.events.CacheEventDispatcher<K,V> eventDispatcher)
Adds an
CacheEventDispatcher to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withEventExecutors(java.util.concurrent.ExecutorService orderedExecutor,
java.util.concurrent.ExecutorService unOrderedExecutor)
Adds the default
CacheEventDispatcher using the provided ExecutorService to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withEventListeners(org.ehcache.core.events.CacheEventListenerConfiguration... cacheEventListenerConfigurations)
Adds one or more
CacheEventListenerConfiguration to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withEventListeners(CacheEventListenerConfigurationBuilder cacheEventListenerConfiguration)
Convenience method to add a
CacheEventListenerConfiguration based on the provided
CacheEventListenerConfigurationBuilder to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withEvictionAdvisor(EvictionAdvisor<K,V> evictionAdvisor)
Adds an
EvictionAdvisor to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withExpiry(Expiry<? super K,? super V> expiry)
Deprecated.
Use
withExpiry(ExpiryPolicy) instead |
UserManagedCacheBuilder<K,V,T> |
withExpiry(ExpiryPolicy<? super K,? super V> expiry)
Adds
ExpiryPolicy configuration to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withKeyCopier(Copier<K> keyCopier)
Adds a configuration for key
Copier to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withKeySerializer(Serializer<K> keySerializer)
Adds a configuration for key
Serializer to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withKeySerializingCopier()
Adds a configuration for
key copying using the key Serializer to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withLoaderWriter(CacheLoaderWriter<K,V> loaderWriter)
Adds a
CacheLoaderWriter to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withResourcePools(ResourcePools resourcePools)
Adds a
ResourcePools configuration to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withResourcePools(ResourcePoolsBuilder resourcePoolsBuilder)
Convenience method to add a
ResourcePools configuration based on the provided ResourcePoolsBuilder
to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withSizeOfMaxObjectGraph(long size)
Adds or updates the
DefaultSizeOfEngineProviderConfiguration with the specified object graph maximum size to the configured
builder. |
UserManagedCacheBuilder<K,V,T> |
withSizeOfMaxObjectSize(long size,
MemoryUnit unit)
Adds or updates the
DefaultSizeOfEngineProviderConfiguration with the specified maximum mapping size to the configured
builder. |
UserManagedCacheBuilder<K,V,T> |
withValueCopier(Copier<V> valueCopier)
Adds a configuration for value
Copier to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withValueSerializer(Serializer<V> valueSerializer)
Adds a configuration for value
Serializer to the returned builder. |
UserManagedCacheBuilder<K,V,T> |
withValueSerializingCopier()
Adds a configuration for
value copying using the key Serializer to the returned builder. |
public final T build(boolean init) throws java.lang.IllegalStateException
UserManagedCache, initializing it if requested.init - whether to initialize or not the cache before returningjava.lang.IllegalStateException - if the user managed cache cannot be builtpublic T build()
UserManagedCache.public final <N extends T> UserManagedCacheBuilder<K,V,N> with(UserManagedCacheConfiguration<K,V,N> cfg)
UserManagedCache subtype through a specific UserManagedCacheConfiguration
which will optionally add configurations to the returned builder.N - the subtype of UserManagedCachecfg - the UserManagedCacheConfiguration to usePersistentUserManagedCache,
UserManagedPersistenceContextpublic final UserManagedCacheBuilder<K,V,T> identifier(java.lang.String identifier)
The identifier will be used in services and logging the way a cache alias would be inside a CacheManager
identifier - the identifierpublic final UserManagedCacheBuilder<K,V,T> withClassLoader(java.lang.ClassLoader classLoader)
ClassLoader, to load non Ehcache types, to the returned builder.classLoader - the class loader to use@Deprecated public final UserManagedCacheBuilder<K,V,T> withExpiry(Expiry<? super K,? super V> expiry)
withExpiry(ExpiryPolicy) insteadExpiry configuration to the returned builder.expiry - the expiry to usepublic final UserManagedCacheBuilder<K,V,T> withExpiry(ExpiryPolicy<? super K,? super V> expiry)
ExpiryPolicy configuration to the returned builder.expiry - the expiry to usepublic final UserManagedCacheBuilder<K,V,T> withEventDispatcher(org.ehcache.core.events.CacheEventDispatcher<K,V> eventDispatcher)
CacheEventDispatcher to the returned builder.
This is one way of providing a mandatory part of supporting event listeners in UserManagedCache
eventDispatcher - the event dispatcher to usewithEventExecutors(ExecutorService, ExecutorService),
withEventListeners(CacheEventListenerConfiguration...),
withEventListeners(CacheEventListenerConfigurationBuilder)public final UserManagedCacheBuilder<K,V,T> withEventExecutors(java.util.concurrent.ExecutorService orderedExecutor, java.util.concurrent.ExecutorService unOrderedExecutor)
CacheEventDispatcher using the provided ExecutorService to the returned builder.
This is one way of providing a mandatory part of supporting event listeners in UserManagedCache
orderedExecutor - the ordered event executor serviceunOrderedExecutor - the unordered event executor servicewithEventDispatcher(CacheEventDispatcher),
withEventListeners(CacheEventListenerConfiguration...),
withEventListeners(CacheEventListenerConfigurationBuilder)public final UserManagedCacheBuilder<K,V,T> withEventListeners(CacheEventListenerConfigurationBuilder cacheEventListenerConfiguration)
CacheEventListenerConfiguration based on the provided
CacheEventListenerConfigurationBuilder to the returned builder.cacheEventListenerConfiguration - the builder to get the configuration fromwithEventDispatcher(CacheEventDispatcher),
withEventExecutors(ExecutorService, ExecutorService),
withEventListeners(CacheEventListenerConfiguration...)public final UserManagedCacheBuilder<K,V,T> withEventListeners(org.ehcache.core.events.CacheEventListenerConfiguration... cacheEventListenerConfigurations)
CacheEventListenerConfiguration to the returned builder.cacheEventListenerConfigurations - the cache event listener configurationswithEventDispatcher(CacheEventDispatcher),
withEventExecutors(ExecutorService, ExecutorService),
withEventListeners(CacheEventListenerConfigurationBuilder)public final UserManagedCacheBuilder<K,V,T> withResourcePools(ResourcePools resourcePools)
ResourcePools configuration to the returned builder.resourcePools - the resource pools to usewithResourcePools(ResourcePoolsBuilder)public final UserManagedCacheBuilder<K,V,T> withResourcePools(ResourcePoolsBuilder resourcePoolsBuilder)
ResourcePools configuration based on the provided ResourcePoolsBuilder
to the returned builder.resourcePoolsBuilder - the builder to get the resource pools fromwithResourcePools(ResourcePools)public final UserManagedCacheBuilder<K,V,T> withDispatcherConcurrency(int dispatcherConcurrency)
dispatcherConcurrency - the dispatcher concurrency levelpublic UserManagedCacheBuilder<K,V,T> withEvictionAdvisor(EvictionAdvisor<K,V> evictionAdvisor)
EvictionAdvisor to the returned builder.evictionAdvisor - the eviction advisor to usepublic UserManagedCacheBuilder<K,V,T> withLoaderWriter(CacheLoaderWriter<K,V> loaderWriter)
CacheLoaderWriter to the returned builder.loaderWriter - the cache loader writer to usepublic UserManagedCacheBuilder<K,V,T> withKeySerializingCopier()
key copying using the key Serializer to the returned builder.withKeyCopier(Copier),
withKeySerializer(Serializer)public UserManagedCacheBuilder<K,V,T> withValueSerializingCopier()
value copying using the key Serializer to the returned builder.withValueCopier(Copier),
withValueSerializer(Serializer)public UserManagedCacheBuilder<K,V,T> withKeyCopier(Copier<K> keyCopier)
Copier to the returned builder.keyCopier - the key copier to usewithKeySerializingCopier()public UserManagedCacheBuilder<K,V,T> withValueCopier(Copier<V> valueCopier)
Copier to the returned builder.valueCopier - the value copier to usewithValueSerializingCopier()public UserManagedCacheBuilder<K,V,T> withKeySerializer(Serializer<K> keySerializer)
Serializer to the returned builder.keySerializer - the key serializer to usepublic UserManagedCacheBuilder<K,V,T> withValueSerializer(Serializer<V> valueSerializer)
Serializer to the returned builder.valueSerializer - the value serializer to usepublic UserManagedCacheBuilder<K,V,T> withSizeOfMaxObjectGraph(long size)
DefaultSizeOfEngineProviderConfiguration with the specified object graph maximum size to the configured
builder.
SizeOfEngine is what enables the heap tier to be sized in MemoryUnit.
size - the maximum graph sizepublic UserManagedCacheBuilder<K,V,T> withSizeOfMaxObjectSize(long size, MemoryUnit unit)
DefaultSizeOfEngineProviderConfiguration with the specified maximum mapping size to the configured
builder.
SizeOfEngine is what enables the heap tier to be sized in MemoryUnit.
size - the maximum mapping sizeunit - the memory unitpublic static <K,V> UserManagedCacheBuilder<K,V,UserManagedCache<K,V>> newUserManagedCacheBuilder(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
UserManagedCacheBuilder.K - the key typeV - the value typekeyType - the cache key typevalueType - the cache value typepublic UserManagedCacheBuilder<K,V,T> using(Service service)
Service to be made available to the returned builder.
Note that while Services will be started upon UserManagedCache construction, no other lifecycle
operations will be performed on them. It is the responsibility of the developer to properly stop
Services once they are no longer required.
service - the service to addusing(ServiceCreationConfiguration)public UserManagedCacheBuilder<K,V,T> using(ServiceCreationConfiguration<?> serviceConfiguration)
ServiceCreationConfiguration, to trigger a service loading and its configuration, to the returned
builder.
Note that while Services will be started upon UserManagedCache construction, no other lifecycle
operations will be performed on them. It is the responsibility of the developer to properly stop
Services once they are no longer required. Which means that this method should not be used to get
services that require a stop.
serviceConfiguration - the service creation configuration to addusing(Service)