Class TypesafeConfigurator
java.lang.Object
com.github.benmanes.caffeine.jcache.configuration.TypesafeConfigurator
Static utility methods pertaining to externalized
CaffeineConfiguration entries using the
Typesafe Config library.-
Method Summary
Modifier and TypeMethodDescriptioncacheNames(Config config) Retrieves the names of the caches defined in the configuration resource.static ConfigSourceReturns the strategy for loading the configuration.static <K,V> CaffeineConfiguration <K, V> Retrieves the default cache settings from the configuration resource.static FactoryCreatorReturns the strategy for how factory instances are created.static <K,V> Optional <CaffeineConfiguration<K, V>> Retrieves the cache's settings from the configuration resource if defined.static voidsetConfigSource(ConfigSource configSource) Specifies how theConfiginstance should be loaded.static voidsetConfigSource(Supplier<Config> configSource) Specifies how theConfiginstance should be loaded.static voidsetFactoryCreator(FactoryCreator factoryCreator) Specifies howFactoryinstances are created for a given class name.
-
Method Details
-
cacheNames
-
defaults
Retrieves the default cache settings from the configuration resource.- Type Parameters:
K- the type of keys maintained the cacheV- the type of cached values- Parameters:
config- the configuration resource- Returns:
- the default configuration for a cache
-
from
Retrieves the cache's settings from the configuration resource if defined.- Type Parameters:
K- the type of keys maintained the cacheV- the type of cached values- Parameters:
config- the configuration resourcecacheName- the name of the cache- Returns:
- the configuration for the cache
-
setFactoryCreator
Specifies howFactoryinstances are created for a given class name. The default strategy usesClass.newInstance()and requires the class has a no-args constructor.- Parameters:
factoryCreator- the strategy for creating a factory
-
factoryCreator
Returns the strategy for how factory instances are created. -
setConfigSource
Specifies how theConfiginstance should be loaded. The default strategy uses the uri provided byCacheManager.getURI()as an optional override location to parse from a file system or classpath resource, or else returnsConfigFactory.load(ClassLoader). The configuration is retrieved on-demand, allowing for it to be reloaded, and it is assumed that the source caches it as needed.- Parameters:
configSource- the strategy for loading the configuration
-
setConfigSource
Specifies how theConfiginstance should be loaded. The default strategy uses the uri provided byCacheManager.getURI()as an optional override location to parse from a file system or classpath resource, or else returnsConfigFactory.load(ClassLoader). The configuration is retrieved on-demand, allowing for it to be reloaded, and it is assumed that the source caches it as needed.- Parameters:
configSource- the strategy for loading the configuration from a uri
-
configSource
Returns the strategy for loading the configuration.
-