List of usage examples for org.apache.commons.configuration ConfigurationConverter getConfiguration
public static Configuration getConfiguration(Properties props)
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"); }/* w w w .jav a 2 s .com*/ 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:ws.argo.responder.plugin.configfile.ConfigFileMonitorTask.java
/** * Creates a monitor task with the plugin instance as a parameter. The monitor * needs access to the plugin in order to get its config and set the service * list/*w ww .j a va 2 s . c o m*/ * * @param configFileProbeHandlerPluginImpl the instance of the handler * @throws ConfigurationException if something goes wrong * */ public ConfigFileMonitorTask(ConfigFileProbeHandlerPlugin configFileProbeHandlerPluginImpl) throws ConfigurationException { _plugin = configFileProbeHandlerPluginImpl; Properties properties = _plugin.getConfiguration(); Configuration config = ConfigurationConverter.getConfiguration(properties); String xmlConfigFilename = config.getString("xmlConfigFilename"); _xmlConfigFile = new File(xmlConfigFilename); }
From source file:ws.argo.responder.plugin.configfile.ConfigFileMonitorTask.java
/** * actually load the xml configuration file. If anything goes wrong throws an * exception. This created a list of service records. When done, set the * service record list in the plugin. The plugin set function should be * synchronized so that it won't squash any concurrent access to the old set * of services./*from ww w. j a v a 2 s . c om*/ * * @throws JAXBException if there is some issue with the XML * @throws FileNotFoundException if the file name does not exist * @throws ConfigurationException if something went wrong */ private void loadServiceConfigFile() throws ConfigurationException { Properties properties = _plugin.getConfiguration(); Configuration config = ConfigurationConverter.getConfiguration(properties); String xmlConfigFilename = config.getString("xmlConfigFilename"); _config = new ServiceListConfiguration(xmlConfigFilename); // ServicesConfiguration services = parseConfigFile(xmlConfigFilename); // ArrayList<ServiceWrapper> serviceList = constructServiceList(services); ArrayList<ServiceWrapper> serviceList = _config.getServiceList(); LOGGER.debug("Setting the service list in the plugin"); _plugin.setServiceList(serviceList); }