List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace
public void printStackTrace()
From source file:cd.what.DutchBot.DutchBot.java
/** * Initializes bot./*www. j a v a 2 s . co m*/ * * @param name * Nickname used when connecting. */ public DutchBot(String configfile) { try { this._config.load(configfile); this._config.setAutoSave(true); this._config.setFileName(configfile); AccessList.loadFromConfig(configfile); AccessList.setBot(this); } catch (ConfigurationException e) { this.logMessage("There was an error with your config file! ", true); e.printStackTrace(); System.exit(1); } catch (FileNotFoundException e) { this.logMessage("The config file could not be found! ", true); System.exit(1); } // initialize the finals this.setServerAddress(this._config.getString("server.host")); this.setIrcPort(this._config.getInt("server.port", 6667)); this.setServerPassword(this._config.getString("server.password", "")); this.setNickservPassword(this._config.getString("irc.nickservpass", "")); this.setName(this._config.getString("irc.nick", "DutchBot")); this.setVersion("DutchBot " + VERSION + " by DutchDude"); this.setLogin(this._config.getString("irc.nick", "DutchBot")); _connectionProtector = new ConnectionProtectorTask(this); this.getTimer().schedule(_connectionProtector, 1000L, 1000L); this.setOwner(this._config.getString("bot.owner", "")); this.setLogchannel(this._config.getString("bot.logchannel", "")); this.moduleManager = new ModuleManager(this); }
From source file:it.grid.storm.namespace.config.xml.XMLNamespaceParser.java
/**************************************************************** * PRIVATE METHODs// w ww. jav a 2 s . com *****************************************************************/ private boolean refreshCachedData() { boolean result = false; try { refreshing.lock(); configuration.clear(); configuration.clearTree("filesystems"); configuration.clearTree("mapping-rules"); configuration.clearTree("approachable-rules"); try { configuration.load(); log.debug(" ... reading and parsing the namespace configuration from file!"); } catch (ConfigurationException ex) { ex.printStackTrace(); } log.debug("REFRESHING CACHE.."); // Save the cache content log.debug(" ..save the cache content before semantic check"); Hashtable<String, VirtualFSInterface> vfssSAVED = vfss; Hashtable<String, MappingRule> maprulesSAVED = maprules; Hashtable<String, ApproachableRule> apprulesSAVED = apprules; // Refresh the cache content with new values log.debug(" ..refresh the cache"); refreshCache(); // Do the checking on Namespace log.debug(" ..semantic check of namespace"); NamespaceCheck checker = new NamespaceCheck(vfss, maprules, apprules); boolean semanticCheck = checker.check(); // If there is an error restore old cache content log.debug("REFRESHING ENDED."); if (semanticCheck) { log.debug("Namespace is semantically valid"); result = true; } else { log.warn("Namespace does not semantically valid!, so no load performed!"); vfss = vfssSAVED; maprules = maprulesSAVED; apprules = apprulesSAVED; result = false; } } finally { refreshing.unlock(); } return result; }
From source file:com.ccl.jersey.codegen.SimpleMetaDataExporter.java
private void handleDict() { try {/* w ww . j a va 2 s . com*/ XMLConfiguration config = new XMLConfiguration("dict.xml"); HierarchicalConfiguration.Node root = config.getRoot(); if (root.hasChildren()) { List<ConfigurationNode> dicts = root.getChildren("dict"); for (int i = 0; i < dicts.size(); i++) { String name = config.getString("dict(" + i + ")[@name]"); String label = config.getString("dict(" + i + ")[@label]"); String table = config.getString("dict(" + i + ")[@table]"); String column = config.getString("dict(" + i + ")[@column]"); Map<String, DictType> dictTypeMap = registerDictTypes.get(table); if (null == dictTypeMap) { dictTypeMap = new HashMap<>(); } registerDictTypes.put(table, dictTypeMap); DictType dictType = new DictType(name, label, table, column); dictTypeMap.put(column, dictType); if (dicts.get(i).getChildrenCount() > 0) { List<ConfigurationNode> configurationNodes = dicts.get(i).getChildren("item"); for (int j = 0; j < configurationNodes.size(); j++) { String itemName = config.getString("dict(" + i + ").item(" + j + ")[@name]"); Integer itemValue = config.getInt("dict(" + i + ").item(" + j + ")[@value]"); String itemLabel = config.getString("dict(" + i + ").item(" + j + ")[@label]"); dictType.getItems().add(new DictItemType(itemName, itemValue, itemLabel)); } } } } } catch (ConfigurationException e) { e.printStackTrace(); } }
From source file:m.c.m.proxyma.ProxymaServlet.java
/** * Initialize the servlet and the proxyma environment. */// w w w. j a v a 2 s .c o m @Override public void init() { try { //Obtain configuration parameters.. ServletConfig config = this.getServletConfig(); String proxymaConfigFile = this.getInitParameter("ProxymaConfigurationFile"); String proxymaContextName = this.getInitParameter("ProxymaContextName"); String proxymaLogsDirectory = this.getInitParameter("ProxymaLogsDir"); //if the config file init-parameter is notspecified use the default configuration if (proxymaConfigFile == null) proxymaConfigFile = config.getServletContext().getRealPath("/WEB-INF/proxyma-config.xml"); //Hack to get the servlet path reading it directly from the deployment descriptor. //Valid until apache will put a getServletMappings() method into the ServletConfig class. XMLConfiguration deploymentDescriptor = null; try { deploymentDescriptor = new XMLConfiguration(); deploymentDescriptor.setFile(new File(config.getServletContext().getRealPath("/WEB-INF/web.xml"))); deploymentDescriptor.setValidating(false); deploymentDescriptor.load(); } catch (ConfigurationException ex) { Logger.getLogger("").log(Level.SEVERE, "Unable to load web.xml", ex); } deploymentDescriptor.setExpressionEngine(new XPathExpressionEngine()); String servletPath = deploymentDescriptor .getString("servlet-mapping[servlet-name='" + config.getServletName() + "']/url-pattern"); String proxymaServletContext = config.getServletContext().getContextPath() + servletPath.replaceFirst("/\\*$", GlobalConstants.EMPTY_STRING); //Check if the logs directory init-parameter ends with "/" if (!proxymaLogsDirectory.endsWith("/")) { proxymaLogsDirectory = proxymaLogsDirectory + "/"; } //Create a new proxyma facade this.proxyma = new ProxymaFacade(); //Create a new proxyma context this.proxymaContext = proxyma.createNewContext(proxymaContextName, proxymaServletContext, proxymaConfigFile, proxymaLogsDirectory); //Create a reverse proxy engine for this servlet thread this.proxymaEngine = proxyma.createNewProxyEngine(proxymaContext); } catch (IllegalAccessException ex) { ex.printStackTrace(); } }
From source file:com.wet.wired.jsr.recorder.ScreenRecorder.java
public synchronized void run() { BasicConfigurator.configure();/*w w w. j av a 2s . c om*/ if (sessionId == null) { sessionId = UUID.randomUUID().toString(); } try { Idioma idioma = new Idioma(); logger.trace("Set Idioma:start()"); config = idioma.setIdioma("espanol"); logger.trace("Set Idioma:end()"); } catch (ConfigurationException e) { logger.error(e.getMessage()); } LoggerUtils loggerUtils = new LoggerUtils(); loggerUtils.load(config.getString("pathGlobal"), sessionId, config.getString("synchronizer.ruta.log"), config.getString("pathLog4j"), "synchronizer.log", "synchronizer.html"); logger.info("****************** Inicio de Screen Recorder ***************** "); logger.info("*********** " + sessionId + " *********** "); logger.info("************************************************************ "); startTime = System.currentTimeMillis(); logger.trace(startTime); recording = true; running = true; long lastFrameTime = 0; long time = 0; logger.trace("recordArea.width" + recordArea.width); logger.trace("recordArea.height" + startTime); frameSize = recordArea.width * recordArea.height; streamPacker = new StreamPacker(oStream, frameSize); while (recording) { time = System.currentTimeMillis(); while (time - lastFrameTime < 190) { try { Thread.sleep(10); } catch (Exception e) { } time = System.currentTimeMillis(); } lastFrameTime = time; try { recordFrame(); } catch (Exception e) { e.printStackTrace(); try { oStream.close(); } catch (Exception e2) { } break; } } running = false; recording = false; listener.recordingStopped(); }
From source file:jdbc.pool.JDBCPoolTestCase.java
public void testDestroy() { System.out.println("testDestroy Start."); try {//from w ww. ja va2 s . c o m CConnectionPoolManager manager = null; manager = create(); manager.destroy(true); testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("testDestroy end."); }
From source file:jdbc.pool.JDBCPoolTestCase.java
public void testGetInstanceStringFile() { System.out.println("testGetInstanceStringFile Start"); try {//from w w w.j a v a 2 s. co m CConnectionPoolManager manager = null; manager = create(); assertNotNull("check manager for not null", manager); assertNotNull("check CConnectionPoolManager.getInstance() for not null", CConnectionPoolManager.getInstance()); assertTrue("check manager == CConnectionPoolManager.getInstance()", manager.hashCode() == CConnectionPoolManager.getInstance().hashCode()); manager.destroy(true); testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("testGetInstanceStringFile End"); }
From source file:jdbc.pool.JDBCPoolTestCase.java
public void testGetInstanceStringFile2() { System.out.println("testGetInstanceStringFile2 Start"); try {/*www . jav a2 s. c om*/ CConnectionPoolManager manager = CConnectionPoolManager.getInstance(null, new File( "C:/Documents and Settings/STG/workspace/jdbcpool/junit-source/config/pool.properties")); assertNotNull("Instance not null", manager); assertNotNull("Ascertain CConnectionPoolManager.getInstance()also returns not null", CConnectionPoolManager.getInstance()); assertTrue("ascertain CConnectionPoolManager.getInstance() == manager", manager.hashCode() == CConnectionPoolManager.getInstance().hashCode()); manager.destroy(true); testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("testGetInstanceStringFile2 end"); }
From source file:jdbc.pool.JDBCPoolTestCase.java
/** * Test case for FIFO Algorithm with Maximum JDBC Usage parameter. *///from w w w . j av a 2s .c o m public void testFIFOAlgorithm() { System.out.println("testFIFOAlgorithm with Maximum Usage Counter Start."); try { CConnectionPoolManager manager = create(); Connection realCon = null; Connection con = manager.getConnection("FIFO"); //It has 3 iniital connections. if (con instanceof ConnectionWrapper) { ConnectionWrapper wrapper = (ConnectionWrapper) con; realCon = wrapper.realConnection(); } else { fail("Connection returned is not an instance of ConnectionWrapper"); } con.close(); for (int i = 2; i <= (3 * 4) - 3; i++) { // 3 (no. of con) * 4 (max jdbc usage) - 2 (to bring the original on top.) con = manager.getConnection("FIFO"); con.close(); assertFalse("Connection must be active #" + i, realCon.isClosed()); } con = manager.getConnection("FIFO"); con.close(); assertTrue("Connection must be active", realCon.isClosed()); manager.destroy(true); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("testFIFOAlgorithm with Maximum Usage Counter End."); }
From source file:jdbc.pool.JDBCPoolTestCase.java
/** * Validates whether the connection received from the pool is as per the * JDBC driver specified in the configuration file. * /*from ww w .j a v a2 s . co m*/ */ public void testValidateConnectionForJDBCDriver() { System.out.println("validateConnectionForJDBCDriver Start"); try { CConnectionPoolManager manager = create(); Connection con = manager.getConnection("ORACLE"); if (con instanceof ConnectionWrapper) { ConnectionWrapper wrapper = (ConnectionWrapper) con; assertTrue("real connection from Oracle pool is of Oracle", wrapper.realConnection() instanceof oracle.jdbc.OracleConnection); } else { fail("Connection returned is not an instance of ConnectionWrapper"); } con.close(); con = manager.getConnection("MYSQL"); if (con instanceof ConnectionWrapper) { ConnectionWrapper wrapper = (ConnectionWrapper) con; assertTrue("real connection from MYSQL pool is of MySQL", wrapper.realConnection() instanceof com.mysql.jdbc.Connection); } else { fail("Connection returned is not an instance of ConnectionWrapper"); } con.close(); manager.destroy(true); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("validateConnectionForJDBCDriver end"); }