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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classA one-shot builder for creating a configuration instance. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static Supplier<com.typesafe.config.Config> (package private) static FactoryCreator(package private) static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncacheNames(com.typesafe.config.Config config) Retrieves the names of the caches defined in the configuration resource.static Supplier<com.typesafe.config.Config> Returns the strategy for loading the configuration.static <K,V> CaffeineConfiguration <K, V> defaults(com.typesafe.config.Config config) Retrieves the default cache settings from the configuration resource.static <K,V> Optional <CaffeineConfiguration<K, V>> Retrieves the cache's settings from the configuration resource if defined.static voidsetConfigSource(Supplier<com.typesafe.config.Config> configSource) Specifies how theConfiginstance should be loaded.static voidsetFactoryCreator(FactoryCreator factoryCreator) Specifies howFactoryinstances are created for a given class name.
-
Field Details
-
logger
-
factoryCreator
-
configSource
-
-
Constructor Details
-
TypesafeConfigurator
private TypesafeConfigurator()
-
-
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
public static <K,V> Optional<CaffeineConfiguration<K,V>> from(com.typesafe.config.Config config, String cacheName) 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
-
setConfigSource
Specifies how theConfiginstance should be loaded. The default strategy usesConfigFactory.load(). 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
-
configSource
Returns the strategy for loading the configuration.
-