WIP - change semantics of parameter addition api EntitySpec.parameters(...) should *add* parameters, like the other methods; since parameters have just been introduced it is fine to do this
also comments and tidy of other merges Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/aa9a2d7b Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/aa9a2d7b Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/aa9a2d7b Branch: refs/heads/master Commit: aa9a2d7be66863144449fe05079ddad97d19a457 Parents: 73f7e73 Author: Alex Heneveld <[email protected]> Authored: Wed Jan 13 23:08:29 2016 +0000 Committer: Alex Heneveld <[email protected]> Committed: Thu Jan 14 15:51:24 2016 +0000 ---------------------------------------------------------------------- .../api/internal/AbstractBrooklynObjectSpec.java | 9 ++++++++- .../brooklyn/core/mgmt/EntityManagementUtils.java | 16 ++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aa9a2d7b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java index ab046d5..d03eec1 100644 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java +++ b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java @@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; @@ -107,8 +108,14 @@ public abstract class AbstractBrooklynObjectSpec<T,SpecT extends AbstractBrookly return self(); } + /** adds the given parameters */ public SpecT parameters(List<? extends SpecParameter<?>> parameters) { - this.parameters = ImmutableList.copyOf(checkNotNull(parameters, "parameters")); + // parameters follows immutable pattern, unlike the other fields + Builder<SpecParameter<?>> result = ImmutableList.<SpecParameter<?>>builder(); + if (this.parameters!=null) + result.addAll(this.parameters); + result.addAll( checkNotNull(parameters, "parameters") ); + this.parameters = result.build(); return self(); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aa9a2d7b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java index d0f5b14..7dcd9a2 100644 --- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java +++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java @@ -248,18 +248,18 @@ public class EntityManagementUtils { if (Strings.isNonEmpty(wrapperParent.getDisplayName())) { wrappedChild.displayName(wrapperParent.getDisplayName()); } - if (!wrapperParent.getLocations().isEmpty()) { - wrappedChild.locations(wrapperParent.getLocations()); - } - if (!wrapperParent.getParameters().isEmpty()) { - wrappedChild.parameters(wrapperParent.getParameters()); - } + + wrappedChild.locations(wrapperParent.getLocations()); + + wrappedChild.parameters(wrapperParent.getParameters()); + if (wrappedChild.getCatalogItemId()==null) { wrappedChild.catalogItemId(wrapperParent.getCatalogItemId()); } - // NB: this clobbers child config; might prefer to deeply merge maps etc - // (but this should not be surprising, as unwrapping is often parameterising the nested blueprint, so outer config should dominate) + // NB: this clobber's child config; might prefer to deeply merge maps etc + // (or maybe even prevent the merge in these cases; + // not sure there is a compelling reason to have config on a pure-wrapper parent) Map<ConfigKey<?>, Object> configWithoutWrapperMarker = Maps.filterKeys(wrapperParent.getConfig(), Predicates.not(Predicates.<ConfigKey<?>>equalTo(EntityManagementUtils.WRAPPER_APP_MARKER))); wrappedChild.configure(configWithoutWrapperMarker); wrappedChild.configure(wrapperParent.getFlags());
