Search in sources :

Example 11 with ConfigSource

use of org.apache.deltaspike.core.spi.config.ConfigSource in project deltaspike by apache.

the class ConfigurationExtension method registerUserConfigSources.

@SuppressWarnings("UnusedDeclaration")
public void registerUserConfigSources(@Observes AfterDeploymentValidation adv) {
    if (!isActivated) {
        return;
    }
    // create a local copy with all the collected PropertyFileConfig
    Set<Class<? extends PropertyFileConfig>> allPropertyFileConfigClasses = new HashSet<Class<? extends PropertyFileConfig>>(this.propertyFileConfigClasses);
    // now add any PropertyFileConfigs from a 'parent BeanManager'
    // we start with the current TCCL
    ClassLoader currentClassLoader = ClassUtils.getClassLoader(null);
    addParentPropertyFileConfigs(currentClassLoader, allPropertyFileConfigClasses);
    // because maybe WE are a parent BeanManager ourselves!
    if (!this.propertyFileConfigClasses.isEmpty()) {
        detectedParentPropertyFileConfigs.put(currentClassLoader, this.propertyFileConfigClasses);
    }
    // collect all the ConfigSources from our PropertyFileConfigs
    List<ConfigSource> configSources = new ArrayList<ConfigSource>();
    for (Class<? extends PropertyFileConfig> propertyFileConfigClass : allPropertyFileConfigClasses) {
        configSources.addAll(createPropertyConfigSource(propertyFileConfigClass));
    }
    for (final Bean bean : cdiSources) {
        configSources.add(BeanProvider.getContextualReference(ConfigSource.class, bean));
    }
    // finally add all
    ConfigResolver.addConfigSources(configSources);
    for (final Bean bean : cdiFilters) {
        ConfigResolver.addConfigFilter(BeanProvider.getContextualReference(ConfigFilter.class, bean));
    }
    processConfigurationValidation(adv);
    registerConfigMBean();
    logConfiguration();
}
Also used : ConfigSource(org.apache.deltaspike.core.spi.config.ConfigSource) ArrayList(java.util.ArrayList) PropertyFileConfig(org.apache.deltaspike.core.api.config.PropertyFileConfig) HashSet(java.util.HashSet) ProcessBean(javax.enterprise.inject.spi.ProcessBean) Bean(javax.enterprise.inject.spi.Bean) ConfigFilter(org.apache.deltaspike.core.spi.config.ConfigFilter)

Aggregations

ConfigSource (org.apache.deltaspike.core.spi.config.ConfigSource)11 ArrayList (java.util.ArrayList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)2 CompositeType (javax.management.openmbean.CompositeType)2 OpenDataException (javax.management.openmbean.OpenDataException)2 OpenType (javax.management.openmbean.OpenType)2 TabularDataSupport (javax.management.openmbean.TabularDataSupport)2 TabularType (javax.management.openmbean.TabularType)2 ConfigFilter (org.apache.deltaspike.core.spi.config.ConfigFilter)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Bean (javax.enterprise.inject.spi.Bean)1 ProcessBean (javax.enterprise.inject.spi.ProcessBean)1 PropertyFileConfig (org.apache.deltaspike.core.api.config.PropertyFileConfig)1 ConfigSourceProvider (org.apache.deltaspike.core.spi.config.ConfigSourceProvider)1