brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #429: BasicJcloudsLocationCustomizer is an Enti...
Date Wed, 16 Nov 2016 13:44:10 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/429#discussion_r88238075
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/BasicJcloudsLocationCustomizer.java
---
    @@ -18,19 +18,73 @@
      */
     package org.apache.brooklyn.location.jclouds;
     
    +import java.util.Collection;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.entity.EntityInitializer;
    +import org.apache.brooklyn.api.entity.EntityLocal;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
    +import org.apache.brooklyn.core.location.LocationConfigKeys;
    +import org.apache.brooklyn.core.objs.BasicConfigurableObject;
    +import org.apache.brooklyn.util.core.config.ConfigBag;
     import org.jclouds.compute.ComputeService;
     import org.jclouds.compute.domain.Template;
     import org.jclouds.compute.domain.TemplateBuilder;
     import org.jclouds.compute.options.TemplateOptions;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
     
    -import org.apache.brooklyn.api.entity.Entity;
    -import org.apache.brooklyn.core.location.LocationConfigKeys;
    -import org.apache.brooklyn.core.objs.BasicConfigurableObject;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.ImmutableMap;
    +import com.google.common.collect.Iterables;
    +import com.google.common.collect.Lists;
     
     /**
    - * A default no-op implementation, which can be extended to override the appropriate
methods.
    + * A default no-op location customizer, which can be extended to override the appropriate
methods.
    + * <p>
    + * When the class is used as an {@link EntityInitializer} it inserts itself into the
entity's
    + * {@link JcloudsLocationConfig#JCLOUDS_LOCATION_CUSTOMIZERS} under the
    + * {@link BrooklynConfigKeys#PROVISIONING_PROPERTIES} key.
      */
    -public class BasicJcloudsLocationCustomizer extends BasicConfigurableObject implements
JcloudsLocationCustomizer {
    +public class BasicJcloudsLocationCustomizer extends BasicConfigurableObject implements
JcloudsLocationCustomizer, EntityInitializer {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(BasicJcloudsLocationCustomizer.class);
    +
    +    public BasicJcloudsLocationCustomizer() {
    +        this(ImmutableMap.<String, String>of());
    +    }
    +
    +    public BasicJcloudsLocationCustomizer(Map<String, String> params) {
    +        this(ConfigBag.newInstance(params));
    +    }
    +
    +    public BasicJcloudsLocationCustomizer(final ConfigBag params) {
    +        for (Map.Entry<String, Object> entry : params.getAllConfig().entrySet())
{
    +            config().set(ConfigKeys.newConfigKey(Object.class, entry.getKey()), entry.getValue());
    +        }
    +    }
    +
    +    @Override
    +    public void apply(EntityLocal entity) {
    +        ConfigKey<Object> subkey = BrooklynConfigKeys.PROVISIONING_PROPERTIES.subKey(JcloudsLocationConfig.JCLOUDS_LOCATION_CUSTOMIZERS.getName());
    --- End diff --
    
    very minor - maybe call this `customizers` rather than just `subkey`, to highlight its
role


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message