use of org.apache.deltaspike.core.api.config.PropertyFileConfig in project crnk-framework by crnk-project.
the class GeneratorConfigSourceProvider method registerPropertyFileConfigs.
/**
* Load all {@link PropertyFileConfig}s which are registered via
* {@code java.util.ServiceLoader}.
*/
private void registerPropertyFileConfigs() {
List<? extends PropertyFileConfig> propertyFileConfigs = ServiceUtils.loadServiceImplementations(PropertyFileConfig.class);
for (PropertyFileConfig propertyFileConfig : propertyFileConfigs) {
EnvironmentPropertyConfigSourceProvider environmentPropertyConfigSourceProvider = new EnvironmentPropertyConfigSourceProvider(propertyFileConfig.getPropertyFileName(), propertyFileConfig.isOptional());
configSources.addAll(environmentPropertyConfigSourceProvider.getConfigSources());
}
}
use of org.apache.deltaspike.core.api.config.PropertyFileConfig in project deltaspike by apache.
the class ConfigurationExtension method createPropertyConfigSource.
/**
* @return create an instance of the given {@link PropertyFileConfig} and return all it's ConfigSources.
*/
private List<ConfigSource> createPropertyConfigSource(Class<? extends PropertyFileConfig> propertyFileConfigClass) {
String fileName = "";
try {
PropertyFileConfig propertyFileConfig = propertyFileConfigClass.newInstance();
fileName = propertyFileConfig.getPropertyFileName();
EnvironmentPropertyConfigSourceProvider environmentPropertyConfigSourceProvider = new EnvironmentPropertyConfigSourceProvider(fileName, propertyFileConfig.isOptional());
return environmentPropertyConfigSourceProvider.getConfigSources();
} catch (InstantiationException e) {
throw new RuntimeException(CANNOT_CREATE_CONFIG_SOURCE_FOR_CUSTOM_PROPERTY_FILE_CONFIG + propertyFileConfigClass.getName(), e);
} catch (IllegalAccessException e) {
throw new RuntimeException(CANNOT_CREATE_CONFIG_SOURCE_FOR_CUSTOM_PROPERTY_FILE_CONFIG + propertyFileConfigClass.getName(), e);
} catch (IllegalStateException e) {
throw new IllegalStateException(propertyFileConfigClass.getName() + " points to an invalid file: '" + fileName + "'", e);
}
}
use of org.apache.deltaspike.core.api.config.PropertyFileConfig in project deltaspike by apache.
the class DefaultConfigSourceProvider method registerPropertyFileConfigs.
/**
* Load all {@link PropertyFileConfig}s which are registered via
* {@code java.util.ServiceLoader}.
*/
private void registerPropertyFileConfigs() {
List<? extends PropertyFileConfig> propertyFileConfigs = ServiceUtils.loadServiceImplementations(PropertyFileConfig.class);
for (PropertyFileConfig propertyFileConfig : propertyFileConfigs) {
EnvironmentPropertyConfigSourceProvider environmentPropertyConfigSourceProvider = new EnvironmentPropertyConfigSourceProvider(propertyFileConfig.getPropertyFileName(), propertyFileConfig.isOptional());
configSources.addAll(environmentPropertyConfigSourceProvider.getConfigSources());
}
}
use of org.apache.deltaspike.core.api.config.PropertyFileConfig 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();
}
Aggregations