Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DDFB018CAE for ; Thu, 14 Jan 2016 23:54:16 +0000 (UTC) Received: (qmail 95559 invoked by uid 500); 14 Jan 2016 23:54:16 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 95497 invoked by uid 500); 14 Jan 2016 23:54:16 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 95119 invoked by uid 99); 14 Jan 2016 23:54:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2016 23:54:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0FAADE38A6; Thu, 14 Jan 2016 23:54:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: heneveld@apache.org To: commits@brooklyn.apache.org Date: Thu, 14 Jan 2016 23:54:29 -0000 Message-Id: <2df3f281f0254926b6d1767ef655f392@git.apache.org> In-Reply-To: <084c0a2705884477b304d4f12991393d@git.apache.org> References: <084c0a2705884477b304d4f12991393d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [15/24] incubator-brooklyn git commit: WIP - change semantics of parameter addition 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 Authored: Wed Jan 13 23:08:29 2016 +0000 Committer: Alex Heneveld 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> parameters) { - this.parameters = ImmutableList.copyOf(checkNotNull(parameters, "parameters")); + // parameters follows immutable pattern, unlike the other fields + Builder> result = ImmutableList.>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, Object> configWithoutWrapperMarker = Maps.filterKeys(wrapperParent.getConfig(), Predicates.not(Predicates.>equalTo(EntityManagementUtils.WRAPPER_APP_MARKER))); wrappedChild.configure(configWithoutWrapperMarker); wrappedChild.configure(wrapperParent.getFlags());