Class PayaraConfig

  • All Implemented Interfaces:
    org.eclipse.microprofile.config.Config

    public class PayaraConfig
    extends Object
    implements org.eclipse.microprofile.config.Config
    Standard implementation for MP Config. This implementation usually caches values for 1 min to avoid resolving and converting values each time getValue(String, Class) is called. This cache can be bypassed by constructing the PayaraConfig with a TTL of zero (or negative).
    Author:
    Steve Millidge (Payara Foundation), Jan Bernitt (caching part, ConfigValueResolver)
    • Constructor Detail

      • PayaraConfig

        public PayaraConfig​(List<org.eclipse.microprofile.config.spi.ConfigSource> sources,
                            Map<Class<?>,​org.eclipse.microprofile.config.spi.Converter<?>> converters,
                            long defaultCacheDurationSeconds)
    • Method Detail

      • getCacheDurationSeconds

        public long getCacheDurationSeconds()
      • getValue

        public <T> T getValue​(String propertyName,
                              Class<T> propertyType)
        Specified by:
        getValue in interface org.eclipse.microprofile.config.Config
      • getConfigValue

        public org.eclipse.microprofile.config.ConfigValue getConfigValue​(String propertyName)
        Specified by:
        getConfigValue in interface org.eclipse.microprofile.config.Config
      • getOptionalValue

        public <T> Optional<T> getOptionalValue​(String propertyName,
                                                Class<T> propertyType)
        Specified by:
        getOptionalValue in interface org.eclipse.microprofile.config.Config
      • getOptionalValues

        public <T> Optional<List<T>> getOptionalValues​(String propertyName,
                                                       Class<T> propertyType)
        Specified by:
        getOptionalValues in interface org.eclipse.microprofile.config.Config
      • getPropertyNames

        public Iterable<String> getPropertyNames()
        Specified by:
        getPropertyNames in interface org.eclipse.microprofile.config.Config
      • getConfigSources

        public Iterable<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSources()
        Specified by:
        getConfigSources in interface org.eclipse.microprofile.config.Config
      • getConverterTypes

        public Set<Class<?>> getConverterTypes()
      • getValue

        protected <T> T getValue​(String propertyName,
                                 String cacheKey,
                                 Long ttl,
                                 String defaultValue,
                                 Supplier<Optional<org.eclipse.microprofile.config.spi.Converter<T>>> converter)
      • getConverter

        public <T> Optional<org.eclipse.microprofile.config.spi.Converter<T>> getConverter​(Class<T> propertyType)
        Specified by:
        getConverter in interface org.eclipse.microprofile.config.Config
      • clearCache

        public void clearCache()
      • unwrap

        public <T> T unwrap​(Class<T> type)
        Specified by:
        unwrap in interface org.eclipse.microprofile.config.Config
      • getProfile

        public String getProfile()
        The Mp Config profile in use.
        Returns:
        may be null