List of usage examples for org.apache.commons.configuration2.builder.fluent Parameters xml
public XMLBuilderParameters xml()
From source file:com.netcore.hsmart.AppConstants.java
/** * This will load the code constants from application_status_codes.xml and * will push in redis key name: xml_node key value: xml node object *//*from www.j a v a 2 s . com*/ private static void loadStatusCodeConfig() { final Logger logger = LoggerFactory.getLogger(AppConstants.class); Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>( XMLConfiguration.class) .configure(params.xml().setBasePath(System.getProperty("hsmart-config-path")) .setFileName("application_status_codes.xml") .setExpressionEngine(new XPathExpressionEngine())); try { AppConstants.statusCodeConfig = builder.getConfiguration(); logger.info(AppConstants.getApplicationCodeMessage("HSMART_GEN_1007")); // AppConstants.GEN_STATUS_CODES = // AppConstants.statusCodeConfig.getList("general/data"); // for (Object codes : AppConstants.GEN_STATUS_CODES) { // System.out.println(codes); // } // AppConstants.APP_ERR_CODES = // AppConstants.statusCodeConfig.getList("general/internal_app_error_codes/data"); // AppConstants.DLR_STATUS_CODES = // AppConstants.statusCodeConfig.getList("general/dlr_status_codes/data"); } catch (ConfigurationException cex) { // loading of the configuration file failed } }
From source file:com.netcore.hsmart.AppConstants.java
@SuppressWarnings("deprecation") public static void loadAppConfig() throws ConfigurationException { Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>( XMLConfiguration.class) .configure(params.xml().setBasePath(System.getProperty("hsmart-config-path")) .setFileName("application.xml").setExpressionEngine(new XPathExpressionEngine())); AppConstants.config = builder.getConfiguration(); AppConstants.HTTP_PROTOCOL = AppConstants.config.getString("appservers/protocol"); AppConstants.SERVER_SMSRECV_HOST = AppConstants.config.getString("appservers/server[@type='SMSRECV']/host"); AppConstants.SERVER_SMSRECV_PORT = AppConstants.config.getString("appservers/server[@type='SMSRECV']/port"); AppConstants.SERVER_DLRRECV_HOST = AppConstants.config.getString("appservers/server[@type='DLRRECV']/host"); AppConstants.SERVER_DLRRECV_PORT = AppConstants.config.getString("appservers/server[@type='DLRRECV']/port"); AppConstants.WRITE_DB_JDBC_TYPE = AppConstants.config .getString("databases/database[@type='WRITE']/jdbc_type"); AppConstants.WRITE_DB_HOST = AppConstants.config.getString("databases/database[@type='WRITE']/host"); AppConstants.WRITE_DB_USERNAME = AppConstants.config .getString("databases/database[@type='WRITE']/username"); AppConstants.WRITE_DB_PASSWORD = AppConstants.config .getString("databases/database[@type='WRITE']/password"); AppConstants.WRITE_DB_PORT = AppConstants.config.getString("databases/database[@type='WRITE']/port"); AppConstants.WRITE_DB_NAME = AppConstants.config.getString("databases/database[@type='WRITE']/dbname"); AppConstants.WRITE_DB_DIALECT = AppConstants.config.getString("databases/database[@type='WRITE']/dialect"); AppConstants.WRITE_DB_DRIVER_CLASS = AppConstants.config .getString("databases/database[@type='WRITE']/driver_class"); AppConstants.WRITE_DB_POOL_MIN_SIZE = AppConstants.config .getString("databases/database[@type='WRITE']/c3p0_min_size"); AppConstants.WRITE_DB_POOL_MAX_SIZE = AppConstants.config .getString("databases/database[@type='WRITE']/c3p0_max_size"); AppConstants.WRITE_DB_AUTO_COMMIT = AppConstants.config .getString("databases/database[@type='WRITE']/autocommit"); AppConstants.WRITE_DB_TIMEOUT = AppConstants.config .getString("databases/database[@type='WRITE']/c3p0_timeout"); AppConstants.WRITE_DB_RELEASE_MODE = AppConstants.config .getString("databases/database[@type='WRITE']/release_mode"); AppConstants.WRITE_DB_IDLE_TESTS_PERIOD = AppConstants.config .getString("databases/database[@type='WRITE']/idle_test_periods"); AppConstants.WRITE_DB_SHOW_SQL = AppConstants.config .getString("databases/database[@type='WRITE']/show_sql"); AppConstants.WRITE_DB_CTX_CLASS = AppConstants.config .getString("databases/database[@type='WRITE']/current_session_context_class"); AppConstants.RABBITMQ_HOST = AppConstants.config.getString("rabbitmq/host"); AppConstants.RABBITMQ_USERNAME = AppConstants.config.getString("rabbitmq/username"); AppConstants.RABBITMQ_PASSWORD = AppConstants.config.getString("rabbitmq/password"); AppConstants.RABBITMQ_PORT = AppConstants.config.getString("rabbitmq/port"); AppConstants.RABBITMQ_SMSRECV_EX = AppConstants.config.getString("rabbitmq/exchanges/smsrecv_ex"); AppConstants.RABBITMQ_DLRRECV_EX = AppConstants.config.getString("rabbitmq/exchanges/dlrrecv_ex"); AppConstants.RABBITMQ_SMSDATA_EX = AppConstants.config.getString("rabbitmq/exchanges/smsdata_ex"); AppConstants.RABBITMQ_DLRDATA_EX = AppConstants.config.getString("rabbitmq/exchanges/dlrdata_ex"); AppConstants.RABBITMQ_DLRPULLSERVICE_EX = AppConstants.config .getString("rabbitmq/exchanges/dlrpullservice_ex"); AppConstants.RABBITMQ_SMSRECV_Q_PREFIX = AppConstants.config.getString("rabbitmq/queues/smsrecv_q_prefix"); AppConstants.RABBITMQ_DLRRECV_Q_PREFIX = AppConstants.config.getString("rabbitmq/queues/dlrrecv_q_prefix"); AppConstants.RABBITMQ_SMSDATA_Q_PREFIX = AppConstants.config.getString("rabbitmq/queues/smsdata_q_prefix"); AppConstants.RABBITMQ_DLRDATA_Q_PREFIX = AppConstants.config.getString("rabbitmq/queues/dlrdata_q_prefix"); AppConstants.RABBITMQ_DLRPULLSERVICE_Q_PREFIX = AppConstants.config .getString("rabbitmq/queues/dlrpullservice_q_prefix"); AppConstants.LOGGING_PATH = AppConstants.config.getString("logging/path"); AppConstants.LOOGING_ROOT_FILE = AppConstants.config.getString("logging/root_log"); AppConstants.LOGGING_SMSRECV_LOGFILE = AppConstants.config.getString("logging/smsrecv_logfile"); AppConstants.LOGGING_DLRRECV_LOGFILE = AppConstants.config.getString("logging/dlrrecv_logfile"); AppConstants.REDIS_HOST = AppConstants.config.getString("redis/host"); AppConstants.REDIS_PASSWORD = AppConstants.config.getString("redis/password"); AppConstants.REDIS_PORT = AppConstants.config.getString("redis/port"); AppConstants.DM_DLR_API = AppConstants.config.getString("dm/return_api"); AppConstants.DM_GATEWAYS = AppConstants.config.getList("dm/gateways/id"); AppConstants.PAYLOAD_GROUP_SEPARATOR = AppConstants.config .getString("misc/separators/payload/group_separator"); AppConstants.PAYLOAD_KV_SEPARATOR = AppConstants.config .getString("misc/separators/payload/key_val_separator"); AppConstants.HAZELCAST_MEMBERS = AppConstants.config.getList("hazelcast/members/member"); AppConstants.RABBITMQ_DM_DLR_CALL_EX = AppConstants.config.getString("rabbitmq/exchanges/dmdlrcall_ex"); AppConstants.RABBITMQ_DM_DLR_CALL_Q = AppConstants.config.getString("rabbitmq/queues/dmdlrcall_q"); AppConstants.setSystemProperties();//from ww w . ja v a 2 s .c o m final Logger logger = LoggerFactory.getLogger(AppConstants.class); ClientConfig clientConfig = new ClientConfig(); for (int i = 0; i < HAZELCAST_MEMBERS.size(); i++) { clientConfig.addAddress(HAZELCAST_MEMBERS.get(i).toString()); } hazelClient = HazelcastClient.newHazelcastClient(clientConfig); hazelcastRefIdCounter = hazelClient.getAtomicLong(AppConstants.hazelcastCounterString); AppConstants.loadStatusCodeConfig(); try { // initializeDBConnection(); // initializeRedisConnection(); initializeRabbitMqConnection(); logger.info(AppConstants.getApplicationCodeMessage("HSMART_GEN_1006")); } catch (Exception cex) { logger.error("HSMART application initialization error"); logger.error("Error:" + cex.getMessage()); } }
From source file:nl.imvertor.common.Configurator.java
/** * Return a XML configuration object for the file passed. * /*from www .j ava2 s .c o m*/ * Properties are accessible by xpath expressions. * * @param configfile * @return * @throws ConfigurationException */ private XMLConfiguration load(File configfile) throws ConfiguratorException, ConfigurationException { Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<XMLConfiguration>( XMLConfiguration.class); XMLBuilderParameters p = params.xml(); p.setFile(configfile); builder.configure(p); XMLConfiguration c = builder.getConfiguration(); c.setExpressionEngine(new XPathExpressionEngine()); return c; }
From source file:nl.minvenj.pef.stream.LiveCapture.java
/** * Main function to start the tool for pseudonymization of packets. * * @param args command line tool arguments */// w w w . jav a2 s. c o m public static void main(String[] args) { String xmlConfigFile; if (args.length == 1) { xmlConfigFile = args[0]; } else { xmlConfigFile = "configuration.xml"; } // Test if the file exists. File configFile = new File(xmlConfigFile); if (!configFile.exists()) { System.out.println("Create the file configuration.xml with the settings for pseudonymization. " + "You can copy the configuration.proto.xml file as template."); // Exit the application. return; } else { System.out.println("Using " + xmlConfigFile + " as configuration file."); } Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>( XMLConfiguration.class).configure(params.xml().setFileName(xmlConfigFile)); try { XMLConfiguration config = builder.getConfiguration(); // Check the configuration. String logFile = config.getString("log_file", "default_log.txt"); initLogger(logFile); if (checkConfiguration(config)) { runPEF(config); } } catch (ConfigurationException cex) { // Loading of the configuration file failed cex.printStackTrace(); } catch (IOException | SecurityException | IllegalArgumentException e) { // The logger could not be initialized. System.err.println("The logger could not be initialized " + e.getMessage()); } catch (PEFException e) { System.err.println(e.getMessage()); } }
From source file:org.craftercms.engine.util.ConfigUtils.java
public static XMLConfiguration readXmlConfiguration(Resource resource, char listDelimiter, Map<String, Lookup> prefixLookups) throws ConfigurationException { Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>( XMLConfiguration.class); try {/*from w w w.j a v a2 s . c o m*/ XMLBuilderParameters xmlParams = params.xml().setURL(resource.getURL()) .setListDelimiterHandler(new DefaultListDelimiterHandler(listDelimiter)); if (MapUtils.isNotEmpty(prefixLookups)) { xmlParams = xmlParams.setPrefixLookups(prefixLookups); } builder.configure(xmlParams); } catch (IOException e) { throw new ConfigurationException("Unable to get URL of resource " + resource, e); } return builder.getConfiguration(); }
From source file:org.objectspace.library.marcxmlimporter.MarcReader.java
/** * @param args/* ww w . jav a 2 s. c o m*/ * @throws SAXException * @throws ParserConfigurationException * @throws IOException * @throws ConfigurationException * @throws SQLException * @throws ClassNotFoundException * @throws IllegalAccessException * @throws InstantiationException */ public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, ConfigurationException, InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { String configfilename = "tagreader.xml"; if (args.length > 0) { configfilename = args[0]; } Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<XMLConfiguration>( XMLConfiguration.class).configure(params.xml().setFileName(configfilename)); XMLConfiguration config = builder.getConfiguration(); String xmlfile = config.getString("marcreader.file", null); // Create a "parser factory" for creating SAX parsers SAXParserFactory spfac = SAXParserFactory.newInstance(); // Now use the parser factory to create a SAXParser object SAXParser sp = spfac.newSAXParser(); // Create an instance of this class; it defines all the handler methods MarcReader handler = new MarcReader(config); // HIL3/2$0030422 639.1 Hes MARC 954 // Finally, tell the parser to parse the input and notify the handler sp.parse(xmlfile, handler); }
From source file:org.objectspace.rfid.library.inventory.Inventory.java
/** * main function/*ww w .ja v a2 s . c o m*/ * needs configuration * * inventory.window.logo (name of image file with logo) * * inventory.window.background (optional, name of image file with background) * * inventory.window.posx/inventory.window.posy (position of window) * * inventory.window.width/inventory.windows.height (size of window) * @param args args[0] is config file name * @throws Exception */ public static void main(String[] args) throws Exception { String configfilename = "tagreader.xml"; if (args.length > 0) { configfilename = args[0]; } Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<XMLConfiguration>( XMLConfiguration.class).configure(params.xml().setFileName(configfilename)); XMLConfiguration config = builder.getConfiguration(); ISO15693Reader reader = ISO15693ReaderFactory.createReader(config); reader.connect(); reader.init(); Display display = new Display(); Shell shell = new Shell(display); FillLayout layout = new FillLayout(); shell.setLayout(layout); Image logo = new Image(display, config.getString("inventory.window.logo")); String bgImgName = config.getString("inventory.window.background"); Image background = null; if (bgImgName != null) background = new Image(display, bgImgName); InventoryDialog md = new InventoryDialog(shell, SWT.NONE, logo, background); shell.setLocation(config.getInt("inventory.window.posx", 100), config.getInt("inventory.window.posy", 100)); shell.setSize(config.getInt("inventory.window.width", 1150), config.getInt("inventory.window.height", 700)); shell.open(); InventoryCallback callback = new InventoryCallback(md, config); InventoryThread inventoryThread = new InventoryThread(reader, callback, md, config); md.setThread(inventoryThread); Thread runner = new Thread(inventoryThread); runner.start(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } inventoryThread.dispose(); reader.close(); }
From source file:org.objectspace.rfid.library.taghandle.TagHandle.java
/** * @param args//from w w w . j ava2s.c o m * @throws Exception * @throws FedmException */ public static void main(String[] args) throws FedmException, Exception { String configfilename = "tagreader.xml"; if (args.length > 0) { configfilename = args[0]; } Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<XMLConfiguration>( XMLConfiguration.class).configure(params.xml().setFileName(configfilename)); XMLConfiguration config = builder.getConfiguration(); ISO15693Reader reader = ISO15693ReaderFactory.createReader(config); //FeigRFID feig = new FeigRFID(config); reader.connect(); reader.init(); Display display = new Display(); Shell shell = new Shell(display); FillLayout layout = new FillLayout(); shell.setLayout(layout); Image logo = new Image(display, config.getString("taghandle.window.logo")); String bgImgName = config.getString("taghandle.window.background"); Image background = null; if (bgImgName != null) background = new Image(display, bgImgName); MainDialog md = new MainDialog(shell, SWT.NONE, logo, background, config.getInt("taghandle.camera.edgetresholdmin", 100), config.getInt("taghandle.camera.edgetresholdmax", 200)); shell.setLocation(config.getInt("taghandle.window.posx", 100), config.getInt("taghandle.window.posy", 100)); shell.setSize(config.getInt("taghandle.window.width", 1150), config.getInt("taghandle.window.height", 650)); shell.open(); WebCamThread webCamThread = null; if (config.getBoolean("taghandle.camera.active")) { webCamThread = new WebCamThread(config, md); Thread runner = new Thread(webCamThread); runner.start(); } TagHandleThread tagReaderThread = new TagHandleThread(reader, config, md, webCamThread); Thread runner2 = new Thread(tagReaderThread); runner2.start(); // CanvasFrame cFrame = new CanvasFrame("Capture Preview"); // cFrame.setBounds(744, 179, 348, 227); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } tagReaderThread.dispose(); if (webCamThread != null) webCamThread.dispose(); if (!display.isDisposed()) display.dispose(); reader.close(); }