List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:pl.otros.logview.gui.LogViewMainFrame.java
private static XMLConfiguration getConfiguration(String file) { XMLConfiguration commonConfiguration = new XMLConfiguration(); File commonConfigurationFile = new File(file); // load common configuration if (commonConfigurationFile.exists()) { LOGGER.info("Loading common configuration from " + commonConfigurationFile.getAbsolutePath()); try {/*from ww w.j a v a2s . c o m*/ commonConfiguration.load(commonConfigurationFile); } catch (ConfigurationException e) { LOGGER.severe("Can't load configuration, creating new " + e.getMessage()); } } else { LOGGER.info("Common configuration file do not exist"); } // load user specific configuration if (!AllPluginables.USER_CONFIGURATION_DIRECTORY.exists()) { LOGGER.info("Creating user specific OtrosLogViewer configuration directory " + AllPluginables.USER_CONFIGURATION_DIRECTORY.getAbsolutePath()); AllPluginables.USER_CONFIGURATION_DIRECTORY.mkdirs(); AllPluginables.USER_FILTER.mkdirs(); AllPluginables.USER_LOG_IMPORTERS.mkdirs(); AllPluginables.USER_MARKERS.mkdirs(); AllPluginables.USER_MESSAGE_FORMATTER_COLORZIERS.mkdirs(); } XMLConfiguration userConfiguration = new XMLConfiguration(); File userConfigurationFile = new File(AllPluginables.USER_CONFIGURATION_DIRECTORY + File.separator + file); userConfiguration.setFile(userConfigurationFile); if (userConfigurationFile.exists()) { try { userConfiguration.load(); } catch (ConfigurationException e) { LOGGER.severe(String.format("Can't load user configuration from %s: %s", userConfigurationFile.getAbsolutePath(), e.getMessage())); } } Iterator<?> keys = commonConfiguration.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); if (!userConfiguration.containsKey(key)) { userConfiguration.setProperty(key, commonConfiguration.getProperty(key)); } } userConfiguration.setAutoSave(true); return userConfiguration; }
From source file:pl.otros.logview.gui.LogViewMainFrame.java
private static Configuration getVfsFavoritesConfiguration() { File file = new File(AllPluginables.USER_CONFIGURATION_DIRECTORY + File.separator + "vfsFavorites.xml"); XMLConfiguration configuration = new XMLConfiguration(); configuration.setFile(file);//from w w w . j a va 2 s.c o m if (file.exists()) { try { configuration.load(); } catch (ConfigurationException e) { LOGGER.severe(String.format("Can't load user configuration from %s: %s", file.getAbsolutePath(), e.getMessage())); } } configuration.setAutoSave(true); return configuration; }
From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java
public MessageColorizerBrowser(OtrosApplication otrosApplication) { super(new BorderLayout()); this.container = otrosApplication.getAllPluginables().getMessageColorizers(); this.otrosApplication = otrosApplication; toolBar = new JToolBar(); editor = new MessageColorizerEditor(container, otrosApplication.getStatusObserver()); JLabel noEditable = new JLabel("Selected MessageColorizer is not editable.", SwingConstants.CENTER); JLabel nothingSelected = new JLabel("Nothing selected", SwingConstants.CENTER); listModel = new PluginableElementListModel<MessageColorizer>(container); jList = new JList(listModel); jList.setCellRenderer(new PluginableElementNameListRenderer()); cardLayout = new CardLayout(); contentPanel = new JPanel(cardLayout); contentPanel.add(editor, CARD_LAYOUT_EDITOR); contentPanel.add(noEditable, CARD_LAYOUT_NOT_EDITABLE); contentPanel.add(nothingSelected, CARD_LAYOUT_NO_SELECTED); cardLayout.show(contentPanel, CARD_LAYOUT_NOT_EDITABLE); JSplitPane mainSplitPane = new JSplitPane(SwingConstants.VERTICAL, new JScrollPane(jList), contentPanel); mainSplitPane.setDividerLocation(220); jList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override//from www . ja v a 2 s .com public void valueChanged(ListSelectionEvent e) { showSelected(); enableDisableButtonsForSelectedColorizer(); } }); jList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_DELETE) { ActionEvent actionEvent = new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, ""); deleteAction.actionPerformed(actionEvent); } } }); JButton createNew = new JButton("Create new", Icons.ADD); createNew.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveAsButton.setEnabled(false); createNew(); } }); saveButton = new JButton("Save and use", Icons.DISK); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { PropertyPatternMessageColorizer mc = editor.createMessageColorizer(); File selectedFile = null; String f = mc.getFile(); if (StringUtils.isNotBlank(f)) { selectedFile = new File(mc.getFile()); } else { int response = chooser.showSaveDialog(MessageColorizerBrowser.this); if (response != JFileChooser.APPROVE_OPTION) { return; } selectedFile = chooser.getSelectedFile(); if (!selectedFile.getName().endsWith(".pattern")) { selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern"); } } removeMessageColorizerWithNullFile(); applyMessageColorizer(selectedFile); saveMessageColorizer(selectedFile); jList.setSelectedValue(mc, true); } catch (ConfigurationException e1) { String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage()); LOGGER.severe(errorMessage); MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage, StatusObserver.LEVEL_ERROR); } } }); saveAsButton = new JButton("Save as", Icons.DISK_PLUS); saveAsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int response = chooser.showSaveDialog(MessageColorizerBrowser.this); if (response != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = chooser.getSelectedFile(); selectedFile = chooser.getSelectedFile(); if (!selectedFile.getName().endsWith(".pattern")) { selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern"); } removeMessageColorizerWithNullFile(); applyMessageColorizer(selectedFile); saveMessageColorizer(selectedFile); jList.setSelectedValue(editor.createMessageColorizer(), true); } catch (ConfigurationException e1) { String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage()); LOGGER.severe(errorMessage); MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage, StatusObserver.LEVEL_ERROR); } } }); useButton = new JButton("Use without saving"); useButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { removeMessageColorizerWithNullFile(); applyMessageColorizer(File.createTempFile("messageColorizer", "pattern")); } catch (Exception e) { LOGGER.severe("Cannot create message colorizer: " + e.getMessage()); } } }); deleteAction = new DeleteSelected(otrosApplication); deleteButton = new JButton(deleteAction); toolBar.setFloatable(false); toolBar.add(createNew); toolBar.add(saveButton); toolBar.add(saveAsButton); toolBar.add(useButton); toolBar.add(deleteButton); enableDisableButtonsForSelectedColorizer(); initFileChooser(); this.add(mainSplitPane); this.add(toolBar, BorderLayout.SOUTH); }
From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java
protected void createNew() { PropertyPatternMessageColorizer colorizer = new PropertyPatternMessageColorizer(); try {// w w w . j av a 2 s. c o m colorizer.init(new ByteArrayInputStream(getDefaultContent().getBytes())); } catch (ConfigurationException e) { otrosApplication.getStatusObserver().updateStatus( "Can't load message colorizer template: " + e.getMessage(), StatusObserver.LEVEL_WARNING); } colorizer.setFile(""); container.addElement(colorizer); jList.setSelectedValue(colorizer, true); saveAsButton.setEnabled(false); }
From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java
protected void showSelected() { MessageColorizer selectedValue = (MessageColorizer) jList.getSelectedValue(); boolean actionEnabled = false; if (selectedValue == null) { cardLayout.show(contentPanel, CARD_LAYOUT_NO_SELECTED); } else if (selectedValue instanceof PropertyPatternMessageColorizer) { PropertyPatternMessageColorizer mc = (PropertyPatternMessageColorizer) selectedValue; try {// w w w . j a va2 s . c om editor.setMessageColorizer(mc); actionEnabled = true; } catch (ConfigurationException e) { otrosApplication.getStatusObserver().updateStatus("Can't edit message colorizer: " + e.getMessage(), StatusObserver.LEVEL_ERROR); } cardLayout.show(contentPanel, CARD_LAYOUT_EDITOR); } else { cardLayout.show(contentPanel, CARD_LAYOUT_NOT_EDITABLE); } useButton.setEnabled(actionEnabled); saveButton.setEnabled(actionEnabled); saveAsButton.setEnabled(actionEnabled); }
From source file:pl.otros.logview.persistance.PersistentConfiguration.java
private static XMLConfiguration getXMLConfiguration(String file) { XMLConfiguration xmlConfiguration = new XMLConfiguration(); try {/*from www .j ava 2 s.c om*/ xmlConfiguration = new XMLConfiguration(); xmlConfiguration.setFile(new File(file)); xmlConfiguration.load(); xmlConfiguration.setAutoSave(true); } catch (ConfigurationException e) { LOGGER.severe("Can't load configuration, creating new " + e.getMessage()); try { xmlConfiguration.save(); xmlConfiguration.setAutoSave(true); } catch (ConfigurationException e1) { LOGGER.severe("Can't create persistent configuration: " + e1.getMessage()); } } return xmlConfiguration; }
From source file:slib.tools.module.ModuleCst.java
/** * * @param propertiesFile/* www . j av a 2 s .c o m*/ * @param prefix * @throws SLIB_Ex_Critic */ public ModuleCst(String propertiesFile, String prefix) throws SLIB_Ex_Critic { Configuration config; try { config = new PropertiesConfiguration(propertiesFile); } catch (ConfigurationException ex) { throw new SLIB_Ex_Critic("Unable to load configuration file (properties) " + ex.getMessage()); } this.appName = config.getString(prefix + ".name"); this.version = config.getString(prefix + ".version"); this.reference = config.getString(prefix + ".reference"); this.description = config.getString(prefix + ".description"); this.contact = config.getString(prefix + ".contact"); this.versionSnapshot = config.getString(prefix + ".build.snapshot"); }
From source file:tld.yourname.jms.server.JMSServer.java
/** * * @param aArgs/*from w w w . j av a 2 s. co m*/ * @return */ public JWSEndPoint start(String[] aArgs) { // set up log4j logging // later this should be read from a shared log4j properties or xml file! Properties lProps = new Properties(); lProps.setProperty("log4j.rootLogger", "INFO, console"); lProps.setProperty("log4j.logger.org.apache.activemq", "WARN"); lProps.setProperty("log4j.logger.org.springframework", "WARN"); lProps.setProperty("log4j.logger.org.apache.xbean", "WARN"); lProps.setProperty("log4j.logger.org.apache.camel", "INFO"); lProps.setProperty("log4j.logger.org.eclipse.jetty", "WARN"); lProps.setProperty("log4j.appender.console", "org.apache.log4j.ConsoleAppender"); lProps.setProperty("log4j.appender.console.layout", "org.apache.log4j.PatternLayout"); lProps.setProperty("log4j.appender.console.layout.ConversionPattern", // "%p: %m%n" "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p - %C{1}: %m%n"); // set here the jWebSocket log level: lProps.setProperty("log4j.logger.org.jwebsocket", "DEBUG"); lProps.setProperty("log4j.appender.console.threshold", "DEBUG"); PropertyConfigurator.configure(lProps); final JWSAutoSelectAuthenticator lAuthenticator = new JWSAutoSelectAuthenticator(); final JWSOAuthAuthenticator lOAuthAuthenticator = new JWSOAuthAuthenticator(); final JWSLDAPAuthenticator lLDAPAuthenticator = new JWSLDAPAuthenticator(); mLog.info("jWebSocket JMS Gateway Server Endpoint"); Configuration lConfig = null; boolean lConfigLoaded; try { // try to load properties files from local folder or jar String lPath = "JMSServer.properties"; mLog.debug("Trying to read properties from: " + lPath); lConfig = new PropertiesConfiguration(lPath); } catch (ConfigurationException ex) { } if (null == lConfig) { try { // try to load properties files from JWEBSOCKET_HOME/conf/JMSPlugIn String lPath = Tools.expandEnvVarsAndProps("/private/JMSServer.properties"); // String lPath = Tools.expandEnvVarsAndProps("${JWEBSOCKET_HOME}conf/JMSPlugIn/JMSServer.properties"); mLog.debug("Tring to read properties from: " + lPath); lConfig = new PropertiesConfiguration(lPath); } catch (ConfigurationException ex) { } } if (null == lConfig) { mLog.error("Configuration file could not be opened."); return null; } // the URL of the message broker String lBrokerURL = lConfig.getString("BrokerURL", "tcp://127.0.0.1:61616"); // "failover:(tcp://0.0.0.0:61616,tcp://127.0.0.1:61616)?initialReconnectDelay=100&randomize=false"; // the name of the JMS Gateway topic String lGatewayTopic = lConfig.getString("GatewayTopic", "org.jwebsocket.jms.gateway"); // endpoint id of JMS Gateway String lGatewayId = lConfig.getString("GatewayId", "org.jwebsocket.jms.gateway"); String lEndPointId = lConfig.getString("EndPointId", UUID.randomUUID().toString()); // get authentication information against jWebSocket final String lJWSUsername = lConfig.getString("JWSUsername"); final String lJWSPassword = lConfig.getString("JWSPassword"); final boolean lFullTextLogging = lConfig.getBoolean("FullTextLogging", false); // set up OAuth Authenticator boolean lUseOAuth = lConfig.getBoolean("UseOAuth", false); String lOAuthHost = lConfig.getString("OAuthHost"); String lOAuthAppId = lConfig.getString("OAuthAppId"); String lOAuthAppSecret = lConfig.getString("OAuthAppSecret"); String lOAuthUsername = lConfig.getString("OAuthUsername"); String lOAuthPassword = lConfig.getString("OAuthPassword"); long lOAuthTimeout = lConfig.getLong("OAuthTimeout", 5000); lUseOAuth = lUseOAuth && null != lOAuthHost && null != lOAuthAppId && null != lOAuthAppSecret && null != lOAuthUsername && null != lOAuthPassword; if (lUseOAuth) { lOAuthAuthenticator.init(lOAuthHost, lOAuthAppId, lOAuthAppSecret, lOAuthTimeout); lAuthenticator.addAuthenticator(lOAuthAuthenticator); } // set up LDAP Authenticator boolean lUseLDAP = lConfig.getBoolean("UseLDAP", false); String lLDAPURL = lConfig.getString("LDAPURL"); String lBaseDNGroups = lConfig.getString("BaseDNGroups"); String lBaseDNUsers = lConfig.getString("BaseDNUsers"); if (lUseLDAP) { lLDAPAuthenticator.init(lLDAPURL, lBaseDNGroups, lBaseDNUsers); lAuthenticator.addAuthenticator(lLDAPAuthenticator); } // TODO: Validate config data here! lConfigLoaded = true; if (!lConfigLoaded) { mLog.error("Config not loaded."); System.exit(1); } mLog.info("Using: " + lBrokerURL + ", " + "topic: " + lGatewayTopic + ", " + "gateway-id: " + lGatewayId + ", " + "endpoint-id: " + lEndPointId); // todo: Comment that for production purposes JMSLogging.setFullTextLogging(lFullTextLogging); // instantiate a new jWebSocket JMS Gateway Client try { lJWSEndPoint = JWSEndPoint.getInstance(lBrokerURL, lGatewayTopic, // gateway topic lGatewayId, // gateway endpoint id lEndPointId, // unique node id 5, // thread pool size, messages being processed concurrently JMSEndPoint.TEMPORARY // durable (for servers) or temporary (for clients) ); } catch (JMSException lEx) { mLog.fatal("JMSEndpoint could not be instantiated: " + lEx.getMessage()); System.exit(0); } lJWSEndPoint.addRequestListener("org.jwebsocket.jms.gateway", "welcome", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.info("Received 'welcome', authenticating against jWebSocket..."); Token lToken = TokenFactory.createToken("org.jwebsocket.plugins.system", "login"); lToken.setString("username", lJWSUsername); lToken.setString("password", lJWSPassword); sendToken(aSourceId, lToken); } }); // on response of the login... lJWSEndPoint.addResponseListener("org.jwebsocket.plugins.system", "login", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { int lCode = aToken.getInteger("code", -1); if (0 == lCode) { if (mLog.isInfoEnabled()) { mLog.info("Authentication against jWebSocket successful."); } } else { mLog.error("Authentication against jWebSocket failed!"); } } }); // on response of the login... lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "getUser", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { String lPayload = aToken.getString("payload"); if (mLog.isInfoEnabled()) { mLog.info("Processing 'getUser'..."); } } }); // on response of the login... lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "echo", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { String lPayload = aToken.getString("payload"); if (mLog.isInfoEnabled()) { mLog.info("Processing 'demo1 with Payload '" + lPayload + "'"); } Map<String, Object> lAdditionalResults = new FastMap<String, Object>(); lAdditionalResults.putAll(aToken.getMap()); // lAdditionalResults.remove("sourceId"); lAdditionalResults.remove("payload"); lJWSEndPoint.respondPayload(aToken, 0, // return code "Ok", // return message lAdditionalResults, aToken.getString("payload")); } }); // on response of the login... lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "testProgress", new JWSMessageListener(lJWSEndPoint) { @Override @SuppressWarnings("SleepWhileInLoop") public void processToken(String aSourceId, Token aToken) { int lMax = 10; for (int lIdx = 0; lIdx < lMax; lIdx++) { mLog.debug("Progress iteration " + lIdx + "..."); try { Thread.sleep(333); } catch (InterruptedException lEx) { } lJWSEndPoint.sendProgress(aToken, ((lIdx + 1.0) / lMax) * 100, 0, "Iteration #" + lIdx, null); } lJWSEndPoint.respondPayload(aToken, 0, // return code "Ok", // return message null, aToken.getString("payload")); } }); // ... lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "testCaughtException", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.debug("Testing caught exception..."); // provoke null pointer exception and DO catch it for test purposes int a = 1; int b = 0; try { int c = a / b; lJWSEndPoint.respondPayload(aToken, 0, // return code "Ok", // return message null, aToken.getString("payload")); } catch (Exception Ex) { lJWSEndPoint.respondPayload(aToken, -1, // return code Ex.getClass().getSimpleName() + ": " + Ex.getMessage(), // return message null, aToken.getString("payload")); } } }); // ... lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "testUncaughtException", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.debug("Testing uncaught exception..."); // provoke null pointer exception and do NOT catch it for test purposes int a = 1; int b = 0; int c = a / b; lJWSEndPoint.respondPayload(aToken, 0, // return code "Ok", // return message null, aToken.getString("payload")); } }); // test for the OAuth interface lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "testOAuth", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { Map<String, Object> lArgs = new FastMap<String, Object>(); String lUsername; int lCode = 0; String lMessage = "Ok"; try { lUsername = lOAuthAuthenticator.authToken(aToken); if (null == lUsername) { lCode = -1; lMessage = "User could not be authenticated!"; } else { lArgs.put("username", lUsername); } } catch (JMSEndpointException ex) { lCode = -1; lMessage = ex.getClass().getSimpleName() + " on authentication: " + ex.getMessage(); } lJWSEndPoint.respondPayload(aToken, lCode, // return code lMessage, // return message lArgs, // additional result fields null); // payload } }); // test for the LDAP interface lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "testLDAP", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { Map<String, Object> lArgs = new FastMap<String, Object>(); String lUsername; int lCode = 0; String lMessage = "Ok"; try { lUsername = lLDAPAuthenticator.authToken(aToken); if (null == lUsername) { lCode = -1; lMessage = "User could not be authenticated!"; } else { lArgs.put("username", lUsername); } } catch (JMSEndpointException ex) { lCode = -1; lMessage = ex.getClass().getSimpleName() + " on authentication: " + ex.getMessage(); } lJWSEndPoint.respondPayload(aToken, lCode, // return code lMessage, // return message lArgs, // additional result fields null); // payload } }); // test for the auto authentication interface lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "testAuth", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.debug("Testing auto authenticator..."); Map<String, Object> lArgs = new FastMap<String, Object>(); String lUsername; int lCode = 0; String lMessage = "Ok"; try { checkADUsername(aToken); lUsername = lAuthenticator.authToken(aToken); if (null == lUsername) { lCode = -1; lMessage = "User could not be authenticated!"; } else { lArgs.put("username", lUsername); } } catch (JMSEndpointException lEx) { lCode = -1; lMessage = lEx.getClass().getSimpleName() + " on auto authentication: " + lEx.getMessage(); } lJWSEndPoint.respondPayload(aToken, lCode, // return code lMessage, // return message lArgs, // additional result fields null); // payload } }); lJWSEndPoint.addRequestListener("tld.yourname.jms", "transferFile", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { // here you can get the additional arguments mLog.info("Received 'transferFile' with additional args" + " (arg1=" + aToken.getString("arg1") + " (arg2=" + aToken.getString("arg2") + ")..."); // here you get the payload from the requester String lPayload = aToken.getString("payload"); // parse the JSON payload into a Token (for simpler processing) Token lToken = JSONProcessor.JSONStringToToken(lPayload); // extract the base64 and compressed file contents into Strings // (it's a text message) // String lBase64Encoded = lToken.getString("fileAsBase64"); String lBase64Zipped = lToken.getString("fileAsZip"); // specify the target file File lFile = new File("Apache License 2.0 (copy).txt"); try { // take the zipped version of the file... byte[] lBA = Tools.unzip(lBase64Zipped.getBytes("UTF-8"), Boolean.TRUE); // and save it to the hard disk FileUtils.writeByteArrayToFile(lFile, lBA); } catch (Exception lEx) { mLog.error("Demo file " + lFile.getAbsolutePath() + " could not be saved!"); } } }); // add a high level listener to listen in coming messages lJWSEndPoint.addRequestListener("org.jwebsocket.jms.demo", "helloWorld", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.info("Received 'helloWorld'..."); lJWSEndPoint.respondPayload(aToken.getString("sourceId"), aToken, 0, // return code "Ok", // return message null, // here you can add additional results beside the payload "Hello World!"); } }); // start the endpoint all all listener have been assigned lJWSEndPoint.start(); return lJWSEndPoint; }
From source file:uk.ac.ebi.atlas.trader.ConfigurationTrader.java
private XMLConfiguration getXmlConfiguration(String pathTemplate, String experimentAccession, boolean splitOnComma) { Path path = Paths.get(MessageFormat.format(pathTemplate, experimentAccession)); File file = path.toFile();//from ww w. j a v a 2 s. co m if (!file.exists()) { throw new IllegalStateException("Configuration file " + path.toString() + " does not exist"); } try { XMLConfiguration xmlConfiguration = new XMLConfiguration(); if (!splitOnComma) { xmlConfiguration.setDelimiterParsingDisabled(true); } xmlConfiguration.load(path.toFile()); return xmlConfiguration; } catch (ConfigurationException cex) { LOGGER.error(cex.getMessage(), cex); throw new IllegalStateException("Cannot read configuration from path " + path.toString(), cex); } }
From source file:velo.common.SysConf.java
/** * Returns a Configuration object for managing system configuration properties * @return Configuration object/*from w w w . j av a 2 s .c om*/ */ public static Configuration getSysConf() { if (staticConfig == null) { try { System.out.println("(!)Factoring Global Configuration Object..."); //URL iniConf = SysConf.class.getClassLoader().getResource(veloINIConfFileName); //URL xmlConf = SysConf.class.getClassLoader().getResource(veloXMLConfFileName); //String xmlConfFile = System.getProperty("veloSysDir") + "/conf/" + veloXMLConfFileName; //String iniConfFile = System.getProperty("veloSysDir") + "/conf/" + veloINIConfFileName; /* if ( (iniConf == null) || (xmlConf == null) ) { System.err.println("Could not load configuration files, dying..."); return null; } */ //01-jul-07(Asaf), Removed root conf, it is just another file that is accessible by the user and is not neccessary //Only got two conf files, added them by code //factory = new ConfigurationFactory(sysconf.getFile()); //Configuration config = factory.getConfiguration(); CompositeConfiguration config = new CompositeConfiguration(); config.setDelimiterParsingDisabled(true); config.setListDelimiter("|".charAt(0)); config.setDelimiter("|".charAt(0)); //for tests //config.addConfiguration(new PropertiesConfiguration("c:/temp/velo/velo_sys/conf/velo_config.ini")); //config.addConfiguration(new XMLConfiguration("c:/temp/velo/velo_sys/conf/velo_config.xml")); String iniConfFile = getVeloINIConfFileName(); String xmlConfFile = getVeloXMLConfFileName(); String xmlConfExtFile = getVeloExtXMLConfFileName(); config.addConfiguration(new PropertiesConfiguration(iniConfFile)); XMLConfiguration xmlConf = new XMLConfiguration(xmlConfFile); XMLConfiguration xmlExtConf = new XMLConfiguration(xmlConfExtFile); xmlConf.setDelimiterParsingDisabled(true); xmlConf.setListDelimiter("|".charAt(0)); xmlConf.setDelimiter("|".charAt(0)); xmlExtConf.setDelimiterParsingDisabled(true); xmlExtConf.setListDelimiter("|".charAt(0)); xmlExtConf.setDelimiter("|".charAt(0)); config.addConfiguration(xmlConf); config.addConfiguration(xmlExtConf); //TODO: Fix this for JBOSS //config.addConfiguration(new PropertiesConfiguration(iniConf.getFile())); //config.addConfiguration(new XMLConfiguration(xmlConf.getFile())); return config; } catch (ConfigurationException ce) { System.out.println("Could not read ROOT configuration file due to: " + ce.getMessage()); return null; } } return staticConfig; }