@Override public void load() { String appNameToUse = appName; if (null == appNameToUse) { appNameToUse = ConfigurationManager.getDeploymentContext().getApplicationId(); } try { logger.info(String.format("Loading application properties with app id: %s and environment: %s", appNameToUse, ConfigurationManager.getDeploymentContext().getDeploymentEnvironment())); /** * This loads a property file with the name "appName".properties and "appName"-"env".properties, if found. */ ConfigurationManager.loadCascadedPropertiesFromResources(appNameToUse); } catch (IOException e) { logger.error(String.format( "Failed to load properties for application id: %s and environment: %s. This is ok, if you do not have application level properties.", appNameToUse, ConfigurationManager.getDeploymentContext().getDeploymentEnvironment()), e); } } }
@Override public void load() { String appNameToUse = appName; if (null == appNameToUse) { appNameToUse = ConfigurationManager.getDeploymentContext().getApplicationId(); } try { logger.info(String.format("Loading application properties with app id: %s and environment: %s", appNameToUse, ConfigurationManager.getDeploymentContext().getDeploymentEnvironment())); /** * This loads a property file with the name "appName".properties and "appName"-"env".properties, if found. */ ConfigurationManager.loadCascadedPropertiesFromResources(appNameToUse); } catch (IOException e) { logger.error(String.format( "Failed to load properties for application id: %s and environment: %s. This is ok, if you do not have application level properties.", appNameToUse, ConfigurationManager.getDeploymentContext().getDeploymentEnvironment()), e); } } }
@Override public void load() { String appNameToUse = appName; if (null == appNameToUse) { appNameToUse = ConfigurationManager.getDeploymentContext().getApplicationId(); } try { logger.info(String.format("Loading application properties with app id: %s and environment: %s", appNameToUse, ConfigurationManager.getDeploymentContext().getDeploymentEnvironment())); /** * This loads a property file with the name "appName".properties and "appName"-"env".properties, if found. */ ConfigurationManager.loadCascadedPropertiesFromResources(appNameToUse); } catch (IOException e) { logger.error(String.format( "Failed to load properties for application id: %s and environment: %s. This is ok, if you do not have application level properties.", appNameToUse, ConfigurationManager.getDeploymentContext().getDeploymentEnvironment()), e); } } }
@Override protected AbstractConfiguration getConfiguration() { AbstractConfiguration config = ConfigurationManager.getConfigInstance(); boolean dynamic = config.getBoolean(DYNAMIC_CONFIG, true); if (!dynamic) { return new DynamicConfiguration(); } else { String appId = null; DeploymentContext context = ConfigurationManager.getDeploymentContext(); appId = context.getApplicationId(); if (appId == null) { throw new RuntimeException( "Archaius deployment context's applicationId not set (archaius.deployment.applicationId)"); } String consulHost = config.getString(CONSUL_HOST, CONSUL_DEFAULT_HOST); int consulPort = config.getInt(CONSUL_PORT, 8500); String consulAclToken = config.getString(CONSUL_TOKEN); ConsulWatchedConfigurationSource configSource = new ConsulWatchedConfigurationSource(appId, new ConsulClient(consulHost, consulPort), 30, TimeUnit.SECONDS, consulAclToken); // do the first update synchronously try { configSource.runOnce(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } configSource.startAsync(); return new DynamicWatchedConfiguration(configSource); } }