List of usage examples for org.apache.commons.configuration CompositeConfiguration CompositeConfiguration
public CompositeConfiguration(Collection configurations)
From source file:com.croer.javaorange.util.Configuration.java
public static CompositeConfiguration getCONFIGURATION() { if (CONFIGURATION == null) { List lc = new ArrayList(); try {//from w ww .ja v a 2s . c o m PropertiesConfiguration pc1 = new PropertiesConfiguration("prueba.properties"); // PropertiesConfiguration pc2 = new PropertiesConfiguration("mvc.properties"); lc.add(pc1); // lc.add(pc2); } catch (ConfigurationException ex) { Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex); } CONFIGURATION = new CompositeConfiguration(lc); } return CONFIGURATION; }
From source file:de.nrw.hbz.regal.sync.DigitoolDownloadConfiguration.java
/** * @param args//from ww w .java 2 s. c om * Command line arguments * @param options * Command line options * @param cl * Calling class * @author Jan Schnasse, schnasse@hbz-nrw.de * */ public DigitoolDownloadConfiguration(String[] args, Options options, Class<?> cl) { Collection<Configuration> confs = new ArrayList<Configuration>(); confs.add(new MyConfiguration(args, options)); confs.add(new MyPreferences(cl)); this.config = new CompositeConfiguration(confs); }
From source file:net.bican.wordpress.configuration.WpCliConfiguration.java
/** * @param args Command line arguments//from w ww . j a va2s. c o m * @param options Command line options * @param cl Calling class * @throws ParseException When the configuration cannot be parsed */ public WpCliConfiguration(String[] args, Options options, Class<?> cl) throws ParseException { Collection<Configuration> confs = new ArrayList<Configuration>(); confs.add(new CliConfiguration(args, options)); confs.add(new PreferencesConfiguration(cl)); this.config = new CompositeConfiguration(confs); }
From source file:com.dattack.dbtools.drules.engine.report.Report.java
static String interpolate(final String message, final String status, final String log) { final CompositeConfiguration configuration = new CompositeConfiguration( ThreadContext.getInstance().getConfiguration()); configuration.setProperty(PropertyNames.LOG, log); configuration.setProperty(PropertyNames.STATUS, status); return ConfigurationUtil.interpolate(message, configuration); }
From source file:com.github.anba.es6draft.util.Resources.java
/** * Loads the configuration file.// w ww . java 2 s . c om */ public static Configuration loadConfiguration(Class<?> clazz) { TestConfiguration config = clazz.getAnnotation(TestConfiguration.class); String file = config.file(); String name = config.name(); try { PropertiesConfiguration properties = new PropertiesConfiguration(); // entries are mandatory unless an explicit default value was given properties.setThrowExceptionOnMissing(true); properties.getInterpolator().setParentInterpolator(MISSING_VAR); properties.load(resource(file), "UTF-8"); Configuration configuration = new CompositeConfiguration( Arrays.asList(new SystemConfiguration(), properties)); return configuration.subset(name); } catch (ConfigurationException | IOException e) { throw new RuntimeException(e); } catch (NoSuchElementException e) { throw e; } }
From source file:at.gv.egiz.bku.spring.ConfigurationFactoryBean.java
@Override public Object getObject() throws Exception { log.info("Configuration resource is {}.", configurationResource); CompositeConfiguration configuration = null; if (configurationResource != null) { if (configurationResource.exists()) { // initialize with writable configuration URL url = configurationResource.getURL(); XMLConfiguration writableConfiguration = new XMLConfiguration(url); configuration = new CompositeConfiguration(writableConfiguration); log.info("Initialized with configuration from '{}'.", url); } else if (failOnMissingResource) { StringBuilder message = new StringBuilder(); message.append("ConfigurationResource '"); message.append(configurationResource.getDescription()); message.append("' does not exist!"); log.error(message.toString()); throw new MoccaConfigurationException(message.toString()); }/*w w w . ja v a 2 s . c o m*/ } if (configuration == null) { // initialize default configuration log.warn("Initializing with default configuration."); configuration = new CompositeConfiguration(); } configuration.addConfiguration(getDefaultConfiguration()); configuration.addConfiguration(getVersionConfiguration()); return configuration; }
From source file:org.alfresco.extensions.titan.TitanDBSessionImpl.java
@PostConstruct public void buildTitanSession() throws Exception { URL url = getClass().getClassLoader().getResource(titanConfigurationFile).toURI().toURL(); List<Configuration> configs = new LinkedList<>(); configs.add(new SystemPropsConfiguration()); configs.add(new PropertiesConfiguration(url)); this.conf = new CompositeConfiguration(configs); if (clear) {/*from w w w . j a v a2 s .c om*/ clear(); } this.graph = TitanFactory.open(conf); // gremlin(); }
From source file:org.apache.juddi.v3.client.config.ClientConfig.java
/** * Attempts to save any changes made to the configuration back to disk * @throws ConfigurationException /* w ww .j av a 2s .c o m*/ */ public void saveConfig() throws ConfigurationException { XMLConfiguration saveConfiguration = new XMLConfiguration(configurationFile); Configuration cc = new CompositeConfiguration(saveConfiguration); Iterator<String> keys = this.config.getKeys(); while (keys.hasNext()) { String key = keys.next(); if (key.startsWith("client") || key.startsWith("config")) { cc.setProperty(key, config.getProperty(key)); } } saveConfiguration.save(); }
From source file:org.apache.marmotta.platform.core.services.modules.ModuleServiceImpl.java
@PostConstruct public void initialize() { //default_container_name = configurationService.getStringConfiguration("kiwi.pages.default_container.name",default_container_name); //default_container_number = configurationService.getIntConfiguration("kiwi.pages.default_container.number",default_container_number); modules = new HashSet<String>(); containers = new HashMap<String, ArrayList<String>>(); container_weight = new HashMap<String, Integer>(); configurationMap = new HashMap<String, Configuration>(); jarURLs = new HashMap<String, Configuration>(); try {/*from w w w .ja va 2 s. c o m*/ Enumeration<URL> modulePropertiesEnum = this.getClass().getClassLoader() .getResources("kiwi-module.properties"); while (modulePropertiesEnum.hasMoreElements()) { URL moduleUrl = modulePropertiesEnum.nextElement(); Configuration moduleProperties = null; try { Set<Configuration> configurations = new HashSet<Configuration>(); // get basic module configuration moduleProperties = new PropertiesConfiguration(moduleUrl); configurations.add(moduleProperties); String moduleName = moduleProperties.getString("name"); modules.add(moduleName); String c_name = moduleProperties.getString("container") != null ? moduleProperties.getString("container") : default_container_name; if (containers.get(c_name) == null) { containers.put(c_name, new ArrayList<String>()); } containers.get(c_name).add(moduleName); if (container_weight.get(c_name) == null) { container_weight.put(c_name, -1); } if (moduleProperties.getString("container.weight") != null) { container_weight.put(c_name, Math.max(container_weight.get(c_name), moduleProperties.getInt("container.weight", -1))); } URLConnection urlConnection = moduleUrl.openConnection(); URL jarUrl; if (urlConnection instanceof JarURLConnection) { JarURLConnection conn = (JarURLConnection) urlConnection; jarUrl = conn.getJarFileURL(); } else { String fileUrl = moduleUrl.toString(); jarUrl = new URL(fileUrl.substring(0, fileUrl.lastIndexOf("/"))); } // get the build information try { PropertiesConfiguration buildInfo = new PropertiesConfiguration( new URL("jar:" + jarUrl.toString() + "!/buildinfo.properties")); buildInfo.setDelimiterParsingDisabled(true); configurations.add(buildInfo); } catch (ConfigurationException ex) { } // alternative: maven buildinfo plugin try { PropertiesConfiguration buildInfo = new PropertiesConfiguration( new URL("jar:" + jarUrl.toString() + "!/build.info")); buildInfo.setDelimiterParsingDisabled(true); configurations.add(buildInfo); } catch (ConfigurationException ex) { } // create runtime configuration MapConfiguration runtimeConfiguration = new MapConfiguration(new HashMap<String, Object>()); runtimeConfiguration.setProperty("runtime.jarfile", jarUrl.toString()); configurations.add(runtimeConfiguration); CompositeConfiguration moduleConfiguration = new CompositeConfiguration(configurations); configurationMap.put(moduleName, moduleConfiguration); jarURLs.put(jarUrl.toString(), moduleConfiguration); } catch (ConfigurationException e) { log.error("error parsing kiwi-module.properties file at {}", moduleUrl, e); } } //TODO container should be sortable } catch (IOException ex) { log.error("I/O error while trying to retrieve kiwi-module.properties file", ex); } }
From source file:org.apache.marmotta.platform.core.test.base.JettyMarmotta.java
public JettyMarmotta(Configuration override, String context, int port, Set<Class<?>> webservices) { super();//from www. j av a2s.c o m this.port = port; this.context = (context != null ? context : "/"); List<Configuration> configurations = new ArrayList<>(); if (override != null) { configurations.add(override); } configurations.add(this.override); // create a new jetty & run it on port 8080 jetty = new Server(this.port); TestInjectorFactory.setManager(container.getBeanManager()); ServletContextHandler ctx = new ServletContextHandler(jetty, this.context); // now we have a context, start up the first phase of the LMF initialisation startupService.startupConfiguration(home.getAbsolutePath(), new CompositeConfiguration(configurations), ctx.getServletContext()); // register the RestEasy CDI injector factory ctx.setAttribute("resteasy.injector.factory", TestInjectorFactory.class.getCanonicalName()); // register filters FilterHolder resourceFilter = new FilterHolder(CDIContext.getInstance(MarmottaResourceFilter.class)); resourceFilter.setInitParameter("kiwi.resourceCaching", "true"); ctx.addFilter(resourceFilter, "/*", EnumSet.of(DispatcherType.REQUEST)); // register RestEasy so we can run web services // if a single web service is given, only register that webservice, otherwise startup the default configuration //FilterHolder restEasyFilter = new FilterHolder(org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.class); ServletHolder restEasyFilter = new ServletHolder( org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class); restEasyFilter.setInitParameter("resteasy.injector.factory", TestInjectorFactory.class.getCanonicalName()); if (webservices != null) { TestApplication.setTestedWebServices(webservices); //restEasyFilter.setInitParameter("resteasy.resources", webservice.getName()); restEasyFilter.setInitParameter("javax.ws.rs.Application", TestApplication.class.getCanonicalName()); } else { restEasyFilter.setInitParameter("javax.ws.rs.Application", CoreApplication.class.getCanonicalName()); } //ctx.addFilter(restEasyFilter,"/*", Handler.ALL); ctx.addServlet(restEasyFilter, "/*"); try { jetty.start(); String url = "http://localhost:" + this.port + this.context + "/"; startupService.startupHost(url, url); } catch (Exception e) { log.error("could not start up embedded jetty server", e); } // make sure exception mappers are loaded and registered ExceptionMapperServiceImpl mapperService = CDIContext.getInstance(ExceptionMapperServiceImpl.class); try { mapperService.register( ((HttpServletDispatcher) restEasyFilter.getServlet()).getDispatcher().getProviderFactory()); } catch (ServletException e) { log.warn("could not register exception mappers"); } // make sure interceptors are loaded and registered InterceptorServiceImpl interceptorService = CDIContext.getInstance(InterceptorServiceImpl.class); try { interceptorService.register( ((HttpServletDispatcher) restEasyFilter.getServlet()).getDispatcher().getProviderFactory()); } catch (ServletException e) { log.warn("could not register interceptors"); } }