List of usage examples for org.apache.commons.configuration2.builder FileBasedConfigurationBuilder FileBasedConfigurationBuilder
public FileBasedConfigurationBuilder(final Class<? extends T> resCls)
From source file:org.jbb.system.impl.install.auto.AutoInstallationFileManager.java
private InstallationData buildInstallationData(File autoInstallFile) { Parameters params = new Parameters(); FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>( PropertiesConfiguration.class).configure(params.fileBased().setFile(autoInstallFile)); try {//from w w w. j av a2 s . c o m FileBasedConfiguration configuration = builder.getConfiguration(); InstallationData installationData = InstallationData.builder().build(); autoInstallationDataReaders .forEach(reader -> reader.updateInstallationData(installationData, configuration)); return installationData; } catch (ConfigurationException e) { throw new IllegalStateException(e); } }
From source file:org.jbb.system.impl.install.InstallationFileManager.java
public void createInstallationFile(InstallationData installationData) { Parameters params = new Parameters(); File installFile = getInstallFile(); try {// ww w . jav a2s. c o m FileUtils.touch(installFile); } catch (IOException e) { throw new IllegalStateException(e); } FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>( PropertiesConfiguration.class).configure(params.fileBased().setFile(installFile)); builder.setAutoSave(true); try { FileBasedConfiguration configuration = builder.getConfiguration(); configuration.addProperty("installationId", UUID.randomUUID().toString()); configuration.addProperty("installationVersion", jbbMetaData.jbbVersion()); configuration.addProperty("installationDate", LocalDateTime.now().toString()); configuration.addProperty("boardFounderUsername", installationData.getAdminUsername()); builder.save(); } catch (ConfigurationException e) { throw new IllegalStateException(e); } }
From source file:org.mitre.mpf.nms.util.PropertiesUtil.java
@PostConstruct private void init() { URL url;/*from w w w.j a v a 2 s .com*/ try { url = propFile.getURL(); } catch (IOException e) { throw new IllegalStateException("Cannot get URL from " + propFile + ".", e); } FileBasedConfigurationBuilder<PropertiesConfiguration> fileBasedConfigBuilder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class); Parameters configBuilderParameters = new Parameters(); fileBasedConfigBuilder.configure(configBuilderParameters.fileBased().setURL(url) .setListDelimiterHandler(new DefaultListDelimiterHandler(','))); try { propertiesConfig = fileBasedConfigBuilder.getConfiguration(); } catch (ConfigurationException e) { throw new IllegalStateException("Cannot create configuration from " + propFile + ".", e); } }
From source file:org.mitre.mpf.wfm.util.MpfPropertiesConfigurationBuilder.java
private FileBasedConfigurationBuilder<PropertiesConfiguration> createFileBasedConfigurationBuilder( Resource resource) {//from w w w . j a va 2 s . c o m URL url; try { url = resource.getURL(); } catch (IOException e) { throw new IllegalStateException("Cannot get URL from " + resource + ".", e); } FileBasedConfigurationBuilder<PropertiesConfiguration> fileBasedConfigBuilder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class); Parameters configBuilderParameters = new Parameters(); fileBasedConfigBuilder.configure(configBuilderParameters.fileBased().setURL(url) .setListDelimiterHandler(new DefaultListDelimiterHandler(','))); return fileBasedConfigBuilder; }
From source file:org.objectspace.library.marcxmlimporter.MarcReader.java
/** * @param args//from w w w. java2 s . com * @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//w w w . jav a 2 s.co 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/* w w w.j a va 2 s.co 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(); }
From source file:org.powertac.common.config.Configurator.java
public final static XMLConfiguration readXML(String path) throws ConfigurationException { return new FileBasedConfigurationBuilder<>(XMLConfiguration.class) .configure(new Parameters().xml().setBasePath(".").setFileName(path) .setLocationStrategy(fileLocationStrategy).setListDelimiterHandler(listDelimiterHandler)) .getConfiguration();//w w w . j a v a2 s . c o m }
From source file:org.powertac.common.config.Configurator.java
public final static XMLConfiguration readXML(File file) throws ConfigurationException { return new FileBasedConfigurationBuilder<>(XMLConfiguration.class) .configure(new Parameters().xml().setFile(file).setLocationStrategy(fileLocationStrategy) .setListDelimiterHandler(listDelimiterHandler)) .getConfiguration();/*ww w.j a va2s .co m*/ }
From source file:org.powertac.common.config.Configurator.java
public final static XMLConfiguration readXML(URL url) throws ConfigurationException { return new FileBasedConfigurationBuilder<>(XMLConfiguration.class) .configure(new Parameters().xml().setURL(url).setListDelimiterHandler(listDelimiterHandler)) .getConfiguration();//from w w w. j a v a 2 s . c o m }