use of org.eclipse.microprofile.config.spi.ConfigSource in project Payara by payara.
the class ConfigProviderResolverImpl method getDefaultSources.
List<ConfigSource> getDefaultSources() {
LinkedList<ConfigSource> sources = new LinkedList<>();
String appName = null;
String moduleName = null;
ComponentInvocation currentInvocation = invocationManager.getCurrentInvocation();
if (currentInvocation == null) {
ApplicationInfo info = getAppInfo(Thread.currentThread().getContextClassLoader());
if (info != null) {
appName = info.getName();
moduleName = appName;
}
} else {
appName = currentInvocation.getAppName();
moduleName = currentInvocation.getModuleName();
}
String serverName = context.getInstanceName();
String configName = context.getConfigBean().getConfig().getName();
sources.add(new DomainConfigSource());
sources.add(new ClusterConfigSource());
sources.add(new ConfigConfigSource(configName));
sources.add(new ServerConfigSource(serverName));
sources.add(new EnvironmentConfigSource());
sources.add(new SystemPropertyConfigSource());
sources.add(new JNDIConfigSource());
sources.add(new PayaraServerProperties());
sources.add(new SecretsDirConfigSource());
if (appName != null) {
sources.add(new ApplicationConfigSource(appName));
sources.add(new ModuleConfigSource(appName, moduleName));
for (Properties props : getDeployedApplicationProperties(appName)) {
sources.add(new PropertiesConfigSource(props, appName));
}
}
return sources;
}
use of org.eclipse.microprofile.config.spi.ConfigSource in project Payara by payara.
the class ConfigProviderResolverImpl method getDiscoveredSources.
List<ConfigSource> getDiscoveredSources(ApplicationInfo appInfo) {
LinkedList<ConfigSource> sources = appInfo.getTransientAppMetaData(CUSTOM_SOURCES_KEY, LinkedList.class);
if (sources == null) {
sources = new LinkedList<>();
// resolve custom config sources
ServiceLoader<ConfigSource> serviceLoader = ServiceLoader.load(ConfigSource.class, appInfo.getAppClassLoader());
for (ConfigSource configSource : serviceLoader) {
sources.add(configSource);
}
//
ServiceLoader<ConfigSourceProvider> serviceProvideLoader = ServiceLoader.load(ConfigSourceProvider.class, appInfo.getAppClassLoader());
for (ConfigSourceProvider configSourceProvider : serviceProvideLoader) {
Iterable<ConfigSource> configSources = configSourceProvider.getConfigSources(appInfo.getAppClassLoader());
for (ConfigSource configSource : configSources) {
sources.add(configSource);
}
}
appInfo.addTransientAppMetaData(CUSTOM_SOURCES_KEY, sources);
}
return sources;
}
use of org.eclipse.microprofile.config.spi.ConfigSource 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