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 Details

    • newResourcePoolsBuilder

      public static ResourcePoolsBuilder newResourcePoolsBuilder()
      Creates a new ResourcePoolsBuilder.
      Returns:
      the new builder
    • newResourcePoolsBuilder

      public static ResourcePoolsBuilder newResourcePoolsBuilder(org.ehcache.config.ResourcePools pools)
      Convenience method to get a builder from an existing ResourcePools.
      Parameters:
      pools - the resource pools to build from
      Returns:
      a new builder with configuration matching the provided resource pools
    • heap

      public static ResourcePoolsBuilder heap(long entries)
      Creates a new ResourcePoolsBuilder with a heap pool sized in entries
      Parameters:
      entries - the maximum number of mappings to cache
      Returns:
      a new builder with a heap configuration
    • with

      public ResourcePoolsBuilder with(org.ehcache.config.ResourcePool resourcePool)
      Add the ResourcePool of ResourceType in the returned builder.
      Parameters:
      resourcePool - the non-null resource pool to add
      Returns:
      a new builder with the added pool
      Throws:
      IllegalArgumentException - if the set of resource pools already contains a pool for type
    • withReplacing

      public ResourcePoolsBuilder withReplacing(org.ehcache.config.ResourcePool resourcePool)
      Add or replace the ResourcePool of ResourceType in the returned builder.
      Parameters:
      resourcePool - the non-null resource 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 the ResourcePool of ResourceType in the returned builder.
      Parameters:
      type - the resource type
      size - the pool size
      unit - the pool size unit
      persistent - 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 for type
    • heap

      public ResourcePoolsBuilder heap(long size, org.ehcache.config.ResourceUnit unit)
      Convenience method to add a heap pool.
      Parameters:
      size - the pool size
      unit - 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
    • sharedHeap

      public ResourcePoolsBuilder sharedHeap()
      Informs the cache manager that an existing heap shared pool, defined on the cache manager, should be used for the cache's on-heap caching requirements.
      Returns:
      a new builder with the added pool
    • offheap

      public ResourcePoolsBuilder offheap(long size, org.ehcache.config.units.MemoryUnit unit)
      Convenience method to add an offheap pool.
      Parameters:
      size - the pool size
      unit - 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
    • sharedOffheap

      public ResourcePoolsBuilder sharedOffheap()
      Informs the cache manager that an existing offheap shared pool, defined on the cache manager, should be used for the cache's offheap caching requirements.
      Returns:
      a new builder with the added pool
    • disk

      public ResourcePoolsBuilder disk(long size, org.ehcache.config.units.MemoryUnit unit)
      Convenience method to add a non persistent disk pool.
      Parameters:
      size - the pool size
      unit - 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 a disk pool specifying persistence.
      Parameters:
      size - the pool size
      unit - the pool size unit
      persistent - 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
    • sharedDisk

      public ResourcePoolsBuilder sharedDisk()
      Informs the cache manager that an existing disk shared pool, defined on the cache manager, should be used for the cache's disk caching requirements.
      Returns:
      a new builder with the added pool
    • shared

      public ResourcePoolsBuilder shared(org.ehcache.config.ResourceType<?> type, boolean persistent)
    • shared

      public ResourcePoolsBuilder shared(org.ehcache.config.ResourceType<?> type)
    • build

      public org.ehcache.config.ResourcePools build()
      Builds the ResourcePools based on this builder's configuration.
      Specified by:
      build in interface org.ehcache.config.Builder<org.ehcache.config.ResourcePools>
      Returns:
      the resource pools