Example usage for com.amazonaws.services.elasticbeanstalk.model ConfigurationOptionSetting ConfigurationOptionSetting

List of usage examples for com.amazonaws.services.elasticbeanstalk.model ConfigurationOptionSetting ConfigurationOptionSetting

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticbeanstalk.model ConfigurationOptionSetting ConfigurationOptionSetting.

Prototype

public ConfigurationOptionSetting() 

Source Link

Document

Default constructor for ConfigurationOptionSetting object.

Usage

From source file:br.com.ingenieux.mojo.beanstalk.AbstractNeedsEnvironmentMojo.java

License:Apache License

protected ConfigurationOptionSetting[] introspectOptionSettings() {
    Set<ConfigurationOptionSetting> configOptionSetting = new TreeSet<ConfigurationOptionSetting>(
            COS_COMPARATOR);//from www . j a  v a  2s.  com

    Map<String, ConfigurableOptionSetting> extraOptionSettings = new LinkedHashMap<String, ConfigurableOptionSetting>();

    for (ConfigurableOptionSetting e : configurableOptionSettings) {
        if (!e.getAlias().startsWith(BEANSTALKX_PREFIX)) {
            getLog().warn(format("Ignoring ConfigurableOptionSetting '%s' ('%s') since it doesn't start with "
                    + BEANSTALKX_PREFIX, e.getAlias(), e));
            continue;
        }

        getLog().info(format("Declaring alias '%s' for '%s'", e.getAlias(), e));

        extraOptionSettings.put(e.getAlias(), e);
    }

    Properties properties = new Properties();

    if (null != project) {
        for (Map.Entry<Object, Object> entry : project.getProperties().entrySet()) {
            if (("" + entry.getKey()).startsWith("beanstalk")) {
                properties.put(entry.getKey(), entry.getValue());
            }
        }
    }

    for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
        if (("" + entry.getKey()).startsWith("beanstalk")) {
            properties.put(entry.getKey(), entry.getValue());
        }
    }

    for (Object o : properties.keySet()) {
        String k = "" + o;

        if (k.startsWith("beanstalk.env.aws.")) {
            String realKey = k.substring("beanstalk.env.".length());
            String v = "" + properties.get(k);
            List<String> elements = new ArrayList<String>(Arrays.asList(realKey.split("\\.")));

            String namespace = StringUtils.join(elements.subList(0, -1 + elements.size()), ":");
            String optionName = elements.get(-1 + elements.size());

            getLog().info("importing " + k + " as " + namespace + ":" + optionName + "=" + v);

            configOptionSetting.add(new ConfigurationOptionSetting().withNamespace(namespace)
                    .withOptionName(optionName).withValue(v));
        } else if (COMMON_PARAMETERS.containsKey(k)) {
            String v = "" + properties.get(k);
            String namespace = COMMON_PARAMETERS.get(k).getNamespace();
            String optionName = COMMON_PARAMETERS.get(k).getOptionName();

            getLog().info("Found alias " + k + " for " + namespace + ":" + optionName + "(value=" + v + ")");

            configOptionSetting.add(new ConfigurationOptionSetting().withNamespace(namespace)
                    .withOptionName(optionName).withValue(v));
        } else if (extraOptionSettings.containsKey(k)) {
            ConfigurableOptionSetting cos = extraOptionSettings.get(k);
            String v = "" + properties.get(k);

            if (isNotBlank(v)) {
                getLog().info(format("Assigning alias '%s' to '%s' (value='%s')", k, cos, v));
                configOptionSetting
                        .add(new ConfigurationOptionSetting(cos.getNamespace(), cos.getOptionName(), v));
            }
        }
    }

    return (ConfigurationOptionSetting[]) configOptionSetting
            .toArray(new ConfigurationOptionSetting[configOptionSetting.size()]);
}

From source file:br.com.ingenieux.mojo.beanstalk.env.SetPropertyMojo.java

License:Apache License

protected Object executeInternal() throws Exception {
    waitForNotUpdating();/*from  w w w . j  av  a2  s.  co m*/

    UpdateEnvironmentRequest req = new UpdateEnvironmentRequest().withEnvironmentId(curEnv.getEnvironmentId());

    req.setOptionSettings(Arrays.asList(
            new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment")
                    .withOptionName(envName).withValue(envValue)));

    UpdateEnvironmentResult result = getService().updateEnvironment(req);

    return result;
}