List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:com.qspin.qtaste.ui.MainPanel.java
public void genUI() { try {/*from w ww.j a va 2s .c o m*/ getContentPane().setLayout(new BorderLayout()); // prepare the top panel that contains the following panes: // - logo // - ConfigInfopanel // - Current Date/time JPanel topanel = new JPanel(new BorderLayout()); JPanel center = new JPanel(new GridBagLayout()); ImageIcon topLeftLogo = ResourceManager.getInstance().getImageIcon("main/qspin"); JLabel iconlabel = new JLabel(topLeftLogo); mHeaderPanel = new ConfigInfoPanel(this); mTestCasePanel = new TestCasePane(this); mTestCampaignPanel = new TestCampaignMainPanel(this); mHeaderPanel.init(); GridBagLineAdder centeradder = new GridBagLineAdder(center); JLabel sep = new JLabel(" "); sep.setFont(ResourceManager.getInstance().getSmallFont()); sep.setUI(new FillLabelUI(ResourceManager.getInstance().getLightColor())); centeradder.setWeight(1.0f, 0.0f); centeradder.add(mHeaderPanel); // prepare the right panels containg the main information: // the right pane is selected through the tabbed pane: // - Test cases: management of test cases and test suites // - Test campaign: management of test campaigns // - Interactive: ability to invoke QTaste verbs one by one mRightPanels = new JPanel(new CardLayout()); mRightPanels.add(mTestCasePanel, "Test Cases"); mRightPanels.add(mTestCampaignPanel, "Test Campaign"); final TestCaseInteractivePanel testInterractivePanel = new TestCaseInteractivePanel(); mRightPanels.add(testInterractivePanel, "Interactive"); mTreeTabsPanel = new JTabbedPane(JTabbedPane.BOTTOM); mTreeTabsPanel.setPreferredSize(new Dimension(TREE_TABS_WIDTH, HEIGHT)); TestCaseTree tct = new TestCaseTree(mTestCasePanel); JScrollPane sp2 = new JScrollPane(tct); mTreeTabsPanel.addTab("Test Cases", sp2); // add tree view for test campaign definition com.qspin.qtaste.ui.testcampaign.TestCaseTree mtct = new com.qspin.qtaste.ui.testcampaign.TestCaseTree( mTestCampaignPanel.getTreeTable()); JScrollPane sp3 = new JScrollPane(mtct); mTreeTabsPanel.addTab("Test Campaign", sp3); genMenu(tct); // add another tab contain used for Interactive mode TestAPIDocsTree jInteractive = new TestAPIDocsTree(testInterractivePanel); JScrollPane spInter = new JScrollPane(jInteractive); mTreeTabsPanel.addTab("Interactive", spInter); // init will do the link between the tree view and the pane testInterractivePanel.init(); // Define the listener to display the pane depending on the selected tab mTreeTabsPanel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { String componentName = mTreeTabsPanel.getTitleAt(mTreeTabsPanel.getSelectedIndex()); CardLayout rcl = (CardLayout) mRightPanels.getLayout(); rcl.show(mRightPanels, componentName); } }); mTestCampaignPanel.addTestCampaignActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getID() == TestCampaignMainPanel.RUN_ID) { if (e.getActionCommand().equals(TestCampaignMainPanel.STARTED_CMD)) { // open the tab test cases SwingUtilities.invokeLater(new Runnable() { public void run() { mTreeTabsPanel.setSelectedIndex(0); mTestCasePanel.setSelectedTab(TestCasePane.RESULTS_INDEX); } }); // update the buttons mTestCasePanel.setExecutingTestCampaign(true, ((TestCampaignMainPanel) e.getSource()).getExecutionThread()); mTestCasePanel.updateButtons(true); } else if (e.getActionCommand().equals(TestCampaignMainPanel.STOPPED_CMD)) { mTestCasePanel.setExecutingTestCampaign(false, null); mTestCasePanel.updateButtons(); } } } }); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTreeTabsPanel, mRightPanels); splitPane.setDividerSize(4); GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); int mainHorizontalSplitDividerLocation = guiConfiguration .getInt(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, 285); splitPane.setDividerLocation(mainHorizontalSplitDividerLocation); splitPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("dividerLocation")) { GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); if (evt.getSource() instanceof JSplitPane) { JSplitPane splitPane = (JSplitPane) evt.getSource(); guiConfiguration.setProperty(MAIN_HORIZONTAL_SPLIT_DIVIDER_LOCATION_PROPERTY, splitPane.getDividerLocation()); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } } } }); topanel.add(iconlabel, BorderLayout.WEST); topanel.add(center); getContentPane().add(topanel, BorderLayout.NORTH); getContentPane().add(splitPane); this.pack(); this.setExtendedState(Frame.MAXIMIZED_BOTH); if (mTestSuiteDir != null) { DirectoryTestSuite testSuite = DirectoryTestSuite.createDirectoryTestSuite(mTestSuiteDir); if (testSuite != null) { testSuite.setExecutionLoops(mNumberLoops, mLoopsInHour); setTestSuite(testSuite.getName()); mTestCasePanel.runTestSuite(testSuite, false); } } setVisible(true); //treeTabs.setMinimumSize(new Dimension(100, this.HEIGHT)); } catch (Exception e) { logger.fatal(e); e.printStackTrace(); TestEngine.shutdown(); System.exit(1); } }
From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppModule.java
@Provides @Singleton/*from www.j a v a2 s.co m*/ Configuration provideConfiguration() { PropertiesConfiguration configuration = null; if (Files.exists(configFile)) { try { configuration = new PropertiesConfiguration(configFile.toFile()); } catch (ConfigurationException e) { LOG.error(e.getMessage(), e); System.exit(-1); } LOG.info("Using configuration file: " + configFile); } if (configuration == null) { LOG.error("Could not find configuration file: " + configFile); printConfigurationTemplate(); System.exit(-1); } if (configuration.isEmpty()) { LOG.error("Configuration file was empty: " + configFile); printConfigurationTemplate(); System.exit(-1); } if (!dk.dma.ais.abnormal.analyzer.config.Configuration.isValid(configuration)) { LOG.error("Configuration is invalid: " + configFile); printConfigurationTemplate(); System.exit(-1); } LOG.info("Configuration file located, read and presumed valid."); return configuration; }
From source file:com.qspin.qtaste.ui.ConfigInfoPanel.java
public void init() { setLayout(new GridBagLayout()); GridBagLineAdder adder = new GridBagLineAdder(this); adder.setWeight(1.0f, 0.0f);/* w w w .j av a 2s. c o m*/ adder.setLength(6); //1st column - 1st row adder.setWeight(0.0, 0.0); adder.add(new JLabel("Test suite:")); adder.setWeight(1.0, 0.0); adder.add(mTestSuiteLabel); adder.setWeight(0.0, 0.0); //2d column - 1st row adder.add(new JLabel("Testbed config:")); // set the combobox as read only (not possible to modify the testbed from GUI at this time UIManager.put("ComboBox.disabledForeground", Color.BLACK); mTestbedList.setEnabled(true); adder.add(mTestbedList); // add testbed mouse listener, for the "Edit File" action TestbedMouseListener testbedMouseListener = new TestbedMouseListener(); java.awt.Component[] mTestbedListComponents = mTestbedList.getComponents(); for (int i = 0; i < mTestbedListComponents.length; i++) { mTestbedListComponents[i].addMouseListener(testbedMouseListener); } // go to second row adder.addSeparator(); //1st column - 2d row adder.add(new JLabel("Test results directory:")); adder.add(mTestResultsLabel); //2d column - 2d row m_ignoreControlScript.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TestEngine.setIgnoreControlScript(ignoreControlScript()); setControlTestbedButtonsEnabled(); GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); guiConfiguration.setProperty(StaticConfiguration.IGNORE_CONTROL_SCRIPT_PROPERTY, m_ignoreControlScript.isSelected()); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } }); adder.add(m_ignoreControlScript); JPanel sutPanel = new JPanel(); JLabel sutVersion = new JLabel("SUT version: "); sutPanel.add(sutVersion); m_SUTVersion.setHorizontalAlignment(JTextField.RIGHT); m_SUTVersion.setPreferredSize(new Dimension(150, m_SUTVersion.getPreferredSize().height)); sutPanel.add(m_SUTVersion); adder.add(sutPanel); m_SUTVersion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TestBedConfiguration.setSUTVersion(m_SUTVersion.getText()); } }); //create a 3d row adder.addSeparator(); //1st column - 3d row adder.add(new JLabel("Reporting Format:")); adder.add(mTestReportingFormat); //2d column - 3d row // add a button to manually start the testbed m_startTestbed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { isStartingOrStoppingTestbed = true; setControlTestbedButtonsEnabled(); parent.getTestCasePanel().setStopButtonEnabled(true, true); parent.getTestCasePanel().showTestcaseResultsTab(); TestBedConfiguration.setSUTVersion(getSUTVersion()); new SUTStartStopThread("start").start(); } }); m_startTestbed.setEnabled(false); adder.add(m_startTestbed); // add a button to manually stop the testbed m_stopTestbed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { isStartingOrStoppingTestbed = true; setControlTestbedButtonsEnabled(); parent.getTestCasePanel().showTestcaseResultsTab(); TestBedConfiguration.setSUTVersion(getSUTVersion()); new SUTStartStopThread("stop").start(); } }); m_stopTestbed.setEnabled(false); adder.add(m_stopTestbed); DefaultComboBoxModel model = (DefaultComboBoxModel) mTestbedList.getModel(); model.removeAllElements(); String testbedDir = testbedConfig.getFile().getParent(); File fTestbedDir = new File(testbedDir); FileMask fileMask = new FileMask(); fileMask.addExtension("xml"); File[] fTestbedList = FileUtilities.listSortedFiles(fTestbedDir, fileMask); for (int i = 0; i < fTestbedList.length; i++) { // remove the extension String testbedName = fTestbedList[i].getName().substring(0, fTestbedList[i].getName().lastIndexOf('.')); model.addElement(testbedName); } mTestbedList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (mTestbedList.getSelectedItem() != null) { String selectedTestbed = (String) mTestbedList.getSelectedItem(); String configFile = StaticConfiguration.TESTBED_CONFIG_DIRECTORY + "/" + selectedTestbed + "." + StaticConfiguration.TESTBED_CONFIG_FILE_EXTENSION; TestBedConfiguration.setConfigFile(configFile); GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); guiConfiguration.setProperty(StaticConfiguration.LAST_SELECTED_TESTBED_PROPERTY, selectedTestbed); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } refreshData(); } }); refreshTestBed(); refreshData(); if (GUIConfiguration.getInstance().getBoolean(StaticConfiguration.IGNORE_CONTROL_SCRIPT_PROPERTY, false)) m_ignoreControlScript.doClick(); TestBedConfiguration .registerConfigurationChangeHandler(new TestBedConfiguration.ConfigurationChangeHandler() { public void onConfigurationChange() { testbedConfig = TestBedConfiguration.getInstance(); String configFileName = testbedConfig.getFile().getName(); mTestbedList.getModel() .setSelectedItem(configFileName.substring(0, configFileName.lastIndexOf('.'))); } }); }
From source file:com.nilostep.xlsql.database.xlInstanceOLD.java
private xlInstanceOLD(String cfg) throws xlException { logger = Logger.getLogger(this.getClass().getName()); instance = this; //name = cfg; try {//ww w . ja v a 2s . c o m // file = new File(cfg + "_config.xml"); // handler = new XMLFileHandler(); // handler.setFile(file); // // cm = ConfigurationManager.getInstance(); // config = cm.getConfiguration(name); // config.addConfigurationListener(this); // // if (file.exists()) { PropertiesConfiguration config = new PropertiesConfiguration(); config.load(this.getClass().getResourceAsStream(cfg + ".properties")); String engine = config.getString("general.engine"); //cm.load(handler, name); //Category cat = config.getCategory("general"); //engine = config.getProperty("engine", null, "general"); //config.setCategory(engine, true); //logger.info("Configuration file: " + file + " loaded"); logger.info("Configuration engine: " + engine + " loaded"); // } else { // // assert (config.isNew()); // // // // config.setCategory("general", true); // // String engine = "hsqldb"; // setLog("xlsql.log"); // setDatabase(System.getProperty("user.dir")); // // // // this.engine = engine; // this.config.setProperty("engine", engine); // addEngine(engine); // config.setCategory(engine, true); // // // // // setDriver("org.hsqldb.jdbcDriver"); // setUrl("jdbc:hsqldb:."); // setSchema(""); // setUser("sa"); // setPassword(""); // config.setCategory(getEngine(), true); // logger.info("Configuration file: " + file + " created."); // } } //catch (ConfigurationManagerException cme) { // config = cm.getConfiguration(name); //} catch (ConfigurationException e) { e.printStackTrace(); throw new xlException(e.getMessage()); } try { if (getLog() == null) { setLog("xlsql.log"); } 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()); logger.info("Instance created with engine " + engine); // // // }
From source file:com.vangent.hieos.empi.config.EMPIConfig.java
/** * /*w w w.java 2 s . c om*/ * @throws EMPIException */ private void loadConfiguration() throws EMPIException { String empiConfigDir = XConfig.getConfigLocation(XConfig.ConfigItem.EMPI_DIR); String configLocation = empiConfigDir + "/" + EMPIConfig.EMPI_CONFIG_FILE_NAME; String codesConfigLocation = empiConfigDir + "/" + EMPIConfig.EMPI_CODES_CONFIG_FILE_NAME; try { XMLConfiguration xmlConfig = new XMLConfiguration(configLocation); jndiResourceName = xmlConfig.getString(JNDI_RESOURCE_NAME, DEFAULT_JNDI_RESOURCE_NAME); subjectSequenceGeneratorSQL = xmlConfig.getString(SUBJECT_SEQUENCE_GENERATOR_SQL, "UNKNOWN SUBJECT SEQUENCE GENERATOR SQL"); updateNotificationEnabled = xmlConfig.getBoolean(UPDATE_NOTIFICATION_ENABLED, false); identitySourceFilteringEnabled = xmlConfig.getBoolean(IDENTITY_SOURCE_FILTERING_ENABLED, false); validateCodesEnabled = xmlConfig.getBoolean(VALIDATE_CODES_ENABLED, true); validateIdentitySourcesEnabled = xmlConfig.getBoolean(VALIDATE_IDENTITY_SOURCES_ENABLED, true); empiDeviceIds = xmlConfig.getStringArray(EMPI_DEVICE_IDS); // Load account number treatment configuration. this.loadAccountNumberTreatmentConfig(xmlConfig); // Load the candidate finder. this.loadCandidateFinder(xmlConfig); // Load the match algorithm. this.loadMatchAlgorithm(xmlConfig); // Load function configurations. this.loadFunctionConfigs(xmlConfig); // Load field configurations. this.loadFieldConfigs(xmlConfig); // Load matching configurations. // Configuration to support feeds. matchConfigFeed = new MatchConfig(); matchConfigFeed.load(xmlConfig.configurationAt(MATCH_CONFIG_FEED), this); // Configuration to support finds. matchConfigFind = new MatchConfig(); matchConfigFind.load(xmlConfig.configurationAt(MATCH_CONFIG_FIND), this); // Load EUID configuration. euidConfig = new EUIDConfig(); euidConfig.load(xmlConfig.configurationAt(EUID_CONFIG), this); // Load identity sources. this.loadIdentitySources(xmlConfig); // Load codes configuration. codesConfig = new CodesConfig(); codesConfig.loadConfiguration(codesConfigLocation); } catch (ConfigurationException ex) { throw new EMPIException( "EMPIConfig: Could not load configuration from " + configLocation + " " + ex.getMessage()); } }
From source file:com.qspin.qtaste.ui.testcampaign.TestCampaignMainPanel.java
public void genUI() { TestCampaignTreeModel model = new TestCampaignTreeModel("Test Campaign"); treeTable = new JTreeTable(model); FormLayout layout = new FormLayout("6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px:grow", "6px, fill:pref, 6px"); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); int colIndex = 2; JLabel label = new JLabel("Campaign:"); saveMetaCampaignButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/save_32")); saveMetaCampaignButton.setToolTipText("Save campaign"); saveMetaCampaignButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (selectedCampaign == null) { logger.warn("No Campaign created"); return; }//w w w. ja va 2 s .c om treeTable.save(selectedCampaign.getFileName(), selectedCampaign.getCampaignName()); } }); addNewMetaCampaignButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/add")); addNewMetaCampaignButton.setToolTipText("Define a new campaign"); addNewMetaCampaignButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newCampaign = JOptionPane.showInputDialog(null, "New campaign creation:", "Campaign name:", JOptionPane.QUESTION_MESSAGE); if (newCampaign != null && newCampaign.length() > 0) { int index = addTestCampaign(newCampaign); metaCampaignComboBox.setSelectedIndex(index); MetaCampaignFile currentSelectedCampaign = (MetaCampaignFile) metaCampaignComboBox .getSelectedItem(); selectedCampaign = currentSelectedCampaign; if (selectedCampaign != null) { treeTable.save(selectedCampaign.getFileName(), selectedCampaign.getCampaignName()); } metaCampaignComboBox.validate(); metaCampaignComboBox.repaint(); } } }); // get last selected campaign GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); String lastSelectedCampaign = guiConfiguration.getString(LAST_SELECTED_CAMPAIGN_PROPERTY); // add campaigns found in the list MetaCampaignFile[] campaigns = populateCampaignList(); builder.add(label, cc.xy(colIndex, 2)); colIndex += 2; builder.add(metaCampaignComboBox, cc.xy(colIndex, 2)); colIndex += 2; // add test campaign mouse listener, for the Rename and Remove actions TestcampaignMouseListener testcampaignMouseListener = new TestcampaignMouseListener(); java.awt.Component[] mTestcampaignListComponents = metaCampaignComboBox.getComponents(); for (int i = 0; i < mTestcampaignListComponents.length; i++) { mTestcampaignListComponents[i].addMouseListener(testcampaignMouseListener); } metaCampaignComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MetaCampaignFile currentSelectedCampaign = (MetaCampaignFile) metaCampaignComboBox .getSelectedItem(); if (currentSelectedCampaign != selectedCampaign) { selectedCampaign = currentSelectedCampaign; if (selectedCampaign != null) { treeTable.removeAll(); if (new File(selectedCampaign.getFileName()).exists()) { treeTable.load(selectedCampaign.getFileName()); } GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); guiConfiguration.setProperty(LAST_SELECTED_CAMPAIGN_PROPERTY, selectedCampaign.getCampaignName()); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage(), ex); } } else { treeTable.removeAll(); } } } }); boolean setLastSelectedCampaign = false; if (lastSelectedCampaign != null) { // select last selected campaign for (int i = 0; i < campaigns.length; i++) { if (campaigns[i].getCampaignName().equals(lastSelectedCampaign)) { metaCampaignComboBox.setSelectedIndex(i); setLastSelectedCampaign = true; break; } } } if (!setLastSelectedCampaign && metaCampaignComboBox.getItemCount() > 0) { metaCampaignComboBox.setSelectedIndex(0); } runMetaCampaignButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/running_32")); runMetaCampaignButton.setToolTipText("Run campaign"); runMetaCampaignButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (selectedCampaign == null) { logger.warn("No Campaign created"); return; } // first save the current campaign if needed if (treeTable.hasChanged()) { treeTable.save(selectedCampaign.getFileName(), selectedCampaign.getCampaignName()); } // set SUT version TestBedConfiguration.setSUTVersion(parent.getSUTVersion()); testExecutionHandler = new CampaignExecutionThread(selectedCampaign.getFileName()); Thread t = new Thread(testExecutionHandler); t.start(); // set the window to test result // TO DO } catch (Exception ex) { // logger.error(ex.getMessage(), ex); } } }); builder.add(addNewMetaCampaignButton, cc.xy(colIndex, 2)); colIndex += 2; builder.add(saveMetaCampaignButton, cc.xy(colIndex, 2)); colIndex += 2; builder.add(runMetaCampaignButton, cc.xy(colIndex, 2)); colIndex += 2; JScrollPane sp = new JScrollPane(treeTable); this.add(builder.getPanel(), BorderLayout.NORTH); this.add(sp); }
From source file:dk.dbc.opensearch.datadock.DatadockMain.java
/** * * //www. j a va 2 s .c om * @param args * @throws ConfigurationException */ public DatadockMain(String[] args) throws ConfigurationException { /** Try obtaining home path of datadock. If property 'datadock.home' is not set, * current working directory is assumed to be home. */ String datadockHome = System.getProperty("datadock.home"); if (datadockHome == null) { datadockHome = new File(".").getAbsolutePath(); } else { datadockHome = new File(datadockHome).getAbsolutePath(); } log.info(String.format("Using datadock.home: %s", datadockHome)); System.out.println(String.format("Using datadock.home: %s", datadockHome)); Configuration config = null; // Try reading properties file from -Dproperties.file String localPropFileName = System.getProperty("properties.file"); // If -Dpropfile is not set try reading from either ../config/datadock.properties or ./config/datadock.properties if (localPropFileName != null) { config = new PropertiesConfiguration(localPropFileName); } else { localPropFileName = "../config/" + propFileName; if (new File(localPropFileName).exists()) { config = new PropertiesConfiguration(localPropFileName); } localPropFileName = "./config/" + propFileName; if (new File(localPropFileName).exists()) { config = new PropertiesConfiguration(localPropFileName); } } // Throw new ConfigurationException if properties file could not be located. if (config == null) { throw new ConfigurationException( String.format("Could not load configuration from configuration file: %s; CWD: %s", localPropFileName, new File(".").getAbsoluteFile())); } log.info(String.format("Using properties file: %s", localPropFileName)); try { String configFile = config.getString("Log4j"); if (new File(configFile).exists()) { Log4jConfiguration.configure(configFile); } else { if (configFile.startsWith("../")) { configFile = configFile.replaceFirst("../", ""); if (new File(configFile).exists()) { Log4jConfiguration.configure(configFile); } else { throw new ConfigurationException( String.format("Could not locate config file at: %s", config.getString("Log4j"))); } } else { throw new ConfigurationException( String.format("Could not locate config file at: %s", config.getString("Log4j"))); } } log.info(String.format("Using config file: %s", configFile)); } catch (ConfigurationException ex) { String errMsg = String.format("Logger could not be configured, will continue without logging: %s", ex.getMessage()); log.error(errMsg); System.out.println(errMsg); } pollTime = config.getInt("MainPollTime"); queueSize = config.getInt("QueueSize"); corePoolSize = config.getInt("CorePoolSize"); maxPoolSize = config.getInt("MaxPoolSize"); keepAliveTime = config.getInt("KeepAliveTime"); log.debug(String.format("Starting Datadock with pollTime = %s", pollTime)); log.debug(String.format("Starting Datadock with queueSize = %s", queueSize)); log.debug(String.format("Starting Datadock with corePoolSize = %s", corePoolSize)); log.debug(String.format("Starting Datadock with maxPoolSize = %s", maxPoolSize)); log.debug(String.format("Starting Datadock with keepAliveTime = %s", keepAliveTime)); pluginFlowXmlPath = new File(config.getString("PluginFlowXmlPath")); pluginFlowXsdPath = new File(config.getString("PluginFlowXsdPath")); if (null == pluginFlowXmlPath || null == pluginFlowXsdPath) { throw new ConfigurationException( "Failed to initialize configuration values for File objects properly (pluginFlowXmlPath or pluginFlowXsdPath)"); } log.debug(String.format("Starting Datadock with pluginFlowXmlPath = %s", pluginFlowXmlPath)); log.debug(String.format("Starting Datadock with pluginFlowXsdPath = %s", pluginFlowXsdPath)); maxToHarvest = config.getInt("MaxToHarvest"); dataBaseNames = config.getList("OracleDataBaseNames"); oracleCacheName = config.getString("OracleCacheName"); oracleUrl = config.getString("OracleUrl"); oracleUser = config.getString("OracleUserID"); oraclePassWd = config.getString("OraclePassWd"); minLimit = config.getString("OracleMinLimit"); maxLimit = config.getString("OracleMaxLimit"); initialLimit = config.getString("OracleInitialLimit"); connectionWaitTimeout = config.getString("OracleConnectionWaitTimeout"); usePriorityFlag = config.getBoolean("UsePriorityField"); host = config.getString("Host"); port = config.getString("Port"); user = config.getString("User"); pass = config.getString("PassPhrase"); javascriptPath = config.getString("ScriptPath"); fileHarvestLightDir = config.getString("ToHarvest"); fileHarvestLightSuccessDir = config.getString("HarvestDone"); fileHarvestLightFailureDir = config.getString("HarvestFailure"); }
From source file:com.termmed.statistics.Processor.java
/** * Execute./* w ww . jav a 2 s . c o m*/ * * @throws IOException Signals that an I/O exception has occurred. * @throws Exception the exception */ public void execute() throws IOException, Exception { logger.logInfo("Starting report execution"); createFolders(); XMLConfiguration xmlConfig; try { xmlConfig = new XMLConfiguration(configFile); } catch (ConfigurationException e) { logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage()); throw e; } createDetails = xmlConfig.getString("createDetailReports"); String dependentRelease = xmlConfig.getString("dependentReleaseFullFolder"); enableListeners = true; if (dependentRelease == null || dependentRelease.trim().equals("")) { enableListeners = false; } List<HierarchicalConfiguration> listDescriptors = xmlConfig .configurationsAt("interestConceptLists.conceptListDescriptor"); List<HierarchicalConfiguration> fields = xmlConfig.configurationsAt("reports.reportDescriptor"); String excList = xmlConfig.getString("createExcluyentDetailLists"); boolean createExcluyentDetailLists = false; if (excList != null && excList.equals("true")) { createExcluyentDetailLists = true; } mapExcluyentListFile = new TreeMap<Integer, IReportDetail>(); for (HierarchicalConfiguration sub : fields) { String report = sub.getString("filename"); String value = sub.getString("execute"); if (value.toLowerCase().equals("true")) { logger.logInfo("Getting report config for " + report); ReportConfig reportCfg = ResourceUtils.getReportConfig(report); logger.logInfo("Executing report " + report); long start = logger.startTime(); executeReport(reportCfg); logger.logInfo("Writing report " + report); writeReports(reportCfg, report, listDescriptors); String msg = logger.endTime(start); int posIni = msg.indexOf("ProcessingTime:") + 16; ReportInfo rInfo = new ReportInfo(); rInfo.setName(reportCfg.getName()); if (reportCfg.getOutputFile() != null) { for (OutputFileTableMap file : reportCfg.getOutputFile()) { rInfo.getOutputFiles().add(file.getFile()); } } if (reportCfg.getOutputDetailFile() != null) { for (OutputDetailFile file : reportCfg.getOutputDetailFile()) { rInfo.getOutputDetailFiles().add(file.getFile()); } } rInfo.setTimeTaken(msg.substring(posIni)); OutputInfoFactory.get().getStatisticProcess().getReports().add(rInfo); if (createExcluyentDetailLists) { if (reportCfg.getOutputDetailFile() != null) { for (OutputDetailFile file : reportCfg.getOutputDetailFile()) { Integer priority = file.getExcluyentListPriority(); if (priority != null) { mapExcluyentListFile.put(priority, file); } } } } } // System.out.println(report + " " + value); } if (createExcluyentDetailLists) { File outputFold = createOutputExcluyentListFolder(); createExcluyentList(outputFold, listDescriptors); } }
From source file:de.xirp.settings.Settings.java
/** * Saves the changed parts of the preferences and fires a * {@link SettingsChangedEvent} if the preferences had really * changed. The preferences are only persisted if properties for * saving were given.// w w w . j a v a 2 s. co m */ public void save() { // remember if anything has changed which has to be saved // it's faster than checking previously with hasChanged boolean saved = false; for (SettingsPage page : pages) { saved |= page.save(doSave); } // if anything has changed save the preferences to the file // and fire the changed event if (saved) { fireChangedEvent(new SettingsChangedEvent(this)); if (doSave) { try { config.save(); } catch (ConfigurationException e) { logClass.debug("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$ } } } }
From source file:fr.inria.wimmics.prissma.selection.Matcher.java
public Matcher(Decomposition decomp) { if (decomp == null) this.decomp = new Decomposition(); else//from w w w . ja v a 2 s .c o m this.decomp = decomp; this.inputGraphContextUnits = new HashSet<ContextUnit>(); this.inputGraphEdges = new HashSet<Edge>(); this.candidates = new HashMap<Integer, List<ETSubgraphIsomorphism>>(); this.winners = new HashMap<Integer, List<ETSubgraphIsomorphism>>(); this.results = new HashSet<URI>(); // read params from property file try { Configuration config = new PropertiesConfiguration("config.properties"); PrissmaProperties.THRESHOLD = config.getDouble("threshold"); PrissmaProperties.MISSING_CTXUNIT_ENTITY_COST = config.getDouble("missing_ctxunit_entity_cost"); PrissmaProperties.MISSING_CTXUNIT_STRING_COST = config.getDouble("missing_ctxunit_string_cost"); PrissmaProperties.DECAY_CONSTANT_TIME = config.getDouble("decay_constant_time"); PrissmaProperties.DECAY_CONSTANT_GEO = config.getDouble("decay_constant_geo"); switch (config.getString("string_similarity")) { case "JARO": PrissmaProperties.STRING_SIMILARITY = StringSimilarity.JARO; break; case "JARO_WINKLER": PrissmaProperties.STRING_SIMILARITY = StringSimilarity.JARO_WINKLER; break; case "MONGE_ELKAN": PrissmaProperties.STRING_SIMILARITY = StringSimilarity.MONGE_ELKAN; break; case "LEVENSTHEIN": PrissmaProperties.STRING_SIMILARITY = StringSimilarity.LEVENSTHEIN; break; case "LIN": PrissmaProperties.STRING_SIMILARITY = StringSimilarity.LIN; break; case "WUPALMER": PrissmaProperties.STRING_SIMILARITY = StringSimilarity.WUPALMER; break; case "PATH": PrissmaProperties.STRING_SIMILARITY = StringSimilarity.PATH; break; default: LOG.error("Similarity measure not supported"); break; } PrissmaProperties.ENTITIES_PATH = config.getString("fresnel_folder"); } catch (ConfigurationException e) { LOG.error("Error reading property file {}", e.getMessage()); } }