public class CacheManagerBuilder<T extends CacheManager> extends java.lang.Object implements Builder<T>
CacheManagerBuilder enables building cache managers using a fluent style.
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 a
CacheManager or a subtype of it uninitialized. |
T |
build(boolean init)
Builds a
CacheManager or a subtype of it and initializes it if requested. |
static CacheManager |
newCacheManager(Configuration configuration)
Creates a new
CacheManager based on the provided configuration |
static CacheManagerBuilder<CacheManager> |
newCacheManagerBuilder()
Creates a new
CacheManagerBuilder |
static CacheManagerConfiguration<PersistentCacheManager> |
persistence(java.lang.String location)
Convenience method to get a
CacheManagerConfiguration for a PersistentCacheManager. |
CacheManagerBuilder<T> |
replacing(ServiceCreationConfiguration<?> overwriteServiceConfiguration)
Replaces an existing
ServiceCreationConfiguration of the same type on the returned builder. |
CacheManagerBuilder<T> |
using(Service service)
Adds a
Service instance to the returned builder. |
CacheManagerBuilder<T> |
using(ServiceCreationConfiguration<?> serviceConfiguration)
Adds a
ServiceCreationConfiguration to the returned builder. |
<N extends T> |
with(Builder<? extends CacheManagerConfiguration<N>> cfgBuilder)
Convenience method to specialize the returned
CacheManager subtype through a CacheManagerConfiguration
built using the provided Builder. |
<N extends T> |
with(CacheManagerConfiguration<N> cfg)
Specializes the returned
CacheManager subtype through a specific CacheManagerConfiguration which
will optionally add configurations to the returned builder. |
<K,V> CacheManagerBuilder<T> |
withCache(java.lang.String alias,
Builder<? extends CacheConfiguration<K,V>> configurationBuilder)
Convenience method to add a
CacheConfiguration linked to the specified alias to the returned builder by
building it from the provided Builder. |
<K,V> CacheManagerBuilder<T> |
withCache(java.lang.String alias,
CacheConfiguration<K,V> configuration)
Adds a
CacheConfiguration linked to the specified alias to the returned builder. |
CacheManagerBuilder<T> |
withClassLoader(java.lang.ClassLoader classLoader)
Adds a
ClassLoader, to use for non Ehcache types, to the returned builder |
<C> CacheManagerBuilder<T> |
withCopier(java.lang.Class<C> clazz,
java.lang.Class<? extends Copier<C>> copier)
Adds a default
Copier for the specified type to the returned builder. |
CacheManagerBuilder<T> |
withDefaultDiskStoreThreadPool(java.lang.String threadPoolAlias)
Adds a
OffHeapDiskStoreProviderConfiguration, that specifies the thread pool to use, to the returned
builder. |
CacheManagerBuilder<T> |
withDefaultEventListenersThreadPool(java.lang.String threadPoolAlias)
Adds a
CacheEventDispatcherFactoryConfiguration, that specifies the thread pool to use, to the returned
builder. |
CacheManagerBuilder<T> |
withDefaultSizeOfMaxObjectGraph(long size)
Adds a default
SizeOfEngine configuration, that limits the max object graph to
size, to the returned builder. |
CacheManagerBuilder<T> |
withDefaultSizeOfMaxObjectSize(long size,
MemoryUnit unit)
Adds a default
SizeOfEngine configuration, that limits the max object size, to
the returned builder. |
CacheManagerBuilder<T> |
withDefaultWriteBehindThreadPool(java.lang.String threadPoolAlias)
Adds a
WriteBehindProviderConfiguration, that specifies the thread pool to use, to the returned builder. |
<C> CacheManagerBuilder<T> |
withSerializer(java.lang.Class<C> clazz,
java.lang.Class<? extends Serializer<C>> serializer)
Adds a default
Serializer for the specified type to the returned builder. |
public T build(boolean init)
CacheManager or a subtype of it and initializes it if requested.init - whether the returned CacheManager is to be initialized or notCacheManager or a subtype of itpublic T build()
CacheManager or a subtype of it uninitialized.build in interface Builder<T extends CacheManager>CacheManager or a subtype of it uninitializedpublic static CacheManager newCacheManager(Configuration configuration)
CacheManager based on the provided configurationconfiguration - the configuration to useCacheManagerpublic <K,V> CacheManagerBuilder<T> withCache(java.lang.String alias, CacheConfiguration<K,V> configuration)
CacheConfiguration linked to the specified alias to the returned builder.K - the cache key typeV - the cache value typealias - the cache aliasconfiguration - the CacheConfigurationCacheConfigurationBuilderpublic <K,V> CacheManagerBuilder<T> withCache(java.lang.String alias, Builder<? extends CacheConfiguration<K,V>> configurationBuilder)
CacheConfiguration linked to the specified alias to the returned builder by
building it from the provided Builder.K - the cache key typeV - the cache value typealias - the cache aliasconfigurationBuilder - the Builder to get CacheConfiguration fromCacheConfigurationBuilderpublic <N extends T> CacheManagerBuilder<N> with(CacheManagerConfiguration<N> cfg)
CacheManager subtype through a specific CacheManagerConfiguration which
will optionally add configurations to the returned builder.N - the subtype of CacheManagercfg - the CacheManagerConfiguration to usepersistence(String),
PersistentCacheManager,
CacheManagerPersistenceConfigurationpublic <N extends T> CacheManagerBuilder<N> with(Builder<? extends CacheManagerConfiguration<N>> cfgBuilder)
CacheManager subtype through a CacheManagerConfiguration
built using the provided Builder.cfgBuilder - the Builder to get the CacheManagerConfiguration fromCacheConfigurationBuilderpublic CacheManagerBuilder<T> using(Service service)
Service instance to the returned builder.
The service instance will be used by the constructed CacheManager.
service - the Service to addpublic <C> CacheManagerBuilder<T> withCopier(java.lang.Class<C> clazz, java.lang.Class<? extends Copier<C>> copier)
Copier for the specified type to the returned builder.C - the type which can be copiedclazz - the Class for which the copier iscopier - the Copier instancepublic <C> CacheManagerBuilder<T> withSerializer(java.lang.Class<C> clazz, java.lang.Class<? extends Serializer<C>> serializer)
Serializer for the specified type to the returned builder.C - the type which can be serializedclazz - the Class for which the serializer isserializer - the Serializer instancepublic CacheManagerBuilder<T> withDefaultSizeOfMaxObjectGraph(long size)
SizeOfEngine configuration, that limits the max object graph to
size, to the returned builder.size - the max object graph sizepublic CacheManagerBuilder<T> withDefaultSizeOfMaxObjectSize(long size, MemoryUnit unit)
SizeOfEngine configuration, that limits the max object size, to
the returned builder.size - the max object sizeunit - the max object size unitpublic CacheManagerBuilder<T> withDefaultWriteBehindThreadPool(java.lang.String threadPoolAlias)
WriteBehindProviderConfiguration, that specifies the thread pool to use, to the returned builder.threadPoolAlias - the thread pool aliasPooledExecutionServiceConfigurationBuilderpublic CacheManagerBuilder<T> withDefaultDiskStoreThreadPool(java.lang.String threadPoolAlias)
OffHeapDiskStoreProviderConfiguration, that specifies the thread pool to use, to the returned
builder.threadPoolAlias - the thread pool aliasPooledExecutionServiceConfigurationBuilderpublic CacheManagerBuilder<T> withDefaultEventListenersThreadPool(java.lang.String threadPoolAlias)
CacheEventDispatcherFactoryConfiguration, that specifies the thread pool to use, to the returned
builder.threadPoolAlias - the thread pool aliasPooledExecutionServiceConfigurationBuilderpublic CacheManagerBuilder<T> using(ServiceCreationConfiguration<?> serviceConfiguration)
ServiceCreationConfiguration to the returned builder.
These configurations are used to load services and configure them at creation time.
serviceConfiguration - the ServiceCreationConfiguration to usepublic CacheManagerBuilder<T> replacing(ServiceCreationConfiguration<?> overwriteServiceConfiguration)
ServiceCreationConfiguration of the same type on the returned builder.
Duplicate service creation configuration will cause a cache manager to fail to initialize.
overwriteServiceConfiguration - the new ServiceCreationConfiguration to usepublic CacheManagerBuilder<T> withClassLoader(java.lang.ClassLoader classLoader)
ClassLoader, to use for non Ehcache types, to the returned builderclassLoader - the class loader to usepublic static CacheManagerBuilder<CacheManager> newCacheManagerBuilder()
CacheManagerBuilderpublic static CacheManagerConfiguration<PersistentCacheManager> persistence(java.lang.String location)
CacheManagerConfiguration for a PersistentCacheManager.location - the file location for persistent dataCacheManagerConfigurationwith(CacheManagerConfiguration),
PersistentCacheManager