Package org.ehcache.config.builders
Class ResourcePoolsBuilder
java.lang.Object
org.ehcache.config.builders.ResourcePoolsBuilder
- All Implemented Interfaces:
org.ehcache.config.Builder<org.ehcache.config.ResourcePools>
public class ResourcePoolsBuilder
extends Object
implements org.ehcache.config.Builder<org.ehcache.config.ResourcePools>
The
ResourcePoolsBuilder enables building ResourcePools configurations 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.
-
Method Summary
Modifier and TypeMethodDescriptionorg.ehcache.config.ResourcePoolsbuild()Builds theResourcePoolsbased on this builder's configuration.disk(long size, org.ehcache.config.units.MemoryUnit unit) Convenience method to add a non persistentdiskpool.disk(long size, org.ehcache.config.units.MemoryUnit unit, boolean persistent) Convenience method to add adiskpool specifying persistence.static ResourcePoolsBuilderheap(long entries) Creates a newResourcePoolsBuilderwith aheappool sized inentriesheap(long size, org.ehcache.config.ResourceUnit unit) Convenience method to add aheappool.static ResourcePoolsBuilderCreates a newResourcePoolsBuilder.static ResourcePoolsBuildernewResourcePoolsBuilder(org.ehcache.config.ResourcePools pools) Convenience method to get a builder from an existingResourcePools.offheap(long size, org.ehcache.config.units.MemoryUnit unit) Convenience method to add anoffheappool.shared(org.ehcache.config.ResourceType<?> type) shared(org.ehcache.config.ResourceType<?> type, boolean persistent) Informs the cache manager that an existingdiskshared pool, defined on the cache manager, should be used for the cache's disk caching requirements.Informs the cache manager that an existingheapshared pool, defined on the cache manager, should be used for the cache's on-heap caching requirements.Informs the cache manager that an existingoffheapshared pool, defined on the cache manager, should be used for the cache's offheap caching requirements.with(org.ehcache.config.ResourcePool resourcePool) Add theResourcePoolofResourceTypein the returned builder.with(org.ehcache.config.ResourceType<org.ehcache.config.SizedResourcePool> type, long size, org.ehcache.config.ResourceUnit unit, boolean persistent) Add theResourcePoolofResourceTypein the returned builder.withReplacing(org.ehcache.config.ResourcePool resourcePool) Add or replace theResourcePoolofResourceTypein the returned builder.
-
Method Details
-
newResourcePoolsBuilder
Creates a newResourcePoolsBuilder.- Returns:
- the new builder
-
newResourcePoolsBuilder
Convenience method to get a builder from an existingResourcePools.- Parameters:
pools- the resource pools to build from- Returns:
- a new builder with configuration matching the provided resource pools
-
heap
Creates a newResourcePoolsBuilderwith aheappool sized inentries- Parameters:
entries- the maximum number of mappings to cache- Returns:
- a new builder with a heap configuration
-
with
Add theResourcePoolofResourceTypein the returned builder.- Parameters:
resourcePool- the non-nullresource pool to add- Returns:
- a new builder with the added pool
- Throws:
IllegalArgumentException- if the set of resource pools already contains a pool fortype
-
withReplacing
Add or replace theResourcePoolofResourceTypein the returned builder.- Parameters:
resourcePool- the non-nullresource pool to add/replace- Returns:
- a new builder with the added pool
-
with
public ResourcePoolsBuilder with(org.ehcache.config.ResourceType<org.ehcache.config.SizedResourcePool> type, long size, org.ehcache.config.ResourceUnit unit, boolean persistent) Add theResourcePoolofResourceTypein the returned builder.- Parameters:
type- the resource typesize- the pool sizeunit- the pool size unitpersistent- if the pool is to be persistent- Returns:
- a new builder with the added pool
- Throws:
IllegalArgumentException- if the set of resource pools already contains a pool fortype
-
heap
Convenience method to add aheappool.- Parameters:
size- the pool sizeunit- the pool size unit- Returns:
- a new builder with the added pool
- Throws:
IllegalArgumentException- if the set of resource pools already contains a heap resource
-
offheap
Convenience method to add anoffheappool.- Parameters:
size- the pool sizeunit- the pool size unit- Returns:
- a new builder with the added pool
- Throws:
IllegalArgumentException- if the set of resource pools already contains an offheap resource
-
disk
Convenience method to add a non persistentdiskpool.- Parameters:
size- the pool sizeunit- the pool size unit- Returns:
- a new builder with the added pool
- Throws:
IllegalArgumentException- if the set of resource pools already contains a disk resource
-
disk
public ResourcePoolsBuilder disk(long size, org.ehcache.config.units.MemoryUnit unit, boolean persistent) Convenience method to add adiskpool specifying persistence.- Parameters:
size- the pool sizeunit- the pool size unitpersistent- if the pool is persistent or not- Returns:
- a new builder with the added pool
- Throws:
IllegalArgumentException- if the set of resource pools already contains a disk resource
-
build
public org.ehcache.config.ResourcePools build()Builds theResourcePoolsbased on this builder's configuration.- Specified by:
buildin interfaceorg.ehcache.config.Builder<org.ehcache.config.ResourcePools>- Returns:
- the resource pools
-