Search in sources :

Example 1 with ConfigSource

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;
}
Also used : PropertiesConfigSource(fish.payara.nucleus.microprofile.config.source.PropertiesConfigSource) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ClusterConfigSource(fish.payara.nucleus.microprofile.config.source.ClusterConfigSource) EnvironmentConfigSource(fish.payara.nucleus.microprofile.config.source.EnvironmentConfigSource) PayaraServerProperties(fish.payara.nucleus.microprofile.config.source.PayaraServerProperties) PayaraServerProperties(fish.payara.nucleus.microprofile.config.source.PayaraServerProperties) Properties(java.util.Properties) LinkedList(java.util.LinkedList) ServerConfigSource(fish.payara.nucleus.microprofile.config.source.ServerConfigSource) SystemPropertyConfigSource(fish.payara.nucleus.microprofile.config.source.SystemPropertyConfigSource) ServerConfigSource(fish.payara.nucleus.microprofile.config.source.ServerConfigSource) ConfigSource(org.eclipse.microprofile.config.spi.ConfigSource) ModuleConfigSource(fish.payara.nucleus.microprofile.config.source.ModuleConfigSource) ConfigConfigSource(fish.payara.nucleus.microprofile.config.source.ConfigConfigSource) EnvironmentConfigSource(fish.payara.nucleus.microprofile.config.source.EnvironmentConfigSource) SecretsDirConfigSource(fish.payara.nucleus.microprofile.config.source.SecretsDirConfigSource) ApplicationConfigSource(fish.payara.nucleus.microprofile.config.source.ApplicationConfigSource) ClusterConfigSource(fish.payara.nucleus.microprofile.config.source.ClusterConfigSource) JNDIConfigSource(fish.payara.nucleus.microprofile.config.source.JNDIConfigSource) PropertiesConfigSource(fish.payara.nucleus.microprofile.config.source.PropertiesConfigSource) DomainConfigSource(fish.payara.nucleus.microprofile.config.source.DomainConfigSource) ModuleConfigSource(fish.payara.nucleus.microprofile.config.source.ModuleConfigSource) ConfigConfigSource(fish.payara.nucleus.microprofile.config.source.ConfigConfigSource) DomainConfigSource(fish.payara.nucleus.microprofile.config.source.DomainConfigSource) SystemPropertyConfigSource(fish.payara.nucleus.microprofile.config.source.SystemPropertyConfigSource) SecretsDirConfigSource(fish.payara.nucleus.microprofile.config.source.SecretsDirConfigSource) ApplicationConfigSource(fish.payara.nucleus.microprofile.config.source.ApplicationConfigSource) JNDIConfigSource(fish.payara.nucleus.microprofile.config.source.JNDIConfigSource)

Example 2 with ConfigSource

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;
}
Also used : SystemPropertyConfigSource(fish.payara.nucleus.microprofile.config.source.SystemPropertyConfigSource) ServerConfigSource(fish.payara.nucleus.microprofile.config.source.ServerConfigSource) ConfigSource(org.eclipse.microprofile.config.spi.ConfigSource) ModuleConfigSource(fish.payara.nucleus.microprofile.config.source.ModuleConfigSource) ConfigConfigSource(fish.payara.nucleus.microprofile.config.source.ConfigConfigSource) EnvironmentConfigSource(fish.payara.nucleus.microprofile.config.source.EnvironmentConfigSource) SecretsDirConfigSource(fish.payara.nucleus.microprofile.config.source.SecretsDirConfigSource) ApplicationConfigSource(fish.payara.nucleus.microprofile.config.source.ApplicationConfigSource) ClusterConfigSource(fish.payara.nucleus.microprofile.config.source.ClusterConfigSource) JNDIConfigSource(fish.payara.nucleus.microprofile.config.source.JNDIConfigSource) PropertiesConfigSource(fish.payara.nucleus.microprofile.config.source.PropertiesConfigSource) DomainConfigSource(fish.payara.nucleus.microprofile.config.source.DomainConfigSource) ConfigSourceProvider(org.eclipse.microprofile.config.spi.ConfigSourceProvider)

