List of usage examples for org.apache.commons.configuration Configuration subset
Configuration subset(String prefix);
From source file:org.wso2.andes.server.configuration.ServerConfiguration.java
@SuppressWarnings("unchecked") protected void setupVirtualHosts(Configuration conf) throws ConfigurationException { List<String> vhostFiles = conf.getList("virtualhosts"); Configuration vhostConfig = conf.subset("virtualhosts"); // Only one configuration mechanism allowed if (!vhostFiles.isEmpty() && !vhostConfig.subset("virtualhost").isEmpty()) { throw new ConfigurationException( "Only one of external or embedded virtualhosts configuration allowed."); }// ww w.j a v a2s .com // We can only have one vhosts XML file included if (vhostFiles.size() > 1) { throw new ConfigurationException( "Only one external virtualhosts configuration file allowed, multiple filenames found."); } // Virtualhost configuration object Configuration vhostConfiguration = new HierarchicalConfiguration(); // Load from embedded configuration if possible if (!vhostConfig.subset("virtualhost").isEmpty()) { vhostConfiguration = vhostConfig; } else { // Load from the external configuration if possible for (String fileName : vhostFiles) { // Open the vhosts XML file and copy values from it to our config _vhostsFile = new File(fileName); if (!_vhostsFile.exists()) { throw new ConfigurationException("Virtualhosts file does not exist"); } vhostConfiguration = parseConfig(new File(fileName)); // save the default virtualhost name String defaultVirtualHost = vhostConfiguration.getString("default"); _configuration.setProperty("virtualhosts.default", defaultVirtualHost); } } // Now extract the virtual host names from the configuration object List hosts = vhostConfiguration.getList("virtualhost.name"); for (int j = 0; j < hosts.size(); j++) { String name = (String) hosts.get(j); // Add the virtual hosts to the server configuration VirtualHostConfiguration virtualhost = new VirtualHostConfiguration(name, vhostConfiguration.subset("virtualhost." + name)); _virtualHosts.put(virtualhost.getName(), virtualhost); } }
From source file:org.wso2.andes.server.configuration.ServerConfiguration.java
public void reparseConfigFileSecuritySections() throws ConfigurationException { if (_configFile != null) { Configuration newConfig = parseConfig(_configFile); setConfiguration("", newConfig); ApplicationRegistry.getInstance().getSecurityManager().configureHostPlugins(this); // Reload virtualhosts from correct location Configuration newVhosts;/*from ww w . ja va2 s .c o m*/ if (_vhostsFile == null) { newVhosts = newConfig.subset("virtualhosts"); } else { newVhosts = parseConfig(_vhostsFile); } VirtualHostRegistry vhostRegistry = ApplicationRegistry.getInstance().getVirtualHostRegistry(); for (String hostName : _virtualHosts.keySet()) { VirtualHost vhost = vhostRegistry.getVirtualHost(hostName); Configuration vhostConfig = newVhosts.subset("virtualhost." + hostName); vhost.getConfiguration().setConfiguration("virtualhosts.virtualhost", vhostConfig); // XXX vhost.getSecurityManager().configureGlobalPlugins(this); vhost.getSecurityManager().configureHostPlugins(vhost.getConfiguration()); } _logger.warn(SECURITY_CONFIG_RELOADED); } }
From source file:org.wso2.andes.server.store.SlowMessageStore.java
public void configureConfigStore(String name, ConfigurationRecoveryHandler recoveryHandler, Configuration config, LogSubject logSubject) throws Exception { //To change body of implemented methods use File | Settings | File Templates. _logger.info("Starting SlowMessageStore on Virtualhost:" + name); Configuration delays = config.subset(DELAYS); configureDelays(delays);//from w w w. j a v a 2 s . c om String messageStoreClass = config.getString("realStore"); if (delays.containsKey(DEFAULT_DELAY)) { _defaultDelay = delays.getLong(DEFAULT_DELAY); } if (messageStoreClass != null) { Class clazz = Class.forName(messageStoreClass); Object o = clazz.newInstance(); if (!(o instanceof MessageStore)) { throw new ClassCastException("Message store class must implement " + MessageStore.class + ". Class " + clazz + " does not."); } _realStore = (MessageStore) o; _realStore.configureConfigStore(name, recoveryHandler, config, logSubject); } else { _realStore.configureConfigStore(name, recoveryHandler, config, logSubject); } }
From source file:pl.psnc.synat.wrdz.ms.config.MsConfiguration.java
/** * Reads the configuration form the {@value #CONFIG_FILE} file. *//* w ww .j a v a2s .c o m*/ @PostConstruct protected void init() { try { Configuration config = new XMLConfiguration(CONFIG_FILE); statisticsCalculationSchedule = readSchedule(config.subset(STATISTICS_CALCULATION_SCHEDULE)); } catch (ConfigurationException e) { throw new WrdzConfigurationError("Error while loading the MS configuration.", e); } catch (IllegalArgumentException e) { throw new WrdzConfigurationError("Error while loading the MS configuration.", e); } catch (NullPointerException e) { throw new WrdzConfigurationError("Error while loading the MS configuration.", e); } }
From source file:uk.ac.ebi.fg.jobs.JobController.java
private Configuration loadProperties(Configuration properties) { if (properties.getString("persistence-location") == null) throw new RuntimeException("ae.similarity.persistence-location doesn't exist"); if (properties != null && !properties.isEmpty()) { properties = properties.subset("properties"); return properties; } else {//from ww w . ja v a 2 s . co m for (int i = 0; i < defaultProperties.length; i++) { properties.addProperty(defaultProperties[i][0], defaultProperties[i][1]); } logger.error("Default properties loaded."); return properties; } }
From source file:uk.org.openeyes.oink.facade.FacadeRoutingServiceFactory.java
public FacadeRoutingService createInstance() { HttpMapper<RabbitRoute> mappings; String defaultReplyRoutingKey; log.debug("Using props: " + adapterProperties.toString()); Configuration config = ConfigurationConverter.getConfiguration(adapterProperties); String defaultExchange = config.getString(MAPPING_DEFAULT_EXCHANGE_KEY); defaultReplyRoutingKey = config.getString(MAPPING_DEFAULT_REPLY_ROUTING_KEY); Configuration facadeConfig = config.subset(MAPPING_KEY); int numOfMappings = getNumberOfMappingsGiven(facadeConfig); List<HttpMapperEntry<RabbitRoute>> entries = new LinkedList<HttpMapperEntry<RabbitRoute>>(); for (int i = 1; i <= numOfMappings; i++) { Configuration mappingCfg = getMappingsDetailsForIndex(i, facadeConfig); String service = mappingCfg.getString("service"); if (service != null && !service.equals("*") && isReservedResourceWord(service)) { throw new InvalidParameterException("A service name cannot be a Resource name"); }/*from ww w.jav a 2 s . c o m*/ String resource = mappingCfg.getString("resource"); if (resource != null && !resource.equals("*") && !isReservedResourceWord(resource)) { throw new InvalidParameterException( "A resource must be a recognised Resource name e.g. Patient (case-sensitive)"); } String method = mappingCfg.getString("method"); HttpMethod methodEnum; if (method != null && !method.equals("*") && !isValidHttpMethod(method)) { throw new InvalidParameterException( "A resource must be a recognised method verb e.g. POST,GET,PUT (case-sensitive)"); } else if (method == null || method.equals("*")) { methodEnum = HttpMethod.ANY; } else { methodEnum = HttpMethod.valueOf(method); } String routingKey = mappingCfg.getString("routingKey"); if (routingKey == null || routingKey.isEmpty()) { throw new InvalidParameterException("A routingKey must be given for every mapping entry"); } StringBuilder uri = new StringBuilder(); if (!(service == null || service.isEmpty())) { uri.append(service); uri.append("/"); } if (!(resource == null || resource.isEmpty())) { uri.append(resource); } uri.append("*"); RabbitRoute route = new RabbitRoute(routingKey, defaultExchange); HttpMapperEntry<RabbitRoute> entry = new HttpMapperEntry<RabbitRoute>(uri.toString(), methodEnum, route); entries.add(entry); } mappings = new HttpMapper<RabbitRoute>(entries); return new FacadeRoutingService(mappings, defaultReplyRoutingKey); }
From source file:uk.org.openeyes.oink.facade.FacadeRoutingServiceFactory.java
private Configuration getMappingsDetailsForIndex(int i, Configuration facadeConfig) { return facadeConfig.subset(Integer.toString(i)); }