List of usage examples for org.apache.commons.configuration SystemConfiguration SystemConfiguration
public SystemConfiguration()
From source file:ch.cyclops.gatekeeper.Main.java
public static void main(String[] args) throws Exception { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); if (args.length > 0) config.addConfiguration(new PropertiesConfiguration(args[args.length - 1])); //setting up the logging framework now Logger.getRootLogger().getLoggerRepository().resetConfiguration(); ConsoleAppender console = new ConsoleAppender(); //create appender //configure the appender String PATTERN = "%d [%p|%C{1}|%M|%L] %m%n"; console.setLayout(new PatternLayout(PATTERN)); String logConsoleLevel = config.getProperty("log.level.console").toString(); switch (logConsoleLevel) { case ("INFO"): console.setThreshold(Level.INFO); break;/*from www .j av a2 s .c o m*/ case ("DEBUG"): console.setThreshold(Level.DEBUG); break; case ("WARN"): console.setThreshold(Level.WARN); break; case ("ERROR"): console.setThreshold(Level.ERROR); break; case ("FATAL"): console.setThreshold(Level.FATAL); break; case ("OFF"): console.setThreshold(Level.OFF); break; default: console.setThreshold(Level.ALL); } console.activateOptions(); //add appender to any Logger (here is root) Logger.getRootLogger().addAppender(console); String logFileLevel = config.getProperty("log.level.file").toString(); String logFile = config.getProperty("log.file").toString(); if (logFile != null && logFile.length() > 0) { FileAppender fa = new FileAppender(); fa.setName("FileLogger"); fa.setFile(logFile); fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n")); switch (logFileLevel) { case ("INFO"): fa.setThreshold(Level.INFO); break; case ("DEBUG"): fa.setThreshold(Level.DEBUG); break; case ("WARN"): fa.setThreshold(Level.WARN); break; case ("ERROR"): fa.setThreshold(Level.ERROR); break; case ("FATAL"): fa.setThreshold(Level.FATAL); break; case ("OFF"): fa.setThreshold(Level.OFF); break; default: fa.setThreshold(Level.ALL); } fa.setAppend(true); fa.activateOptions(); //add appender to any Logger (here is root) Logger.getRootLogger().addAppender(fa); } //now logger configuration is done, we can start using it. Logger mainLogger = Logger.getLogger("gatekeeper-driver.Main"); mainLogger.debug("Driver loaded properly"); if (args.length > 0) { GKDriver gkDriver = new GKDriver(args[args.length - 1], 1, "Eq7K8h9gpg"); System.out.println("testing if admin: " + gkDriver.isAdmin(1, 0)); ArrayList<String> uList = gkDriver.getUserList(0); //the argument is the starting count of number of allowed //internal attempts. if (uList != null) { mainLogger.info("Received user list from Gatekeeper! Count: " + uList.size()); for (int i = 0; i < uList.size(); i++) mainLogger.info(uList.get(i)); } boolean authResponse = gkDriver.simpleAuthentication(1, "Eq7K8h9gpg"); if (authResponse) mainLogger.info("Authentication attempt was successful."); else mainLogger.warn("Authentication attempt failed!"); String sName = "myservice-" + System.currentTimeMillis(); HashMap<String, String> newService = gkDriver.registerService(sName, "this is my new cool service", 0); String sKey = ""; if (newService != null) { mainLogger.info("Service registration was successful! Got:" + newService.get("uri") + ", Key=" + newService.get("key")); sKey = newService.get("key"); } else { mainLogger.warn("Service registration failed!"); } int newUserId = gkDriver.registerUser("user-" + System.currentTimeMillis(), "pass1234", false, sName, 0); if (newUserId != -1) mainLogger.info("User registration was successful. Received new id: " + newUserId); else mainLogger.warn("User registration failed!"); String token = gkDriver.generateToken(newUserId, "pass1234"); boolean isValidToken = gkDriver.validateToken(token, newUserId); if (isValidToken) mainLogger.info("The token: " + token + " is successfully validated for user-id: " + newUserId); else mainLogger.warn("Token validation was unsuccessful! Token: " + token + ", user-id: " + newUserId); ArrayList<String> sList = gkDriver.getServiceList(0); //the argument is the starting count of number of allowed //internal attempts. if (sList != null) { mainLogger.info("Received service list from Gatekeeper! Count: " + sList.size()); for (int i = 0; i < sList.size(); i++) mainLogger.info(sList.get(i)); } isValidToken = gkDriver.validateToken(token, sKey); if (isValidToken) mainLogger.info("The token: " + token + " is successfully validated for user-id: " + newUserId + " against s-key:" + sKey); else mainLogger.warn("Token validation was unsuccessful! Token: " + token + ", user-id: " + newUserId + ", s-key: " + sKey); boolean deleteResult = gkDriver.deleteUser(newUserId, 0); if (deleteResult) mainLogger.info("User with id: " + newUserId + " was deleted successfully."); else mainLogger.warn("User with id: " + newUserId + " could not be deleted successfully!"); } }
From source file:gobblin.metastore.util.DatabaseJobHistoryStoreSchemaManager.java
public static void main(String[] args) throws IOException { if (args.length < 1 || args.length > 2) { printUsage();//from ww w . j av a2 s . c o m } Closer closer = Closer.create(); try { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); if (args.length == 2) { config.addConfiguration(new PropertiesConfiguration(args[1])); } Properties properties = getProperties(config); DatabaseJobHistoryStoreSchemaManager schemaManager = closer .register(DatabaseJobHistoryStoreSchemaManager.builder(properties).build()); if (String.CASE_INSENSITIVE_ORDER.compare("migrate", args[0]) == 0) { schemaManager.migrate(); } else if (String.CASE_INSENSITIVE_ORDER.compare("info", args[0]) == 0) { schemaManager.info(); } else { printUsage(); } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } }
From source file:com.hpe.caf.worker.testing.SystemSettingsProvider.java
private static CompositeConfiguration createConfiguration() { CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); configuration.addConfiguration(new EnvironmentConfiguration()); return configuration; }
From source file:edu.harvard.i2b2.fhir.core.CoreConfig.java
private static void init() throws ConfigurationException { config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); config.addConfiguration(new PropertiesConfiguration("application.properties")); resourceCategoriesList = config.getString("resourceCategoriesList"); labsPath = config.getString("labsPath"); medicationsPath = config.getString("medicationsPath"); diagnosesPath = config.getString("diagnosesPath"); reportsPath = config.getString("reportsPath"); logger.info("initialized:" + toStaticString()); }
From source file:com.algoTrader.util.ConfigurationUtil.java
public static Configuration getBaseConfig() { if (baseConfig == null) { baseConfig = new CompositeConfiguration(); baseConfig.addConfiguration(new SystemConfiguration()); try {//from ww w .j a v a2 s. c o m baseConfig.addConfiguration(new PropertiesConfiguration(baseFileName)); } catch (ConfigurationException e) { logger.error("error loading base.properties", e); } } return baseConfig; }
From source file:com.dattack.jtoolbox.commons.configuration.ConfigurationUtil.java
/** * Create a <code>Configuration</code> based on the environment variables and system properties. * * @return a <code>Configuration</code> based on the environment variables and system properties *//*from w ww .ja v a2 s .c o m*/ public static CompositeConfiguration createEnvSystemConfiguration() { final CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); configuration.addConfiguration(new EnvironmentConfiguration()); return configuration; }
From source file:com.bluescopesteel.foldermonitor.config.ConfigManager.java
public synchronized static Configuration getConfig() { if (config == null) { try {//from w ww . j a v a2 s .co m log.info("Creating new configuration object"); config = new CompositeConfiguration(); config.addConfiguration(new PropertiesConfiguration("default.properties")); try { config.addConfiguration(new PropertiesConfiguration("config.properties")); } catch (ConfigurationException ex) { log.info("No installed configuration file found"); } config.addConfiguration(new SystemConfiguration()); } catch (ConfigurationException ex) { log.error("Error creating configuration", ex); } } return config; }
From source file:com.algoTrader.util.ConfigurationUtil.java
public static Configuration getStrategyConfig(String strategyName) { if (StrategyImpl.BASE.equals(strategyName.toUpperCase())) { return getBaseConfig(); }//from w w w. ja va 2 s . com CompositeConfiguration strategyConfig = strategyConfigMap.get(strategyName.toUpperCase()); if (strategyConfig == null) { strategyConfig = new CompositeConfiguration(); strategyConfig.addConfiguration(new SystemConfiguration()); try { strategyConfig.addConfiguration( new PropertiesConfiguration("conf-" + strategyName.toLowerCase() + ".properties")); strategyConfig.addConfiguration(new PropertiesConfiguration(baseFileName)); } catch (ConfigurationException e) { logger.error("error loading " + strategyName.toLowerCase() + ".properties", e); } strategyConfigMap.put(strategyName.toUpperCase(), strategyConfig); } return strategyConfig; }
From source file:de.kopis.glacier.parsers.GlacierUploaderOptionParserTest.java
@Before public void setUp() { optionsParser = new GlacierUploaderOptionParser(new SystemConfiguration()); args = new String[] { "--vault", "vaultname", "--endpoint", "file:///endpointurl" }; }
From source file:com.nesscomputing.config.SystemOverrideTest.java
@Before public void setUp() { ps = new PropertiesSaver("string-value"); System.setProperty("string-value", "OVERRIDDEN"); cfg = Config.getConfig("classpath:/test-config/basic", "values"); Assert.assertThat(new SystemConfiguration().getString("string-value"), is("OVERRIDDEN")); cfg2 = Config.getConfig("classpath:/test-config//basic-legacy", "values"); Assert.assertThat(new SystemConfiguration().getString("string-value"), is("OVERRIDDEN")); }