Example usage for org.apache.commons.configuration2 HierarchicalConfiguration setProperty

List of usage examples for org.apache.commons.configuration2 HierarchicalConfiguration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 HierarchicalConfiguration setProperty.

Prototype

void setProperty(String key, Object value);

Source Link

Document

Set a property, this will replace any previously set values.

Usage

From source file:com.github.technosf.posterer.modules.commons.config.CommonsConfiguratorPropertiesImpl.java

/**
 * Check for actionability/*  w w w .  ja v  a2  s  .  com*/
 * <p>
 * If not actionable, remove, otherwise re-key as needed.
 * 
 * @param actionable
 *            the actionable being checked
 * @param nodeId
 *            the node id of the of actionable representation
 * @param node
 *            the actionable representation
 * @param config
 *            the config holding the actionable representation
 * @return true if rekeys
 */
private static boolean actionable(Actionable actionable, int nodeId,
        HierarchicalConfiguration<ImmutableNode> node, HierarchicalConfiguration<ImmutableNode> config) {

    if (actionable.isActionable())
    /*
     * Property is good.
     */
    {
        // System.out.printf("%1$S::%2$s", hashCode, pdi.hashCode());
        if (nodeId != actionable.hashCode())
        /*
         * The config hash changed and needs reindexing
         */
        {
            node.setProperty("id", actionable.hashCode());
        }

        return true;

    } // if (proxy.isActionable())
    else
    /*
     * Property was ill formed - remove from file
     */
    {
        String key = node.getString("id");
        config.clearTree(key);
        return false;
    }
}

From source file:org.craftercms.deployer.impl.DeploymentResolverImpl.java

protected DeploymentContext createDeploymentContext(String deploymentId, File customConfigFile,
        File customAppContextFile) throws IOException {
    HierarchicalConfiguration config = loadConfiguration(customConfigFile);
    ConfigurableApplicationContext appContext = loadApplicationContext(config, customAppContextFile);

    config.setProperty(DEPLOYMENT_ID_PROPERTY_NAME, deploymentId);

    DeploymentPipeline deploymentPipeline = getDeploymentPipeline(config, appContext);
    ErrorHandler errorHandler = getErrorHandler(appContext);

    return new DeploymentContextImpl(deploymentId, deploymentPipeline, errorHandler, appContext);
}

From source file:org.craftercms.deployer.impl.TargetResolverImpl.java

protected TargetContext createTargetContext(String targetId, File customConfigFile, File customAppContextFile)
        throws IOException, DeploymentException {
    HierarchicalConfiguration config = loadConfiguration(customConfigFile);
    ConfigurableApplicationContext appContext = loadApplicationContext(config, customAppContextFile);

    config.setProperty(TARGET_ID_CONFIG_KEY, targetId);

    DeploymentPipeline deploymentPipeline = getDeploymentPipeline(config, appContext);

    return new TargetContextImpl(targetId, deploymentPipeline, appContext);
}

From source file:org.craftercms.deployer.impl.TargetServiceImpl.java

protected Target createTarget(File configFile, File contextFile) throws TargetServiceException {
    try {//from  w w w  .  j  ava2  s  .  com
        HierarchicalConfiguration config = loadConfiguration(configFile);
        String env = ConfigUtils.getRequiredStringProperty(config, TARGET_ENV_CONFIG_KEY);
        String siteName = ConfigUtils.getRequiredStringProperty(config, TARGET_SITE_NAME_CONFIG_KEY);
        String targetId = TargetImpl.getId(env, siteName);

        config.setProperty(TARGET_ID_CONFIG_KEY, targetId);

        ConfigurableApplicationContext context = loadApplicationContext(config, contextFile);
        DeploymentPipeline deploymentPipeline = deploymentPipelineFactory.getPipeline(config, context,
                TARGET_DEPLOYMENT_PIPELINE_CONFIG_KEY);
        Target target = new TargetImpl(env, siteName, deploymentPipeline, configFile, config, context);

        scheduleDeployment(target);

        return target;
    } catch (Exception e) {
        throw new TargetServiceException("Failed to create target for configuration file " + configFile, e);
    }
}