public PropertiesInstanceConfig(String namespace, DataCenterInfo info) { super(info); this.namespace = namespace.endsWith(".") ? namespace : namespace + "."; appGrpNameFromEnv = ConfigurationManager.getConfigInstance() .getString(FALLBACK_APP_GROUP_KEY, Values.UNKNOWN_APPLICATION); this.configInstance = Archaius1Utils.initConfig(CommonConstants.CONFIG_FILE_NAME); }
/** * Users can override to initialize the environment themselves. */ protected void initEurekaEnvironment() throws Exception { logger.info("Setting the eureka configuration.."); String dataCenter = ConfigurationManager.getConfigInstance().getString(EUREKA_DATACENTER); if (dataCenter == null) { logger.info("Eureka data center value eureka.datacenter is not set, defaulting to default"); ConfigurationManager.getConfigInstance().setProperty(ARCHAIUS_DEPLOYMENT_DATACENTER, DEFAULT); } else { ConfigurationManager.getConfigInstance().setProperty(ARCHAIUS_DEPLOYMENT_DATACENTER, dataCenter); } String environment = ConfigurationManager.getConfigInstance().getString(EUREKA_ENVIRONMENT); if (environment == null) { ConfigurationManager.getConfigInstance().setProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT, TEST); logger.info("Eureka environment value eureka.environment is not set, defaulting to test"); } }
private void init() { String env = ConfigurationManager.getConfigInstance().getString( EUREKA_ENVIRONMENT, TEST); ConfigurationManager.getConfigInstance().setProperty( ARCHAIUS_DEPLOYMENT_ENVIRONMENT, env); String eurekaPropsFile = EUREKA_PROPS_FILE.get(); try { // ConfigurationManager // .loadPropertiesFromResources(eurekaPropsFile); ConfigurationManager .loadCascadedPropertiesFromResources(eurekaPropsFile); } catch (IOException e) { logger.warn( "Cannot find the properties specified : {}. This may be okay if there are other environment " + "specific properties or the configuration is installed with a different mechanism.", eurekaPropsFile); } }
public static DynamicPropertyFactory initConfig(String configName) { DynamicPropertyFactory configInstance = DynamicPropertyFactory.getInstance(); DynamicStringProperty EUREKA_PROPS_FILE = configInstance.getStringProperty("eureka.client.props", configName); String env = ConfigurationManager.getConfigInstance().getString(EUREKA_ENVIRONMENT, "test"); ConfigurationManager.getConfigInstance().setProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT, env); String eurekaPropsFile = EUREKA_PROPS_FILE.get(); try { ConfigurationManager.loadCascadedPropertiesFromResources(eurekaPropsFile); } catch (IOException e) { logger.warn( "Cannot find the properties specified : {}. This may be okay if there are other environment " + "specific properties or the configuration is installed with a different mechanism.", eurekaPropsFile); } return configInstance; } }
@Override public String getAlertMessage() { return config.getString("com.netflix.explorers." + name + ".alert_message"); }
/** * Reads a String from the given XML node. * @param config XML node containing a String * @param key attribute key * @param def default String value * @return String from the given XML node. <code>def</code> if a String * cannot be read */ public static String getStringAttribute(AbstractConfiguration config,String key, String def){ return config.getString(attributeKey(key), def); }
/** * Reads a String from the given XML node. * @param config XML node containing a String * @param key attribute key * @param def default String value * @return String from the given XML node. <code>def</code> if a String * cannot be read */ public static String getStringAttribute(AbstractConfiguration config,String key, String def){ return config.getString(attributeKey(key), def); }
private List<String> getAdminPagesPackagesToScan() { final String adminPagesPkgPath = ConfigurationManager.getConfigInstance().getString(PROP_ID_ADMIN_PAGES_SCAN, DEFAULT_SCAN_PKG); String[] pkgPaths = adminPagesPkgPath.split(";"); return Lists.newArrayList(pkgPaths); }
private List<String> getAdminPagesPackagesToScan() { final String adminPagesPkgPath = ConfigurationManager.getConfigInstance().getString(PROP_ID_ADMIN_PAGES_SCAN, DEFAULT_SCAN_PKG); String[] pkgPaths = adminPagesPkgPath.split(";"); return Lists.newArrayList(pkgPaths); }
@Override protected Collection<String> getBasePackages() { List<String> toReturn = new ArrayList<String>(); String basePackagesStr = ConfigurationManager.getConfigInstance().getString(PropertyNames.SERVER_BOOTSTRAP_BASE_PACKAGES_OVERRIDE); String[] basePackages = basePackagesStr.split(";"); for (String basePackage : basePackages) { toReturn.add(String.valueOf(basePackage)); } return toReturn; }
private static String replaceMacrosFromConfig(String macro) { String result = macro; Matcher matcher = VAR_PATTERN.matcher(result); while (matcher.find()) { String key = matcher.group(1); String value = ConfigurationManager.getConfigInstance().getString(key); if (value != null) { result = result.replaceAll("\\$\\{" + key + "\\}", value); matcher = VAR_PATTERN.matcher(result); } } return result.trim(); }
public PropertiesInstanceConfig(String namespace, DataCenterInfo info) { super(info); this.namespace = namespace.endsWith(".") ? namespace : namespace + "."; appGrpNameFromEnv = ConfigurationManager.getConfigInstance() .getString(FALLBACK_APP_GROUP_KEY, Values.UNKNOWN_APPLICATION); this.configInstance = Archaius1Utils.initConfig(CommonConstants.CONFIG_FILE_NAME); }
private static void setIfNotDefined(String key, String value) { final AbstractConfiguration config = ConfigurationManager.getConfigInstance(); if (config.getString(key) == null) { LOG.info("Setting default NIWS Property " + key + "=" + value); config.setProperty(key, value); } }
private static Map<String, Object> createPropertiesMap() { Properties properties = new Properties(); Iterator<String> iter = getConfigInstance().getKeys(JERSEY_ROOT_PACKAGE); while (iter.hasNext()) { String key = iter.next(); properties.setProperty(key, getConfigInstance().getString(key)); } return new TypeSafePropertiesDelegate(properties); }
@Override protected void configure() { final String appId = ConfigurationManager.getConfigInstance().getString(APP_ID); bind(String.class).annotatedWith(Names.named("explorerAppName")).toInstance(appId); bind(GlobalModelContext.class).to(AppConfigGlobalModelContext.class); bind(ExplorerManager.class).to(ExplorersManagerImpl.class); } }
@Override public List<Filter> additionalFilters() { return getInstancesFromClassList( ConfigurationManager.getConfigInstance().getString(NETFLIX_ADMIN_CTX_FILTERS, DEFAULT_CONTEXT_FILTERS), Filter.class); }
private static Map<String, Object> createPropertiesMap() { Properties properties = new Properties(); Iterator<String> iter = getConfigInstance().getKeys(JERSEY_ROOT_PACKAGE); while (iter.hasNext()) { String key = iter.next(); properties.setProperty(key, getConfigInstance().getString(key)); } return new TypeSafePropertiesDelegate(properties); }
protected void putDefaultStringProperty(IClientConfigKey propName, String defaultValue) { String value = ConfigurationManager.getConfigInstance().getString( getDefaultPropName(propName), defaultValue); setPropertyInternal(propName, value); }
@GetMapping(value = "/v1/agent/self", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public Agent getNodes() { String dataCenter = ConfigurationManager.getConfigInstance().getString("archaius.deployment.datacenter"); Config config = Config.builder().dataCenter(Optional.ofNullable(dataCenter).orElse("default")).build(); return Agent.builder().config(config).build(); } }
@Override public CompletableFuture<ResponseInfo<String>> execute(RequestInfo<Void> request, Executor longRunningTaskExecutor, ChannelHandlerContext ctx) { String value = ConfigurationManager.getConfigInstance().getString("archaiusServer.foo"); return CompletableFuture.completedFuture( ResponseInfo.newBuilder(value).build() ); } }