List of usage examples for org.apache.commons.configuration HierarchicalConfiguration configurationsAt
public List configurationsAt(String key)
From source file:com.vaushell.superpipes.nodes.A_Node.java
/** * Load configuration for this node.//ww w .j a v a2 s . c o m * * @param cNode Configuration * @throws Exception */ public void load(final HierarchicalConfiguration cNode) throws Exception { getProperties().readProperties(cNode); antiBurst = getProperties().getConfigDuration("anti-burst", antiBurst); delay = getProperties().getConfigDuration("delay", delay); // Load transforms IN transformsIN.clear(); final List<HierarchicalConfiguration> cTransformsIN = cNode.configurationsAt("in.transform"); if (cTransformsIN != null) { for (final HierarchicalConfiguration cTransform : cTransformsIN) { final List<ConfigProperties> commons = new ArrayList<>(); final String commonsID = cTransform.getString("[@commons]"); if (commonsID != null) { for (final String commonID : commonsID.split(",")) { final ConfigProperties common = getDispatcher().getCommon(commonID); if (common != null) { commons.add(common); } } } final A_Transform transform = addTransformIN(cTransform.getString("[@type]"), commons); transform.load(cTransform); } } // Load transforms OUT transformsOUT.clear(); final List<HierarchicalConfiguration> cTransformsOUT = cNode.configurationsAt("out.transform"); if (cTransformsOUT != null) { for (final HierarchicalConfiguration cTransform : cTransformsOUT) { final List<ConfigProperties> commons = new ArrayList<>(); final String commonsID = cTransform.getString("[@commons]"); if (commonsID != null) { for (final String commonID : commonsID.split(",")) { final ConfigProperties common = getDispatcher().getCommon(commonID); if (common != null) { commons.add(common); } } } final A_Transform transform = addTransformOUT(cTransform.getString("[@type]"), commons); transform.load(cTransform); } } }
From source file:ch.admin.suis.msghandler.config.ClientConfigurationFactory.java
private void setupNativeApps(SenderConfiguration defaultSenderConfiguration, String baseDir, ReceiverConfiguration receiverConfiguration) throws ConfigurationException { // ************** the native applications LOG.info("Configure the native MH applications..."); final List natives = xmlConfig.configurationsAt("nativeApp"); // We could use a foreach, but that would involve using objects. I don't like that. for (Iterator i = natives.iterator(); i.hasNext();) { HierarchicalConfiguration sub = (HierarchicalConfiguration) i.next(); // the sedex ID of this application final String sedexId = sub.getString(".[@participantId]"); // ************** outboxes final List outboxes = sub.configurationsAt(".outbox"); // We could use a foreach, but that would involve using objects. I don't like that. for (Iterator j = outboxes.iterator(); j.hasNext();) { setupNativeOutbox(j, baseDir, sedexId, defaultSenderConfiguration); }//from w w w.j a v a 2s .c om // inboxes for (final HierarchicalConfiguration inboxSub : sub.configurationsAt(".inbox")) { String inboxDir = inboxSub.getString("[@dirPath]"); File tmpDir = FileUtils.createPath(baseDir, inboxDir); List<HierarchicalConfiguration> decryptorConfigs = inboxSub.configurationsAt(".decrypt"); final Inbox inbox = decryptorConfigs.isEmpty() ? new NativeAppInbox(tmpDir, sedexId, MessageType.from(inboxSub.getString(MSG_TYPES))) : new DecryptingInbox(tmpDir, sedexId, MessageType.from(inboxSub.getString(MSG_TYPES))); checkSedexIdMsgTypes(inbox); receiverConfiguration.addInbox(inbox); if (!decryptorConfigs.isEmpty()) { clientConfiguration.setDecryptor(new Decryptor(setUpDecryptorConfiguration(decryptorConfigs))); } } } }
From source file:net.datenwerke.sandbox.util.SandboxParser.java
protected void configureClasses(SandboxContext set, HierarchicalConfiguration rs) throws MalformedURLException { for (Object e : rs.getList("classes.whitelist.entry")) set.addClassPermission(AccessType.PERMIT, (String) e); for (Object e : rs.getList("classes.whitelist.jar")) { set.addJarToWhitelist(new URL((String) e)); }//from w w w . j av a 2 s . com for (Object e : rs.getList("classes.blacklist.entry")) set.addClassPermission(AccessType.DENY, (String) e); for (HierarchicalConfiguration compl : rs.configurationsAt("classes.whitelist.complex")) { String cName = compl.getString("[@name]"); Collection<StackEntry> entries = new HashSet<StackEntry>(); for (HierarchicalConfiguration stack : compl.configurationsAt("check")) entries.add(getStackEntry(stack)); ClassPermission wclazz = new ClassPermission(cName, entries); set.addClassPermission(wclazz); } }
From source file:com.graphhopper.jsprit.core.problem.io.VrpXMLReader.java
private void readSolutions(XMLConfiguration vrpProblem) { if (solutions == null) return;/*from w w w.j a v a 2s. com*/ List<HierarchicalConfiguration> solutionConfigs = vrpProblem.configurationsAt("solutions.solution"); for (HierarchicalConfiguration solutionConfig : solutionConfigs) { String totalCost = solutionConfig.getString("cost"); double cost = -1; if (totalCost != null) cost = Double.parseDouble(totalCost); List<HierarchicalConfiguration> routeConfigs = solutionConfig.configurationsAt("routes.route"); List<VehicleRoute> routes = new ArrayList<VehicleRoute>(); for (HierarchicalConfiguration routeConfig : routeConfigs) { //! here, driverId is set to noDriver, no matter whats in driverId. Driver driver = DriverImpl.noDriver(); String vehicleId = routeConfig.getString("vehicleId"); Vehicle vehicle = getVehicle(vehicleId); if (vehicle == null) throw new IllegalStateException("vehicle is missing."); String start = routeConfig.getString("start"); if (start == null) throw new IllegalStateException("route start-time is missing."); double departureTime = Double.parseDouble(start); String end = routeConfig.getString("end"); if (end == null) throw new IllegalStateException("route end-time is missing."); VehicleRoute.Builder routeBuilder = VehicleRoute.Builder.newInstance(vehicle, driver); routeBuilder.setDepartureTime(departureTime); List<HierarchicalConfiguration> actConfigs = routeConfig.configurationsAt("act"); for (HierarchicalConfiguration actConfig : actConfigs) { String type = actConfig.getString("[@type]"); if (type == null) throw new IllegalStateException("act[@type] is missing."); double arrTime = 0.; double endTime = 0.; String arrTimeS = actConfig.getString("arrTime"); if (arrTimeS != null) arrTime = Double.parseDouble(arrTimeS); String endTimeS = actConfig.getString("endTime"); if (endTimeS != null) endTime = Double.parseDouble(endTimeS); String serviceId = actConfig.getString("serviceId"); if (serviceId != null) { Service service = getService(serviceId); routeBuilder.addService(service); } else { String shipmentId = actConfig.getString("shipmentId"); if (shipmentId == null) throw new IllegalStateException("either serviceId or shipmentId is missing"); Shipment shipment = getShipment(shipmentId); if (shipment == null) throw new IllegalStateException("shipment with id " + shipmentId + " does not exist."); if (type.equals("pickupShipment")) { routeBuilder.addPickup(shipment); } else if (type.equals("deliverShipment")) { routeBuilder.addDelivery(shipment); } else throw new IllegalStateException("type " + type + " is not supported. Use 'pickupShipment' or 'deliverShipment' here"); } } routes.add(routeBuilder.build()); } VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost); List<HierarchicalConfiguration> unassignedJobConfigs = solutionConfig .configurationsAt("unassignedJobs.job"); for (HierarchicalConfiguration unassignedJobConfig : unassignedJobConfigs) { String jobId = unassignedJobConfig.getString("[@id]"); Job job = getShipment(jobId); if (job == null) job = getService(jobId); if (job == null) throw new IllegalStateException("cannot find unassignedJob with id " + jobId); solution.getUnassignedJobs().add(job); } solutions.add(solution); } }
From source file:jsprit.core.problem.io.VrpXMLReader.java
private void readSolutions(XMLConfiguration vrpProblem) { if (solutions == null) return;//www .ja va 2 s . co m List<HierarchicalConfiguration> solutionConfigs = vrpProblem.configurationsAt("solutions.solution"); for (HierarchicalConfiguration solutionConfig : solutionConfigs) { String totalCost = solutionConfig.getString("cost"); double cost = -1; if (totalCost != null) cost = Double.parseDouble(totalCost); List<HierarchicalConfiguration> routeConfigs = solutionConfig.configurationsAt("routes.route"); List<VehicleRoute> routes = new ArrayList<VehicleRoute>(); for (HierarchicalConfiguration routeConfig : routeConfigs) { //! here, driverId is set to noDriver, no matter whats in driverId. Driver driver = DriverImpl.noDriver(); String vehicleId = routeConfig.getString("vehicleId"); Vehicle vehicle = getVehicle(vehicleId); if (vehicle == null) throw new IllegalStateException("vehicle is missing."); String start = routeConfig.getString("start"); if (start == null) throw new IllegalStateException("route start-time is missing."); double departureTime = Double.parseDouble(start); String end = routeConfig.getString("end"); if (end == null) throw new IllegalStateException("route end-time is missing."); VehicleRoute.Builder routeBuilder = VehicleRoute.Builder.newInstance(vehicle, driver); routeBuilder.setDepartureTime(departureTime); routeBuilder.setRouteEndArrivalTime(Double.parseDouble(end)); List<HierarchicalConfiguration> actConfigs = routeConfig.configurationsAt("act"); for (HierarchicalConfiguration actConfig : actConfigs) { String type = actConfig.getString("[@type]"); if (type == null) throw new IllegalStateException("act[@type] is missing."); double arrTime = 0.; double endTime = 0.; String arrTimeS = actConfig.getString("arrTime"); if (arrTimeS != null) arrTime = Double.parseDouble(arrTimeS); String endTimeS = actConfig.getString("endTime"); if (endTimeS != null) endTime = Double.parseDouble(endTimeS); String serviceId = actConfig.getString("serviceId"); if (serviceId != null) { Service service = getService(serviceId); routeBuilder.addService(service); } else { String shipmentId = actConfig.getString("shipmentId"); if (shipmentId == null) throw new IllegalStateException("either serviceId or shipmentId is missing"); Shipment shipment = getShipment(shipmentId); if (shipment == null) throw new IllegalStateException("shipment with id " + shipmentId + " does not exist."); if (type.equals("pickupShipment")) { routeBuilder.addPickup(shipment); } else if (type.equals("deliverShipment")) { routeBuilder.addDelivery(shipment); } else throw new IllegalStateException("type " + type + " is not supported. Use 'pickupShipment' or 'deliverShipment' here"); } } routes.add(routeBuilder.build()); } VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost); List<HierarchicalConfiguration> unassignedJobConfigs = solutionConfig .configurationsAt("unassignedJobs.job"); for (HierarchicalConfiguration unassignedJobConfig : unassignedJobConfigs) { String jobId = unassignedJobConfig.getString("[@id]"); Job job = getShipment(jobId); if (job == null) job = getService(jobId); if (job == null) throw new IllegalStateException("cannot find unassignedJob with id " + jobId); solution.getUnassignedJobs().add(job); } solutions.add(solution); } }
From source file:ch.admin.suis.msghandler.config.SedexCertConfigFactory.java
/** * Method used to handle a private certificate given by {@link #parseFile(XMLConfiguration, String)} * * @param i The iterator//from w w w.ja v a2 s. c om * @param configFile The config file * @return A list of certificates * @throws ConfigurationException A config error. */ private List<SedexCertConfig> handlePrivateCertificate(Iterator i, String configFile) throws ConfigurationException { List<SedexCertConfig> sedexCfgs = new ArrayList<>(); HierarchicalConfiguration sub = (HierarchicalConfiguration) i.next(); File p12File = determinePrivateKeyLocation(sub.getString("location"), configFile); if (null == p12File) { throw new ConfigurationException("The referenced file " + configFile + " contains filenames with variables!\n" + "(probably ${ADAPTER_HOME} of ${SEDEX_HOME})! Define a environment variable with that name." + "The variable must point to the directory, where the sedex adpater is installed."); } if (!p12File.exists()) { throw new ConfigurationException("Maybe incorrect configuration in file: " + configFile + ", specified p12 file not found: " + p12File.getAbsolutePath()); } String password = sub.getString("password"); Date expireDate = null; List optionalInfo = sub.configurationsAt(".optionalInfo"); if (optionalInfo.size() == 1) { HierarchicalConfiguration optionalSub = (HierarchicalConfiguration) optionalInfo.get(0); String sExpiryDate = optionalSub.getString("expirydate"); try { expireDate = ISO8601Utils.parse(sExpiryDate); } catch (IllegalArgumentException ex) { throw new ConfigurationException("Unable to parse date: " + sExpiryDate, ex); } } SedexCertConfig sedexConfig = new SedexCertConfig(p12File, password, expireDate); LOG.debug("Found: " + sedexConfig.toString()); sedexCfgs.add(sedexConfig); return sedexCfgs; }
From source file:com.graphhopper.jsprit.io.problem.VrpXMLReader.java
private void readSolutions(XMLConfiguration vrpProblem) { if (solutions == null) return;//from w ww. j a v a2 s . c o m List<HierarchicalConfiguration> solutionConfigs = vrpProblem.configurationsAt("solutions.solution"); for (HierarchicalConfiguration solutionConfig : solutionConfigs) { String totalCost = solutionConfig.getString("cost"); double cost = -1; if (totalCost != null) cost = Double.parseDouble(totalCost); List<HierarchicalConfiguration> routeConfigs = solutionConfig.configurationsAt("routes.route"); List<VehicleRoute> routes = new ArrayList<VehicleRoute>(); for (HierarchicalConfiguration routeConfig : routeConfigs) { //! here, driverId is set to noDriver, no matter whats in driverId. Driver driver = DriverImpl.noDriver(); String vehicleId = routeConfig.getString("vehicleId"); Vehicle vehicle = getVehicle(vehicleId); if (vehicle == null) throw new IllegalArgumentException("vehicle is missing."); String start = routeConfig.getString("start"); if (start == null) throw new IllegalArgumentException("route start-time is missing."); double departureTime = Double.parseDouble(start); String end = routeConfig.getString("end"); if (end == null) throw new IllegalArgumentException("route end-time is missing."); VehicleRoute.Builder routeBuilder = VehicleRoute.Builder.newInstance(vehicle, driver); routeBuilder.setDepartureTime(departureTime); List<HierarchicalConfiguration> actConfigs = routeConfig.configurationsAt("act"); for (HierarchicalConfiguration actConfig : actConfigs) { String type = actConfig.getString("[@type]"); if (type == null) throw new IllegalArgumentException("act[@type] is missing."); double arrTime = 0.; double endTime = 0.; String arrTimeS = actConfig.getString("arrTime"); if (arrTimeS != null) arrTime = Double.parseDouble(arrTimeS); String endTimeS = actConfig.getString("endTime"); if (endTimeS != null) endTime = Double.parseDouble(endTimeS); if (type.equals("break")) { Break currentbreak = getBreak(vehicleId); routeBuilder.addBreak(currentbreak); } else { String serviceId = actConfig.getString("serviceId"); if (serviceId != null) { Service service = getService(serviceId); routeBuilder.addService(service); } else { String shipmentId = actConfig.getString("shipmentId"); if (shipmentId == null) throw new IllegalArgumentException("either serviceId or shipmentId is missing"); Shipment shipment = getShipment(shipmentId); if (shipment == null) throw new IllegalArgumentException( "shipment with id " + shipmentId + " does not exist."); if (type.equals("pickupShipment")) { routeBuilder.addPickup(shipment); } else if (type.equals("deliverShipment")) { routeBuilder.addDelivery(shipment); } else throw new IllegalArgumentException("type " + type + " is not supported. Use 'pickupShipment' or 'deliverShipment' here"); } } } routes.add(routeBuilder.build()); } VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost); List<HierarchicalConfiguration> unassignedJobConfigs = solutionConfig .configurationsAt("unassignedJobs.job"); for (HierarchicalConfiguration unassignedJobConfig : unassignedJobConfigs) { String jobId = unassignedJobConfig.getString("[@id]"); Job job = getShipment(jobId); if (job == null) job = getService(jobId); if (job == null) throw new IllegalArgumentException("cannot find unassignedJob with id " + jobId); solution.getUnassignedJobs().add(job); } solutions.add(solution); } }
From source file:com.eyeq.pivot4j.ui.AbstractPivotRenderer.java
/** * @see com.eyeq.pivot4j.state.Configurable#restoreSettings(org.apache.commons.configuration.HierarchicalConfiguration) *//*from ww w .ja v a2 s . c om*/ @Override public void restoreSettings(HierarchicalConfiguration configuration) { if (configuration == null) { throw new NullArgumentException("configuration"); } this.showDimensionTitle = configuration.getBoolean("showDimensionTitle", true); this.showParentMembers = configuration.getBoolean("showParentMembers", false); this.hideSpans = configuration.getBoolean("hideSpans", false); List<HierarchicalConfiguration> aggregationSettings = configuration .configurationsAt("aggregations.aggregation"); this.aggregatorNames.clear(); for (HierarchicalConfiguration aggConfig : aggregationSettings) { String name = aggConfig.getString("[@name]"); if (name != null) { Axis axis = Axis.Standard.valueOf(aggConfig.getString("[@axis]")); AggregatorPosition position = AggregatorPosition.valueOf(aggConfig.getString("[@position]")); AggregatorKey key = new AggregatorKey(axis, position); List<String> names = aggregatorNames.get(key); if (names == null) { names = new LinkedList<String>(); aggregatorNames.put(key, names); } if (!names.contains(name)) { names.add(name); } } } initializeProperties(); if (cellProperties != null) { try { cellProperties.restoreSettings(configuration.configurationAt("properties.cell")); } catch (IllegalArgumentException e) { } } if (headerProperties != null) { try { headerProperties.restoreSettings(configuration.configurationAt("properties.header")); } catch (IllegalArgumentException e) { } } }
From source file:net.datenwerke.sandbox.util.SandboxParser.java
protected SandboxContext loadSandbox(String name, HierarchicalConfiguration conf, HierarchicalConfiguration contextConf, HashSet<String> basedOnProcessed) { SandboxContext context = new SandboxContext(); String basedOn = contextConf.getString("[@basedOn]"); if (null != basedOn) { if (basedOnProcessed.contains(basedOn)) throw new IllegalStateException( "Loop detected: there seems to be a loop in the sandbox configuration at" + basedOn + " and " + name); basedOnProcessed.add(basedOn);/*from ww w . ja v a2 s. c o m*/ HierarchicalConfiguration baseConf = null; for (HierarchicalConfiguration c : conf.configurationsAt("security.sandbox")) { if (name.equals(contextConf.getString("[@name]"))) { baseConf = c; break; } } if (null == baseConf) throw new IllegalStateException("Could not find config for " + basedOn); SandboxContext basis = loadSandbox(name, conf, baseConf, basedOnProcessed); context = basis.clone(); } Boolean allAccess = contextConf.getBoolean("[@allowAll]", false); if (allAccess) context.setPassAll(allAccess); boolean bypassClassAccesss = contextConf.getBoolean("[@bypassClassAccess]", false); context.setBypassClassAccessChecks(bypassClassAccesss); boolean bypassPackageAccesss = contextConf.getBoolean("[@bypassPackageAccess]", false); context.setBypassPackageAccessChecks(bypassPackageAccesss); Boolean debug = contextConf.getBoolean("[@debug]", false); if (debug) context.setDebug(debug); String codesource = contextConf.getString("[@codesource]", null); if (null != codesource && !"".equals(codesource.trim())) context.setCodesource(codesource); /* run in */ Boolean runInThread = contextConf.getBoolean("[@runInThread]", false); if (runInThread) context.setRunInThread(runInThread); Boolean runRemote = contextConf.getBoolean("[@runRemote]", false); if (runRemote) context.setRunRemote(runRemote); /* finalizers */ Boolean removeFinalizers = contextConf.getBoolean("[@removeFinalizers]", false); if (removeFinalizers) context.setRemoveFinalizers(removeFinalizers); /* thread */ configureThreadRestrictions(context, contextConf); /* packages */ configurePackages(context, contextConf); /* class access */ try { configureClasses(context, contextConf); /* application loader */ configureClassesForApplicationLoader(context, contextConf); } catch (MalformedURLException e) { throw new IllegalArgumentException("Could not generate URL", e); } /* permissions */ configurePermissions(context, contextConf); /* file access */ configureFileAccess(context, contextConf); return context; }
From source file:com.sonicle.webtop.core.app.DataSourcesConfig.java
protected HikariConfig parseDataSource(HierarchicalConfiguration dsEl) throws ParseException { HikariConfig config = createHikariConfig(); if (dsEl.containsKey("[@dataSourceClassName]")) { // Jdbc 4 configs config.setDataSourceClassName(dsEl.getString("[@dataSourceClassName]")); config.addDataSourceProperty("serverName", dsEl.getString("[@serverName]")); if (dsEl.containsKey("[@port]")) config.addDataSourceProperty("port", dsEl.getInt("[@port]")); config.addDataSourceProperty("databaseName", dsEl.getString("[@databaseName]")); } else if (dsEl.containsKey("[@driverClassName]")) { // Jdbc 3 configs config.setDriverClassName(dsEl.getString("[@driverClassName]")); config.setJdbcUrl(dsEl.getString("[@jdbcUrl]")); }// w w w . j a va 2s . com if (dsEl.containsKey("[@username]")) config.setUsername(dsEl.getString("[@username]")); if (dsEl.containsKey("[@password]")) config.setPassword(dsEl.getString("[@password]")); if (!dsEl.isEmpty()) { List<HierarchicalConfiguration> elProps = dsEl.configurationsAt("property"); Properties props = new Properties(); for (HierarchicalConfiguration elProp : elProps) { if (elProp.containsKey("[@name]") && elProp.containsKey("[@value]")) { final String name = elProp.getString("[@name]"); final String value = elProp.getString("[@value]"); if (!StringUtils.isBlank(name)) { props.setProperty(name, value); logger.trace("property: {} -> {}", name, value); } } } PropertyElf.setTargetFromProperties(config, props); } // Common configs... /* if(dsEl.containsKey("[@autoCommit]")) config.setAutoCommit(dsEl.getBoolean("[@autoCommit]")); if(dsEl.containsKey("[@connectionTimeout]")) config.setConnectionTimeout(dsEl.getLong("[@connectionTimeout]")); if(dsEl.containsKey("[@idleTimeout]")) config.setIdleTimeout(dsEl.getLong("[@idleTimeout]")); if(dsEl.containsKey("[@maxLifetime]")) config.setMaxLifetime(dsEl.getLong("[@maxLifetime]")); if(dsEl.containsKey("[@minimumIdle]")) config.setMinimumIdle(dsEl.getInt("[@minimumIdle]")); if(dsEl.containsKey("[@maximumPoolSize]")) config.setMaximumPoolSize(dsEl.getInt("[@maximumPoolSize]")); */ return config; }