Class TypesafeConfigurator


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

      • cacheNames

        public static Set<String> cacheNames​(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​(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​(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<Config> configSource)
        Specifies how the Config instance should be loaded. The default strategy uses the uri provided by CacheManager.getURI() as an optional override location to parse from a file system or classpath resource, or else returns ConfigFactory.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

        public static void setConfigSource​(ConfigSource configSource)
        Specifies how the Config instance should be loaded. The default strategy uses the uri provided by CacheManager.getURI() as an optional override location to parse from a file system or classpath resource, or else returns ConfigFactory.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

        public static ConfigSource configSource()
        Returns the strategy for loading the configuration.