use of org.eclipse.microprofile.config.spi.Converter in project Payara by payara.
the class ConfigProviderResolverImpl method getDiscoveredConverters.
List<Converter> getDiscoveredConverters(ApplicationInfo appInfo) {
LinkedList<Converter> converters = appInfo.getTransientAppMetaData(CUSTOM_CONVERTERS_KEY, LinkedList.class);
if (converters == null) {
converters = new LinkedList<>();
// resolve custom config sources
ServiceLoader<Converter> serviceLoader = ServiceLoader.load(Converter.class, appInfo.getAppClassLoader());
for (Converter converter : serviceLoader) {
converters.add(converter);
}
appInfo.addTransientAppMetaData(CUSTOM_CONVERTERS_KEY, converters);
}
return converters;
}
use of org.eclipse.microprofile.config.spi.Converter in project Payara by payara.
the class ConfigProviderResolverImpl method getDefaultConverters.
List<Converter> getDefaultConverters() {
LinkedList<Converter> result = new LinkedList<>();
result.add(new BooleanConverter());
result.add(new IntegerConverter());
result.add(new LongConverter());
result.add(new FloatConverter());
result.add(new DoubleConverter());
result.add(new DurationConverter());
result.add(new LocalTimeConverter());
result.add(new LocalDateConverter());
result.add(new LocalDateTimeConverter());
result.add(new OffsetDateTimeConverter());
result.add(new OffsetTimeConverter());
result.add(new InstantConverter());
result.add(new URLConverter());
result.add(new InetAddressConverter());
result.add(new ChronoUnitConverter());
return result;
}
use of org.eclipse.microprofile.config.spi.Converter in project Payara by payara.
the class ConfigProviderResolverImpl method getConfig.
Config getConfig(ApplicationInfo appInfo) {
Config result;
// manage server level config first
if (appInfo == null) {
result = serverLevelConfig;
if (result == null) {
LinkedList<ConfigSource> sources = new LinkedList<>();
LinkedList<Converter> converters = new LinkedList<>();
sources.addAll(getDefaultSources());
converters.addAll(getDefaultConverters());
serverLevelConfig = new PayaraConfig(sources, converters);
result = serverLevelConfig;
}
} else {
// look for an application specific one
result = appInfo.getTransientAppMetaData(METADATA_KEY, Config.class);
if (result == null) {
// build an application specific configuration
initialiseApplicationConfig(appInfo);
LinkedList<ConfigSource> sources = new LinkedList<>();
LinkedList<Converter> converters = new LinkedList<>();
sources.addAll(getDefaultSources());
sources.addAll(getDiscoveredSources(appInfo));
converters.addAll(getDefaultConverters());
converters.addAll(getDiscoveredConverters(appInfo));
result = new PayaraConfig(sources, converters);
appInfo.addTransientAppMetaData(METADATA_KEY, result);
}
}
return result;
}
Aggregations