List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration()
From source file:com.nilostep.xlsql.database.xlInstance.java
private xlInstance(String cfg) throws xlException { logger = Logger.getLogger(this.getClass().getName()); instance = this; try {//from ww w. j a v a 2 s.c om PropertiesConfiguration config = new PropertiesConfiguration(); config.load(this.getClass().getResourceAsStream(cfg + ".properties")); this.config = config; engine = config.getString("general.engine"); logger.info("Configuration engine: " + engine + " loaded"); } catch (ConfigurationException e) { e.printStackTrace(); throw new xlException(e.getMessage()); } try { boolean append = true; FileHandler loghandler = new FileHandler(getLog(), append); loghandler.setFormatter(new SimpleFormatter()); logger.addHandler(loghandler); } catch (IOException e) { throw new xlException("error while creating logfile"); } logger.info("Instance created with engine " + getEngine()); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.SpeedOverGroundAnalysisTest.java
@Before public void prepareTest() { context = new JUnit4Mockery(); // Mock dependencies trackingService = context.mock(EventEmittingTracker.class); statisticsService = context.mock(AppStatisticsService.class); statisticsRepository = context.mock(StatisticDataRepository.class); eventRepository = context.mock(EventRepository.class); behaviourManager = context.mock(BehaviourManager.class); configuration = new PropertiesConfiguration(); configuration.setProperty(CONFKEY_ANALYSIS_SOG_CELL_SHIPCOUNT_MIN, 1000); configuration.setProperty(CONFKEY_ANALYSIS_SOG_PD, 0.001); }
From source file:com.netflix.bdp.inviso.history.TraceService.java
@Override public void contextInitialized(ServletContextEvent context) { log.info("Initializing Trace Service"); config = new Configuration(); properties = new PropertiesConfiguration(); try {//from w ww.jav a 2 s . c o m properties.load(TraceService.class.getClassLoader().getResourceAsStream("trace.properties")); Class<?> c = config.getClass("trace.history.locator.impl", com.netflix.bdp.inviso.history.impl.BucketedHistoryLocator.class); historyLocator = (HistoryLocator) c.newInstance(); historyLocator.initialize(config); } catch (Exception e) { log.error("Failed to initialize trace service.", e); } }
From source file:dk.dma.ais.abnormal.analyzer.analysis.CourseOverGroundAnalysisTest.java
@Before public void prepareTest() { context = new JUnit4Mockery(); // Mock dependencies trackingService = context.mock(EventEmittingTracker.class); statisticsService = context.mock(AppStatisticsService.class); statisticsRepository = context.mock(StatisticDataRepository.class); eventRepository = context.mock(EventRepository.class); behaviourManager = context.mock(BehaviourManager.class); configuration = new PropertiesConfiguration(); configuration.setProperty(CONFKEY_ANALYSIS_COG_CELL_SHIPCOUNT_MIN, 1000); configuration.setProperty(CONFKEY_ANALYSIS_COG_PD, 0.001); }
From source file:com.pinterest.pinlater.backends.redis.PinLaterRedisBackendTest.java
@BeforeClass public static void beforeClass() throws Exception { QUEUE_NAME = "pinlater_redis_backend_test"; // If there is no local Redis, skip this test. Assume.assumeTrue(LocalRedisChecker.isRunning(REDIS_PORT)); configuration = new PropertiesConfiguration(); try {/*from www. j av a 2 s.c om*/ configuration.load(ClassLoader.getSystemResourceAsStream("pinlater.redis.test.properties")); } catch (ConfigurationException e) { throw new RuntimeException(e); } InputStream redisConfigStream = ClassLoader.getSystemResourceAsStream("redis.local.json"); backend = new PinLaterRedisBackend(configuration, redisConfigStream, "localhost", System.currentTimeMillis()); }
From source file:com.aurel.track.util.PropertiesConfigurationHelper.java
/** * Gets the PropertiesConfiguration for a property file from servlet context * @param servletContext/*from ww w. jav a 2 s .c o m*/ * @param pathWithinContext * @param propFile * @return * @throws ServletException */ public static PropertiesConfiguration loadServletContextPropFile(ServletContext servletContext, String pathWithinContext, String propFile) throws ServletException { PropertiesConfiguration propertiesConfiguration = null; InputStream in = null; URL propFileURL = null; try { if (servletContext != null && pathWithinContext != null) { if (!pathWithinContext.startsWith("/")) { pathWithinContext = "/" + pathWithinContext; } if (!pathWithinContext.endsWith("/")) { pathWithinContext = pathWithinContext + "/"; } propFileURL = servletContext.getResource(pathWithinContext + propFile); in = propFileURL.openStream(); propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.load(in); in.close(); } } catch (Exception e) { LOGGER.error("Could not read " + propFile + " from servlet context " + propFileURL == null ? "" : propFileURL.toExternalForm() + ". Exiting. " + e.getMessage()); throw new ServletException(e); } return propertiesConfiguration; }
From source file:com.github.anba.es6draft.util.Resources.java
/** * Loads the configuration file.//from ww w. jav a2 s . co m */ public static Configuration loadConfiguration(Class<?> clazz) { TestConfiguration config = clazz.getAnnotation(TestConfiguration.class); String file = config.file(); String name = config.name(); try { PropertiesConfiguration properties = new PropertiesConfiguration(); // entries are mandatory unless an explicit default value was given properties.setThrowExceptionOnMissing(true); properties.getInterpolator().setParentInterpolator(MISSING_VAR); properties.load(resource(file), "UTF-8"); Configuration configuration = new CompositeConfiguration( Arrays.asList(new SystemConfiguration(), properties)); return configuration.subset(name); } catch (ConfigurationException | IOException e) { throw new RuntimeException(e); } catch (NoSuchElementException e) { throw e; } }
From source file:ke.co.tawi.babblesms.server.servlet.util.PropertiesConfig.java
/** * Populate the internal HashMap which will hold configuration keys and values *///w w w . j a v a 2s .c om private void initConfigHash() { PropertiesConfiguration config; String key; try { config = new PropertiesConfiguration(); config.setListDelimiter('|'); // our array delimiter config.setFileName(configFile); config.load(); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { key = keys.next(); configHash.put(key, (String) config.getProperty(key)); } } catch (ConfigurationException e) { logger.error("ConfigurationException when trying to initialize configuration HashMap"); logger.error(ExceptionUtils.getStackTrace(e)); } }
From source file:com.linkedin.pinot.integration.tests.FileBasedServerBrokerStarters.java
private PropertiesConfiguration brokerProperties() { final PropertiesConfiguration brokerConfiguration = new PropertiesConfiguration(); //transport properties //config based routing brokerConfiguration.addProperty("pinot.broker.transport.routingMode", "CONFIG"); //two tables/*w ww . j ava 2 s. c o m*/ brokerConfiguration.addProperty("pinot.broker.transport.routing.tableName", StringUtils.join(TABLE_NAMES, ",")); // table conf for (final String table : TABLE_NAMES) { brokerConfiguration.addProperty(getKey("pinot.broker.transport.routing", table, "numNodesPerReplica"), "1"); brokerConfiguration.addProperty(getKey("pinot.broker.transport.routing", table, "serversForNode.0"), "localhost:" + SERVER_PORT); brokerConfiguration.addProperty( getKey("pinot.broker.transport.routing", table, "serversForNode.default"), "localhost:" + SERVER_PORT); } // client properties brokerConfiguration.addProperty("pinot.broker.client.enableConsole", "true"); brokerConfiguration.addProperty("pinot.broker.client.queryPort", BROKER_CLIENT_PORT); brokerConfiguration.addProperty("pinot.broker.client.consolePath", "dont/need/this"); brokerConfiguration.setDelimiterParsingDisabled(false); return brokerConfiguration; }
From source file:main.java.workload.Workload.java
protected Workload(String file) { setFile_name(file);/*from w w w . jav a 2 s . c o m*/ BufferedReader config_file = null; AbstractFileConfiguration parameters = null; try { config_file = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(getFile_name()))); Global.LOGGER .info("Configuration file " + getFile_name() + " is found under src/main/resources and read."); //Load configuration parameters parameters = new PropertiesConfiguration(); parameters.load(config_file); //Read the number of tables and types of transactions tbl = parameters.getInt("tables"); tr_types = parameters.getInt("transaction.types"); Global.LOGGER.info("Number of database tables: " + tbl); Global.LOGGER.info("Types of workload transactions: " + tr_types); } catch (ConfigurationException e) { e.printStackTrace(); } finally { if (config_file != null) { try { config_file.close(); } catch (IOException e) { e.printStackTrace(); } } } //Initialize other variables this.warmingup = false; this.tbl_types = new HashMap<Integer, Integer>(); this.schema = new HashMap<Integer, ArrayList<Integer>>(); this.tr_proportions = new HashMap<Integer, Double>(); this.tr_tuple_distributions = new HashMap<Integer, ArrayList<Integer>>(); this.tr_changes = new HashMap<Integer, ArrayList<Integer>>(); this._cache = new HashMap<Integer, ArrayList<Integer>>(); this._cache_keys = new ArrayList<Integer>(); this._cache_id = 0; }