Class TypesafeConfigurator

java.lang.Object
com.github.benmanes.caffeine.jcache.configuration.TypesafeConfigurator

public final class TypesafeConfigurator extends Object
Static utility methods pertaining to externalized CaffeineConfiguration entries using the Typesafe Config library.
  • Field Details

    • logger

      static final Logger logger
    • factoryCreator

      static FactoryCreator factoryCreator
    • configSource

      static Supplier<com.typesafe.config.Config> configSource
  • Constructor Details

    • TypesafeConfigurator

      private TypesafeConfigurator()
  • Method Details

    • cacheNames

      public static Set<String> cacheNames(com.typesafe.config.Config config)
      Retrieves the names of the caches defined in the configuration resource.
      Parameters:
      config - the configuration resource
      Returns:
      the names of the configured caches
    • defaults

      public static <K, V> CaffeineConfiguration<K,V> defaults(com.typesafe.config.Config config)
      Retrieves the default cache settings from the configuration resource.
      Type Parameters:
      K - the type of keys maintained the cache
      V - 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 cache
      V - the type of cached values
      Parameters:
      config - the configuration resource
      cacheName - the name of the cache
      Returns:
      the configuration for the cache
    • setFactoryCreator

      @Inject public static void setFactoryCreator(FactoryCreator factoryCreator)
      Specifies how Factory instances are created for a given class name. The default strategy uses Class.newInstance() and requires the class has a no-args constructor.
      Parameters:
      factoryCreator - the strategy for creating a factory
    • setConfigSource

      public static void setConfigSource(Supplier<com.typesafe.config.Config> configSource)
      Specifies how the Config instance should be loaded. The default strategy uses ConfigFactory.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

      public static Supplier<com.typesafe.config.Config> configSource()
      Returns the strategy for loading the configuration.