/** * Allow the appId and Environment to be overridden when loading TypesafeConfig files. * This will support resolution of different TypesafeConfig files without globally modifying the * appId or environment. This would allow region specific property files * while still maintaining the same appId or environment variables. * * @return {@code Pair<String,String>} with the {@code Left} the appId of the TypesafeConfig to load * and the {@code Right} the Environment. */ protected Pair<String,String> getAppIdAndEnvironmentPair(){ return MainClassUtils.getAppIdAndEnvironmentFromSystemProperties(); }
/** * Initializes the Archaius system and configures the Netty leak detection level (if necessary). * DO NOT CALL THIS DIRECTLY. Use {@link #launchServer(String[])} when you're ready to start the server. */ protected void infrastructureInit() { MainClassUtils.setupJbossLoggingToUseSlf4j(); try { Pair<String, String> appIdAndEnvironmentPair = MainClassUtils.getAppIdAndEnvironmentFromSystemProperties(); ConfigurationManager.loadCascadedPropertiesFromResources(appIdAndEnvironmentPair.getLeft()); } catch (IOException e) { throw new RuntimeException("Error loading Archaius properties", e); } AbstractConfiguration appConfig = ConfigurationManager.getConfigInstance(); Function<String, Boolean> hasPropertyFunction = (propKey) -> appConfig.getProperty(propKey) != null; Function<String, String> propertyExtractionFunction = (propKey) -> { // Properties in Archaius might be a Collection or an Object. Object propValObj = appConfig.getProperty(propKey); return (propValObj instanceof Collection) ? ((Collection<?>) propValObj).stream().map(String::valueOf).collect(Collectors.joining(",")) : String.valueOf(propValObj); }; Set<String> propKeys = new LinkedHashSet<>(); appConfig.getKeys().forEachRemaining(propKeys::add); MainClassUtils.logApplicationPropertiesIfDebugActionsEnabled( hasPropertyFunction, propertyExtractionFunction, propKeys, false ); MainClassUtils.setupNettyLeakDetectionLevel(hasPropertyFunction, propertyExtractionFunction); }
Pair<String, String> results = null; try { results = MainClassUtils.getAppIdAndEnvironmentFromSystemProperties();