List of usage examples for org.apache.commons.configuration ConfigurationUtils cloneConfiguration
public static Configuration cloneConfiguration(Configuration config) throws ConfigurationRuntimeException
From source file:co.turnus.generic.AbstractConfigurable.java
protected Configuration getConfiguration() { Configuration c = configuration != null ? configuration : new BaseConfiguration(); return ConfigurationUtils.cloneConfiguration(c); }
From source file:co.turnus.generic.AbstractConfigurable.java
@Override public void setConfiguration(Configuration configuration) { this.configuration = ConfigurationUtils.cloneConfiguration(configuration); }
From source file:com.dattack.dbtools.drules.engine.DefaultEventActionVisitor.java
@Override public void visit(final EventActionExecuteSqlBean item) { populateContext();//from ww w. j a v a2 s. c om for (final SourceBean sourceBean : item.getSourceList()) { SourceResult sourceResult = null; try { final SourceExecutor sourceExecutor = new SourceExecutor(sourceBean, ConfigurationUtils.cloneConfiguration(ThreadContext.getInstance().getConfiguration())); sourceResult = sourceExecutor.call(); } catch (final DrulesNestableException e) { throw new DrulesNestableRuntimeException(e); } finally { if (sourceResult != null) { sourceResult.close(); } } } }
From source file:com.dattack.dbtools.drules.engine.DrulesEngine.java
private static SourceResultGroup getSourceResultsList(final List<SourceBean> sourceList) throws DrulesNestableException { final ExecutorService executorService = Executors.newCachedThreadPool(createThreadFactory()); final List<Future<SourceResult>> futureList = new ArrayList<>(); for (final SourceBean sourceBean : sourceList) { futureList.add(executorService.submit(new SourceExecutor(sourceBean, ConfigurationUtils.cloneConfiguration(ThreadContext.getInstance().getConfiguration())))); }/*from w ww . j a v a 2 s. com*/ final SourceResultGroup sourceResultList = new SourceResultGroup(); for (final Future<SourceResult> future : futureList) { try { sourceResultList.add(future.get()); } catch (InterruptedException | ExecutionException e) { throw new DrulesNestableException(e); } } executorService.shutdown(); return sourceResultList; }
From source file:com.netflix.config.ConcurrentCompositeConfiguration.java
/** * Returns a copy of this object. This implementation will create a deep * clone, i.e. all configurations contained in this composite will also be * cloned. This only works if all contained configurations support cloning; * otherwise a runtime exception will be thrown. Registered event handlers * won't get cloned.//from ww w. jav a 2 s. c o m * */ @Override public Object clone() { try { ConcurrentCompositeConfiguration copy = (ConcurrentCompositeConfiguration) super.clone(); copy.clearConfigurationListeners(); copy.configList = new LinkedList<AbstractConfiguration>(); copy.containerConfiguration = (AbstractConfiguration) ConfigurationUtils .cloneConfiguration(getContainerConfiguration()); copy.configList.add(copy.containerConfiguration); for (Configuration config : configList) { if (config != getContainerConfiguration()) { copy.addConfiguration((AbstractConfiguration) ConfigurationUtils.cloneConfiguration(config)); } } return copy; } catch (CloneNotSupportedException cnex) { // cannot happen throw new ConfigurationRuntimeException(cnex); } }
From source file:org.apache.whirr.ClusterSpec.java
/** * @throws ConfigurationException if something is wrong *///from www. java 2 s . c o m public ClusterSpec(Configuration userConfig, boolean loadDefaults) throws ConfigurationException { if (loadDefaults) { config = composeWithDefaults(userConfig); } else { config = ConfigurationUtils.cloneConfiguration(userConfig); } setClusterName(getString(Property.CLUSTER_NAME)); setServiceName(getString(Property.SERVICE_NAME)); setBootstrapUser(getBootstrapUserOrDeprecatedLoginUser()); setClusterUser(getString(Property.CLUSTER_USER)); setInstanceTemplates(InstanceTemplate.parse(config)); setMaxStartupRetries(getInt(Property.MAX_STARTUP_RETRIES, 1)); setProvider(getString(Property.PROVIDER)); setIdentity(getString(Property.IDENTITY)); setCredential(getString(Property.CREDENTIAL)); setBlobStoreProvider(getString(Property.BLOBSTORE_PROVIDER)); setBlobStoreIdentity(getString(Property.BLOBSTORE_IDENTITY)); setBlobStoreCredential(getString(Property.BLOBSTORE_CREDENTIAL)); setBlobStoreCacheContainer(getString(Property.BLOBSTORE_CACHE_CONTAINER)); setStateStore(getString(Property.STATE_STORE)); setStateStoreContainer(getString(Property.STATE_STORE_CONTAINER)); setStateStoreBlob(getString(Property.STATE_STORE_BLOB)); setAwsEc2SpotPrice(getFloat(Property.AWS_EC2_SPOT_PRICE, -1)); checkAndSetKeyPair(); setImageId(getString(Property.IMAGE_ID)); setHardwareId(getString(Property.HARDWARE_ID)); setHardwareMinRam(getInt(Property.HARDWARE_MIN_RAM, 1024)); setLocationId(getString(Property.LOCATION_ID)); setBlobStoreLocationId(getString(Property.BLOBSTORE_LOCATION_ID)); setClientCidrs(getList(Property.CLIENT_CIDRS)); setTerminateAllOnLaunchFailure( config.getBoolean(Property.TERMINATE_ALL_ON_LAUNCH_FAILURE.getConfigName(), Boolean.TRUE)); Map<String, List<String>> fr = new HashMap<String, List<String>>(); String firewallPrefix = Property.FIREWALL_RULES.getConfigName(); Pattern firewallRuleKeyPattern = Pattern .compile("^".concat(Pattern.quote(firewallPrefix).concat("(?:\\.(.+))?$"))); for (String key : Iterators.<String>toArray(config.getKeys(), String.class)) { Matcher m = firewallRuleKeyPattern.matcher(key); if (!m.matches()) continue; String role = m.group(1); fr.put(role, config.getList(key)); } setFirewallRules(fr); setVersion(getString(Property.VERSION)); setRunUrlBase(getString(Property.RUN_URL_BASE)); }
From source file:org.ssh.test.conf.IConfiguration.java
/** * Returns a copy of this object. This implementation performs a deep clone, * i.e. all contained configurations will be cloned, too. For this to work, * all contained configurations must be cloneable. Registered event * listeners won't be cloned. The clone will use the same node combiner than * the original.//from w ww . j av a2 s.co m * * @return the copied object */ @Override public Object clone() { CombinedConfiguration copy = (CombinedConfiguration) super.clone(); copy.clear(); for (ConfigData cd : configurations) { copy.addConfiguration( (AbstractConfiguration) ConfigurationUtils.cloneConfiguration(cd.getConfiguration()), cd.getName(), cd.getAt()); } copy.setRootNode(new DefaultConfigurationNode()); return copy; }
From source file:org.zaproxy.zap.extension.ascan.CustomScanDialog.java
private void reset(boolean refreshUi) { // From Apache Commons source code: // Note: This method won't work well on hierarchical configurations because it is not able to // copy information about the properties' structure. // So when dealing with hierarchical configuration objects their clone() methods should be used. //FileConfiguration fileConfig = new XMLConfiguration(); //ConfigurationUtils.copy(extension.getScannerParam().getConfig(), fileConfig); XMLConfiguration fileConfig = (XMLConfiguration) ConfigurationUtils .cloneConfiguration(extension.getScannerParam().getConfig()); scannerParam = new ScannerParam(); scannerParam.load(fileConfig);/*from ww w . j a v a2 s . c om*/ optionsParam = new OptionsParam(); optionsParam.load(fileConfig); if (refreshUi) { init(target); repaint(); } }
From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java
private void reset(boolean refreshUi) { // From Apache Commons source code: // Note: This method won't work well on hierarchical configurations because it is not able to // copy information about the properties' structure. // So when dealing with hierarchical configuration objects their clone() methods should be used. // FileConfiguration fileConfig = new XMLConfiguration(); // ConfigurationUtils.copy(extension.getScannerParam().getConfig(), fileConfig); XMLConfiguration fileConfig = (XMLConfiguration) ConfigurationUtils .cloneConfiguration(extension.getScannerParam().getConfig()); // XMLConfiguration fileConfig = null; scannerParam = new ScannerParam(); scannerParam.load(fileConfig);//from ww w. j a v a2 s . c om optionsParam = new OptionsParam(); optionsParam.load(fileConfig); if (refreshUi) { init(target); repaint(); //sTree.reset(); } }