@SuppressWarnings("UnusedDeclaration") public void registerUserConfigSources(@Observes AfterDeploymentValidation adv) { if (!isActivated) { return; } List<ConfigSource> configSources = new ArrayList<ConfigSource>(); for (Class<? extends PropertyFileConfig> propertyFileConfigClass : configSourcesClasses) { configSources.addAll(createPropertyConfigSource(propertyFileConfigClass)); } // finally add all ConfigResolver.addConfigSources(configSources); }
public void validateConfiguration(@Observes AfterDeploymentValidation adv) { List<ConfigSource> configSources = new ArrayList<ConfigSource>(cdiSources.size()); for (final Bean bean : cdiSources) { configSources.add(BeanProvider.getContextualReference(ConfigSource.class, bean)); } ConfigResolver.addConfigSources(configSources); for (final Bean bean : cdiFilters) { ConfigResolver.addConfigFilter(BeanProvider.getContextualReference(ConfigFilter.class, bean)); } processConfigurationValidation(adv); }
@SuppressWarnings("UnusedDeclaration") public void registerUserConfigSources(@Observes AfterBeanDiscovery abd) { 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); // now let's add our own PropertyFileConfigs to the detected ones. // 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)); } ConfigResolver.addConfigSources(configSources); registerConfigMBean(); logConfiguration(); }
ConfigResolver.addConfigSources(Arrays.<ConfigSource>asList(testConfigSource));
@Test // this test validates we read the config properly but also it is lazy public void configuredPool() throws ExecutionException, InterruptedException { ConfigResolver.addConfigSources(Collections.<ConfigSource>singletonList(new PropertiesConfigSource(new Properties() {{ setProperty("futurable.pool.custom.coreSize", "5"); }}) { @Override public String getConfigName() { return "configuredPool"; } })); final ExecutorService custom = manager.find("custom"); assertEquals(custom, custom); assertSame(custom, custom); assertEquals(5, ThreadPoolExecutor.class.cast(custom).getCorePoolSize()); assertUsable(custom); }