From 629ab10872baf4a8dc3f20fa4bd657d747f67fd7 Mon Sep 17 00:00:00 2001 From: Svetoslav Neykov Date: Tue, 31 May 2016 17:30:03 +0300 Subject: [PATCH] Don't inherit "brooklyn.wrapper_app" key in children --- .../camp/brooklyn/ApplicationsYamlTest.java | 19 +++++++++++++++++++ .../core/mgmt/EntityManagementUtils.java | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java index 979dadc2ee..7a14f94706 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java @@ -232,6 +232,25 @@ public void testDoesNotWrapCatalogItemAndUsesCatalogServiceName() throws Excepti assertDoesNotWrap(app, BasicApplication.class, "catalogServiceLevel"); } + @Test + public void testUnwrappedChildNotTagged() throws Exception { + addCatalogItems( + "brooklyn.catalog:", + " id: simple", + " version: " + TEST_VERSION, + " item:", + " type: " + BasicEntity.class.getName()); + Entity app = createAndStartApplication( + "services:", + "- type: simple:" + TEST_VERSION); + Entity entity = Iterables.getOnlyElement(app.getChildren()); + assertNull(entity.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER)); + // Note that "brooklyn.wrapper_app" will still make it into + // ((EntityInternal) entity).config().getBag().getAllConfigAsConfigKeyMap(); + // so the UI will still show the marker as inherited by the entity. + + } + // FIXME Fails with name "My App 1" rather than the overridden value. // See discussion in https://issues.apache.org/jira/browse/BROOKLYN-248 @Test(groups="WIP") diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java index d5c31eecd9..61b518941f 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java @@ -32,6 +32,7 @@ import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec; import org.apache.brooklyn.api.mgmt.ManagementContext; import org.apache.brooklyn.api.mgmt.Task; +import org.apache.brooklyn.config.ConfigInheritance; import org.apache.brooklyn.config.ConfigKey; import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog; import org.apache.brooklyn.core.config.ConfigKeys; @@ -73,7 +74,9 @@ public class EntityManagementUtils { * it will be unwrapped. * See {@link #newWrapperApp()} and {@link #unwrapApplication(EntitySpec)}. */ - public static final ConfigKey WRAPPER_APP_MARKER = ConfigKeys.newBooleanConfigKey("brooklyn.wrapper_app"); + public static final ConfigKey WRAPPER_APP_MARKER = ConfigKeys.builder(Boolean.class, "brooklyn.wrapper_app") + .inheritance(ConfigInheritance.NONE) + .build(); /** creates an application from the given app spec, managed by the given management context */ public static T createUnstarted(ManagementContext mgmt, EntitySpec spec) {