javax.cache
Interface CacheBuilder<K,V>

Type Parameters:
K - the key type
V - the value type

public interface CacheBuilder<K,V>

A CacheBuilder is used for creating Caches. A CacheBuilder is created by CacheManager.createCacheBuilder(String) and is associated with that manager. Additional configuration methods may be available on a builder instance by casting to a concrete implementation.

Since:
1.0
Author:
Yannis Cosmadopoulos

Method Summary
 Cache<K,V> build()
          Create an instance of the named Cache.
 CacheBuilder<K,V> registerCacheEntryListener(CacheEntryListener<K,V> cacheEntryListener, NotificationScope scope, boolean synchronous)
          Registers a listener.
 CacheBuilder<K,V> setCacheConfiguration(CacheConfiguration configuration)
          Set the cache configuration.
 CacheBuilder<K,V> setCacheLoader(CacheLoader<K,V> cacheLoader)
          Set the cache loader.
 

Method Detail

build

Cache<K,V> build()
Create an instance of the named Cache.

The Cache will be created, added to the caches controlled by its associated CacheManager and started. If there is an existing Cache of the same name associated with this CacheManager when build is invoked, the old Cache will be stopped.

Returns:
a new instance of the named cache
Throws:
InvalidConfigurationException - thrown if the configuration is invalid
See Also:
CacheManager.createCacheBuilder(String)

setCacheConfiguration

CacheBuilder<K,V> setCacheConfiguration(CacheConfiguration configuration)
Set the cache configuration.

Parameters:
configuration - the cache configuration
Returns:
the builder

setCacheLoader

CacheBuilder<K,V> setCacheLoader(CacheLoader<K,V> cacheLoader)
Set the cache loader.

Parameters:
cacheLoader - the CacheLoader
Returns:
the builder

registerCacheEntryListener

CacheBuilder<K,V> registerCacheEntryListener(CacheEntryListener<K,V> cacheEntryListener,
                                             NotificationScope scope,
                                             boolean synchronous)
Registers a listener. Can be invoked multiple times.

Parameters:
cacheEntryListener - the listener
scope - the notification scope.
synchronous - whether to listener should be invoked synchronously
Returns:
the builder
Throws:
NullPointerException - if any of the arguments are null.


Copyright © 2011. All Rights Reserved.