public static void installDynamicConfig() { if (ConfigurationManager.isConfigurationInstalled()) { LOGGER.warn("Configuration installed by others, will ignore this configuration."); return; } ConcurrentCompositeConfiguration compositeConfig = ConfigUtil.createLocalConfig(); ConfigCenterConfigurationSource configCenterConfigurationSource = createConfigCenterConfigurationSource(compositeConfig); if (configCenterConfigurationSource != null) { createDynamicWatchedConfiguration(compositeConfig, configCenterConfigurationSource); } ConfigurationManager.install(compositeConfig); if (configCenterConfigurationSource != null) { configCenterConfigurationSource.init(compositeConfig); } }
/** * Register Dynamic configuration. * * @param dc * archiaus {@link DynamicConfiguration} settings */ public PropertyStoreArchaius(AbstractConfiguration dc) { super(dc); if (!ConfigurationManager.isConfigurationInstalled()) { ConfigurationManager.install(dc); } }
if (configFromManager != null) { initWithConfigurationSource(configFromManager); initializedWithDefaultConfig = !ConfigurationManager.isConfigurationInstalled(); logger.info("DynamicPropertyFactory is initialized with configuration sources: " + configFromManager);
public ArchaiusInitializingBeanPostProcessor(ConfigurableApplicationContext applicationContext, AbstractPollingScheduler pollingScheduler, SpringEnvironmentPolledConfigurationSource polledConfigurationSource, List<ClasspathPropertySource> propertyBindings) { this.applicationContext = Objects.requireNonNull(applicationContext, "applicationContext"); this.pollingScheduler = Objects.requireNonNull(pollingScheduler, "pollingScheduler"); this.polledConfigurationSource = Objects.requireNonNull(polledConfigurationSource, "polledConfigurationSource"); this.propertyBindings = propertyBindings != null ? propertyBindings : Collections.emptyList(); initPropertyBindings(); configurationInstance = new DynamicConfiguration(polledConfigurationSource, pollingScheduler); if (!ConfigurationManager.isConfigurationInstalled()) { ConfigurationManager.install(new CompositeConfiguration()); } CompositeConfiguration config = (CompositeConfiguration) ConfigurationManager.getConfigInstance(); config.addConfiguration(configurationInstance); applicationContext.getBeanFactory().registerSingleton("environmentBackedConfig", ConfigurationManager.getConfigInstance()); applicationContext.getBeanFactory().registerAlias("environmentBackedConfig", "abstractConfiguration"); }
if (configFromManager != null) { initWithConfigurationSource(configFromManager); initializedWithDefaultConfig = !ConfigurationManager.isConfigurationInstalled(); logger.info("DynamicPropertyFactory is initialized with configuration sources: " + configFromManager);
/** * Initialize the factory with an AbstractConfiguration. * <p/> * The initialization will register a ConfigurationListener with the configuration so that {@link DynamicProperty} * will receives a callback and refresh its value when a property is changed in the configuration. * <p/> * If the factory is already initialized with a default configuration source (see {@link #getInstance()}), it will re-register * itself with the new configuration source passed to this method. Otherwise, this method will throw IllegalArgumentException * if it has been initialized with a different and non-default configuration source. This method should be only called once. * * @param config Configuration to be attached with DynamicProperty * @return the instance of DynamicPropertyFactory * @throws IllegalArgumentException if the factory has already been initialized with a non-default configuration source */ public static DynamicPropertyFactory initWithConfigurationSource(AbstractConfiguration config) { synchronized (ConfigurationManager.class) { if (config == null) { throw new NullPointerException("config is null"); } if (ConfigurationManager.isConfigurationInstalled() && config != ConfigurationManager.instance) { throw new IllegalStateException("ConfigurationManager is already initialized with configuration " + ConfigurationManager.getConfigInstance()); } if (config instanceof DynamicPropertySupport) { return initWithConfigurationSource((DynamicPropertySupport) config); } return initWithConfigurationSource(new ConfigurationBackedDynamicPropertySupportImpl(config)); } }
throw new IllegalStateException("DynamicPropertyFactory is already initialized with a diffrerent configuration source: " + config); if (ConfigurationManager.isConfigurationInstalled() && (configuration != null && configuration != ConfigurationManager.instance)) { throw new IllegalStateException("ConfigurationManager is already initialized with configuration "
/** * Initialize the factory with an AbstractConfiguration. * <p/> * The initialization will register a ConfigurationListener with the configuration so that {@link DynamicProperty} * will receives a callback and refresh its value when a property is changed in the configuration. * <p/> * If the factory is already initialized with a default configuration source (see {@link #getInstance()}), it will re-register * itself with the new configuration source passed to this method. Otherwise, this method will throw IllegalArgumentException * if it has been initialized with a different and non-default configuration source. This method should be only called once. * * @param config Configuration to be attached with DynamicProperty * @return the instance of DynamicPropertyFactory * @throws IllegalArgumentException if the factory has already been initialized with a non-default configuration source */ public static DynamicPropertyFactory initWithConfigurationSource(AbstractConfiguration config) { synchronized (ConfigurationManager.class) { if (config == null) { throw new NullPointerException("config is null"); } if (ConfigurationManager.isConfigurationInstalled() && config != ConfigurationManager.instance) { throw new IllegalStateException("ConfigurationManager is already initialized with configuration " + ConfigurationManager.getConfigInstance()); } if (config instanceof DynamicPropertySupport) { return initWithConfigurationSource((DynamicPropertySupport) config); } return initWithConfigurationSource(new ConfigurationBackedDynamicPropertySupportImpl(config)); } }
private static void addArchaiusConfiguration(ConcurrentCompositeConfiguration config) { if (ConfigurationManager.isConfigurationInstalled()) { AbstractConfiguration installedConfiguration = ConfigurationManager .getConfigInstance(); if (installedConfiguration instanceof ConcurrentCompositeConfiguration) { ConcurrentCompositeConfiguration configInstance = (ConcurrentCompositeConfiguration) installedConfiguration; configInstance.addConfiguration(config); } else { installedConfiguration.append(config); if (!(installedConfiguration instanceof AggregatedConfiguration)) { log.warn( "Appending a configuration to an existing non-aggregated installed configuration will have no effect"); } } } else { ConfigurationManager.install(config); } }
throw new IllegalStateException("DynamicPropertyFactory is already initialized with a diffrerent configuration source: " + config); if (ConfigurationManager.isConfigurationInstalled() && (configuration != null && configuration != ConfigurationManager.instance)) { throw new IllegalStateException("ConfigurationManager is already initialized with configuration "
public static void installDynamicConfig() { if (ConfigurationManager.isConfigurationInstalled()) { LOGGER.warn("Configuration installed by others, will ignore this configuration."); return; } ConcurrentCompositeConfiguration compositeConfig = ConfigUtil.createLocalConfig(); ConfigCenterConfigurationSource configCenterConfigurationSource = createConfigCenterConfigurationSource(compositeConfig); if (configCenterConfigurationSource != null) { createDynamicWatchedConfiguration(compositeConfig, configCenterConfigurationSource); } ConfigurationManager.install(compositeConfig); if (configCenterConfigurationSource != null) { configCenterConfigurationSource.init(compositeConfig); } }
private void addArchaiusConfiguration(ConcurrentCompositeConfiguration config) { if (ConfigurationManager.isConfigurationInstalled()) { AbstractConfiguration installedConfiguration = ConfigurationManager .getConfigInstance(); if (installedConfiguration instanceof ConcurrentCompositeConfiguration) { ConcurrentCompositeConfiguration configInstance = (ConcurrentCompositeConfiguration) installedConfiguration; configInstance.addConfiguration(config); } else { installedConfiguration.append(config); // if (!(installedConfiguration instanceof AggregatedConfiguration)) { // //log.warn( // // "Appending a configuration to an existing non-aggregated // //installed configuration will have no effect"); // } } } else { ConfigurationManager.install(config); } }