Example 3 with ConfigSource

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;
}
Also used : SystemPropertyConfigSource(fish.payara.nucleus.microprofile.config.source.SystemPropertyConfigSource) ServerConfigSource(fish.payara.nucleus.microprofile.config.source.ServerConfigSource) ConfigSource(org.eclipse.microprofile.config.spi.ConfigSource) ModuleConfigSource(fish.payara.nucleus.microprofile.config.source.ModuleConfigSource) ConfigConfigSource(fish.payara.nucleus.microprofile.config.source.ConfigConfigSource) EnvironmentConfigSource(fish.payara.nucleus.microprofile.config.source.EnvironmentConfigSource) SecretsDirConfigSource(fish.payara.nucleus.microprofile.config.source.SecretsDirConfigSource) ApplicationConfigSource(fish.payara.nucleus.microprofile.config.source.ApplicationConfigSource) ClusterConfigSource(fish.payara.nucleus.microprofile.config.source.ClusterConfigSource) JNDIConfigSource(fish.payara.nucleus.microprofile.config.source.JNDIConfigSource) PropertiesConfigSource(fish.payara.nucleus.microprofile.config.source.PropertiesConfigSource) DomainConfigSource(fish.payara.nucleus.microprofile.config.source.DomainConfigSource) Config(org.eclipse.microprofile.config.Config) ChronoUnitConverter(fish.payara.nucleus.microprofile.config.converters.ChronoUnitConverter) LongConverter(fish.payara.nucleus.microprofile.config.converters.LongConverter) OffsetDateTimeConverter(fish.payara.nucleus.microprofile.config.converters.OffsetDateTimeConverter) Converter(org.eclipse.microprofile.config.spi.Converter) DoubleConverter(fish.payara.nucleus.microprofile.config.converters.DoubleConverter) OffsetTimeConverter(fish.payara.nucleus.microprofile.config.converters.OffsetTimeConverter) InstantConverter(fish.payara.nucleus.microprofile.config.converters.InstantConverter) IntegerConverter(fish.payara.nucleus.microprofile.config.converters.IntegerConverter) LocalTimeConverter(fish.payara.nucleus.microprofile.config.converters.LocalTimeConverter) BooleanConverter(fish.payara.nucleus.microprofile.config.converters.BooleanConverter) DurationConverter(fish.payara.nucleus.microprofile.config.converters.DurationConverter) URLConverter(fish.payara.nucleus.microprofile.config.converters.URLConverter) LocalDateTimeConverter(fish.payara.nucleus.microprofile.config.converters.LocalDateTimeConverter) InetAddressConverter(fish.payara.nucleus.microprofile.config.converters.InetAddressConverter) FloatConverter(fish.payara.nucleus.microprofile.config.converters.FloatConverter) LocalDateConverter(fish.payara.nucleus.microprofile.config.converters.LocalDateConverter) LinkedList(java.util.LinkedList)

Aggregations

ApplicationConfigSource (fish.payara.nucleus.microprofile.config.source.ApplicationConfigSource)3 ClusterConfigSource (fish.payara.nucleus.microprofile.config.source.ClusterConfigSource)3 ConfigConfigSource (fish.payara.nucleus.microprofile.config.source.ConfigConfigSource)3 DomainConfigSource (fish.payara.nucleus.microprofile.config.source.DomainConfigSource)3 EnvironmentConfigSource (fish.payara.nucleus.microprofile.config.source.EnvironmentConfigSource)3 JNDIConfigSource (fish.payara.nucleus.microprofile.config.source.JNDIConfigSource)3 ModuleConfigSource (fish.payara.nucleus.microprofile.config.source.ModuleConfigSource)3 PropertiesConfigSource (fish.payara.nucleus.microprofile.config.source.PropertiesConfigSource)3 SecretsDirConfigSource (fish.payara.nucleus.microprofile.config.source.SecretsDirConfigSource)3 ServerConfigSource (fish.payara.nucleus.microprofile.config.source.ServerConfigSource)3 SystemPropertyConfigSource (fish.payara.nucleus.microprofile.config.source.SystemPropertyConfigSource)3 ConfigSource (org.eclipse.microprofile.config.spi.ConfigSource)3 LinkedList (java.util.LinkedList)2 BooleanConverter (fish.payara.nucleus.microprofile.config.converters.BooleanConverter)1 ChronoUnitConverter (fish.payara.nucleus.microprofile.config.converters.ChronoUnitConverter)1 DoubleConverter (fish.payara.nucleus.microprofile.config.converters.DoubleConverter)1 DurationConverter (fish.payara.nucleus.microprofile.config.converters.DurationConverter)1 FloatConverter (fish.payara.nucleus.microprofile.config.converters.FloatConverter)1 InetAddressConverter (fish.payara.nucleus.microprofile.config.converters.InetAddressConverter)1 InstantConverter (fish.payara.nucleus.microprofile.config.converters.InstantConverter)1