/** * Create an instance and start polling the source. * * @param initialDelayMillis initial delay in milliseconds used by {@link FixedDelayPollingScheduler} * @param delayMillis delay interval in milliseconds used by {@link FixedDelayPollingScheduler} * @param ignoreDeletesFromSource whether the scheduler should ignore deletes of properties from configuration source when * applying the polling result to a configuration. * @param urls The set of URLs to be polled by {@link URLConfigurationSource} */ public DynamicURLConfiguration(int initialDelayMillis, int delayMillis, boolean ignoreDeletesFromSource, String... urls) { super(new URLConfigurationSource(urls), new FixedDelayPollingScheduler(initialDelayMillis, delayMillis, ignoreDeletesFromSource)); } }
@Override protected synchronized void initialLoad(PolledConfigurationSource source, Configuration config) { try { super.initialLoad(source, config); } catch (Exception err) { LOGGER.warn("Initial dynamic configuration load failed", err); } } }
@Override protected synchronized void schedule(Runnable runnable) { tasks.add(runnable); super.schedule(runnable); }
/** * Create an instance and start polling the source. * * @param initialDelayMillis initial delay in milliseconds used by {@link FixedDelayPollingScheduler} * @param delayMillis delay interval in milliseconds used by {@link FixedDelayPollingScheduler} * @param ignoreDeletesFromSource whether the scheduler should ignore deletes of properties from configuration source when * applying the polling result to a configuration. * @param urls The set of URLs to be polled by {@link URLConfigurationSource} */ public DynamicURLConfiguration(int initialDelayMillis, int delayMillis, boolean ignoreDeletesFromSource, String... urls) { super(new URLConfigurationSource(urls), new FixedDelayPollingScheduler(initialDelayMillis, delayMillis, ignoreDeletesFromSource)); } }
@Override protected synchronized void initialLoad(PolledConfigurationSource source, Configuration config) { try { super.initialLoad(source, config); } catch (Exception err) { LOGGER.warn("Initial dynamic configuration load failed", err); } } }
private void initializeConfiguration() { // FixedDelayPollingScheduler is initialized with default system // settings // Fixed delay in milliseconds between two reads of the configuration // URLs // archaius.fixedDelayPollingScheduler.delayMills = 60000 // Initial delay in milliseconds of reading from the configuration // source // archaius.fixedDelayPollingScheduler.initialDelayMills = 30000 AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler(); // Configuration source that brings dynamic changes to the configuration // via polling PolledConfigurationSource source = new XMLPolledConfigurationSource(); // Configuration that polls a PolledConfigurationSource according to the // schedule set by a scheduler DynamicConfiguration configuration = new DynamicConfiguration(source, scheduler); ConfigurationManager.install(configuration); // Registering configuration with an MBean and will be accessible for // read and update via JConsole ConfigJMXManager.registerConfigMbean(configuration); }
@Bean static AbstractPollingScheduler pollingScheduler(ConfigurableApplicationContext applicationContext) { int initialDelayMillis = applicationContext.getEnvironment().getProperty(FixedDelayPollingScheduler.INITIAL_DELAY_PROPERTY, Integer.class, 0); int delayMillis = applicationContext.getEnvironment().getProperty(FixedDelayPollingScheduler.DELAY_PROPERTY, Integer.class, (int) TimeUnit.SECONDS.toMillis(15)); return new FixedDelayPollingScheduler(initialDelayMillis, delayMillis, false); }
/** * Create an instance with default {@link URLConfigurationSource#URLConfigurationSource()} and * {@link FixedDelayPollingScheduler#FixedDelayPollingScheduler()} and start polling the source * if there is any URLs available for polling. */ public DynamicURLConfiguration() { URLConfigurationSource source = new URLConfigurationSource(); if (source.getConfigUrls() != null && source.getConfigUrls().size() > 0) { startPolling(source, new FixedDelayPollingScheduler()); } }
/** * Create an instance with default {@link URLConfigurationSource#URLConfigurationSource()} and * {@link FixedDelayPollingScheduler#FixedDelayPollingScheduler()} and start polling the source * if there is any URLs available for polling. */ public DynamicURLConfiguration() { URLConfigurationSource source = new URLConfigurationSource(); if (source.getConfigUrls() != null && source.getConfigUrls().size() > 0) { startPolling(source, new FixedDelayPollingScheduler()); } }
return; AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler( config.getInt("dynamicConfigSource.initDelayMillis"), config.getInt("dynamicConfigSource.delayMillis"),