List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace
public void printStackTrace()
From source file:org.jhub1.agent.run.cli.Params.java
boolean process(String[] args) { try {//from w w w.j av a 2 s . co m config = new PropertiesImpl(); } catch (ConfigurationException e1) { e1.printStackTrace(); System.exit(0); } GnuParser parser = new GnuParser(); CommandLine cmd = null; try { cmd = parser.parse(getOptions(), args); } catch (Exception e) { System.out.println("\n************************"); System.out.println("The parameter(s) not recognized or other parsing problem!"); System.out.println("************************"); return false; } return processCommandLine(cmd); }
From source file:org.jlange.proxy.util.Config.java
private static Configuration getConfig() { if (config == null) { try {/*from w w w . ja v a 2 s .c o m*/ config = new PropertiesConfiguration("jLange.properties"); } catch (ConfigurationException e) { e.printStackTrace(); System.exit(1); } } return config; }
From source file:org.kitodo.production.plugin.opac.pica.ConfigOpac.java
private static XMLConfiguration getConfig() { if (config != null) { return config; }/*from w w w .j a v a 2 s . c o m*/ String configPfad = FilenameUtils.concat(PicaPlugin.getConfigDir(), PicaPlugin.OPAC_CONFIGURATION_FILE); if (!new File(configPfad).exists()) { String message = "File not found: ".concat(configPfad); throw new RuntimeException(message, new FileNotFoundException(message)); } try { config = new XMLConfiguration(configPfad); } catch (ConfigurationException e) { e.printStackTrace(); config = new XMLConfiguration(); } config.setListDelimiter('&'); config.setReloadingStrategy(new FileChangedReloadingStrategy()); return config; }
From source file:org.mot.common.db.DatabaseConnectionFactory.java
private DatabaseConnectionFactory() { logger.debug("Creating new Database Connection Factory ..."); PropertiesFactory pf = PropertiesFactory.getInstance(); String pathToConfigDir = pf.getConfigDir(); try {/* www .ja v a2 s . c om*/ config = new PropertiesConfiguration(pathToConfigDir + "/database.properties"); // Set the user name and password. String userName = config.getString("database.username"); String password = config.getString("database.password"); int minidle = config.getInt("database.connection.min", 3); int maxIdle = config.getInt("database.connection.maxIdle", 40); int max = config.getInt("database.connection.max", 50); int evictor = config.getInt("database.connection.evictor.millis", 500); int timeout = config.getInt("database.connection.timeout", 120); Boolean autoCommit = config.getBoolean("database.connection.autoCommit", true); String url = config.getString("database.url"); databaseProperties = config.getBoolean("database.configuration.enabled", false); ds = new BasicDataSource(); ds.setDriverClassName(config.getString("database.driver")); ds.setUsername(userName); ds.setPassword(password); ds.setUrl(url); ds.setDefaultQueryTimeout(timeout); //ds.setEnableAutoCommitOnReturn(true); ds.setMinIdle(minidle); ds.setMaxIdle(maxIdle); ds.setTimeBetweenEvictionRunsMillis(evictor); ds.setMaxTotal(max); //ds.setTimeBetweenEvictionRunsMillis(500); ds.setDefaultAutoCommit(autoCommit); //ds.setMaxWaitMillis(2000); // conn = ds.getConnection(); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.mot.common.mq.ActiveMQFactory.java
private void connect() { // Get the cache configuration int count = 0; int max = 5;//from ww w . j a v a 2s . co m long sleep = 2000; while (true) { try { config = new PropertiesConfiguration(pathToConfigDir + "/activemq.properties"); String wireformat = config.getString("activemq.wireFormat"); ActiveMQConnectionFactory connectionFactory = null; String url = config.getString("activemq.connection.URL"); String user = config.getString("activemq.user"); String password = config.getString("activemq.password"); if (wireformat != null) { // Create new connectionFactory with wireFormat specification //connectionFactory = new PooledConnectionFactory(config.getString("activemq.connectionFactory") + "?" + wireformat); connectionFactory = new ActiveMQConnectionFactory(url + "?" + wireformat); } else { // Create new connectionFactory connectionFactory = new ActiveMQConnectionFactory(url); } // Set the connection Factory properties /* connectionFactory.setMaxConnections(10000); connectionFactory.setIdleTimeout(120); connectionFactory.initConnectionsPool(); connectionFactory.start(); */ // Create a Connection // Need to investigate a bit further, if the session should be async. if false, performance is better - but not sure // this can be used for each queue/topic. May need to move this into a session instead of globally in the connection! connectionFactory.setAlwaysSessionAsync(false); connectionFactory.setDispatchAsync(false); connectionFactory.setMaxThreadPoolSize(300); if (user == null || password == null) { // Dont provide credentials to connectionFactory if user or pwd are empty connection = connectionFactory.createConnection(); } else { connection = connectionFactory.createConnection(user, password); } connection.start(); // Create a default session object this.session = this.createSession(); logger.debug("Started Active MQ connection"); } catch (ConfigurationException e) { // If the configuration is wrong, exit immediately System.out.println( "*** Cannot connect to Message Broker - Invalid configuration - Exiting MyOpenTrader ..."); e.printStackTrace(); System.exit(0); } catch (JMSException e) { // Only exit if we have tried for 3 times, with a pause of 2 seconds in between! if (++count == max) { System.out.println("*** Failed to connect to Message Broker - Exiting MyOpenTrader ..."); e.printStackTrace(); System.exit(0); } else { try { // Make sure the connection is closed, before retrying to create a new one. connection.close(); System.out.println( "*** Cannot connect to Message Broker - Retry " + count + " of " + max + "..."); e.printStackTrace(); Thread.sleep(sleep); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (JMSException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } // If everything went well, break the while loop. break; } }
From source file:org.mot.common.order.OrderEngine.java
/** * Default constructor /*from w w w. j a v a 2 s . co m*/ */ private OrderEngine() { PropertiesFactory pf = PropertiesFactory.getInstance(); String pathToConfigDir = pf.getConfigDir(); try { config = new PropertiesConfiguration(pathToConfigDir + "/config.properties"); txnPct = config.getDouble("order.transactionCostPerOrder.pct", 0.0024); min = config.getInt("order.barrier.sellIncrement.min", 10); max = config.getInt("order.barrier.sellIncrement.max", 25); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.mot.common.tools.EmailFactory.java
public EmailFactory() { Configuration emailProps;/*www. j a v a 2 s .c o m*/ try { emailProps = new PropertiesConfiguration(pf.getConfigDir() + "/email.properties"); enabled = emailProps.getBoolean("email.enabled", true); from = emailProps.getString("email.sender", "info@myopentrader.org"); rcpt = emailProps.getString("email.recipient", "stephan@myopentrader.org"); host = emailProps.getString("email.smtp.host", "localhost"); // Get system properties Properties properties = System.getProperties(); // Setup mail server properties.setProperty("mail.smtp.host", host); session = Session.getDefaultInstance(properties); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.mot.common.tools.PropertiesFactory.java
private Configuration getFileConfiguration(String filename) { Configuration config = null;//from w ww .j a v a 2 s. co m // Read the properties from file try { config = new PropertiesConfiguration(this.getConfigDir() + "/" + filename); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return config; }
From source file:org.mot.common.util.DateBuilder.java
private void init() { String pathToConfigDir = pf.getConfigDir(); try {// www .j a v a 2 s .c om config = new PropertiesConfiguration(pathToConfigDir + "/date.properties"); } catch (ConfigurationException e) { // TODO Auto-generated catch block logger.error(e.getLocalizedMessage()); e.printStackTrace(); } }
From source file:org.mot.core.MyOpenTraderCore.java
/** * This is the main starting point for the CORE class. From here all other subclasses are initiated and triggered. * Make sure to be careful about changes in here! * /*from www . j a va 2 s .c o m*/ * @param PathToConfigDir - provide a configuration directory to use * @param name - the executor name */ protected void startWorkers(String PathToConfigDir, String name) { // First make sure to set the config directory pf.setConfigDir(PathToConfigDir); try { // Read in the properties Configuration genericProperties = new PropertiesConfiguration(PathToConfigDir + "/config.properties"); // Make sure to set the global property and initiate logging PropertyConfigurator.configure(pf.getConfigDir() + "/log4j.properties"); logger.debug("Setting PathToCoreConfigDir property to: " + PathToConfigDir); // If the executor is left empty, use wildcard ALL instead. if (name == null) { // Get the engine name name = genericProperties.getString("engine.core.name", "ALL"); } // Start the tick message listener if (genericProperties.getBoolean("engine.startup.core.tickListener.enabled", true)) { startIndiviualTickMessageListener(name, genericProperties); } ; // Start the tick size listener if (genericProperties.getBoolean("engine.startup.core.tickSizeListener.enabled", true)) { startTickSizeListener(); } ; // Start the tick history listener if (genericProperties.getBoolean("engine.startup.core.historyListener.enabled", true)) { startTickMessageHistoryListener(); } ; // Start the internal scheduling engine startScheduler(name); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }