Repository: brooklyn-server
Updated Branches:
  refs/heads/master f4281af2e -> 1db462a3f


introduce inheritance contexts so ConfigKey is not opinionated about type v 
runtime inheritance
(that's a choice Brooklyn makes about how to use config keys)


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/189677de
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/189677de
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/189677de

Branch: refs/heads/master
Commit: 189677def8af93694c4fac9f828575c51ccc1e85
Parents: 759d67e
Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Authored: Fri Sep 16 00:19:51 2016 +0100
Committer: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Committed: Tue Sep 20 08:47:26 2016 +0100

----------------------------------------------------------------------
 .../camp/brooklyn/BrooklynCampConstants.java    |  4 +-
 .../brooklyn/core/config/BasicConfigKey.java    | 72 +++++++++++++++++---
 .../apache/brooklyn/core/config/ConfigKeys.java |  4 ++
 .../brooklyn/core/config/MapConfigKey.java      |  4 +-
 .../brooklyn/core/entity/AbstractEntity.java    |  2 +-
 .../entity/lifecycle/ServiceStateLogic.java     |  4 +-
 .../brooklyn/core/objs/BasicSpecParameter.java  |  2 +-
 .../brooklyn/core/config/ConfigKeysTest.java    |  2 +-
 .../entity/ConfigEntityInheritanceTest.java     |  4 +-
 .../brooklyn/test/framework/TestCase.java       |  2 +-
 .../brooklyn/config/ConfigInheritance.java      |  3 +
 .../org/apache/brooklyn/config/ConfigKey.java   | 24 ++++---
 .../brooklyn/util/collections/MutableMap.java   |  4 +-
 13 files changed, 98 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
----------------------------------------------------------------------
diff --git 
a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
 
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
index 5a2d4e6..0ea1116 100644
--- 
a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
+++ 
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
@@ -34,12 +34,12 @@ public class BrooklynCampConstants {
     public static final ConfigKey<String> PLAN_ID = 
ConfigKeys.builder(String.class, "camp.plan.id")
             .description("Identifier supplied in the deployment plan for 
component to which this entity corresponds "
                         + "(human-readable, for correlating across plan, 
template, and instance)")
-            .parentInheritance(ConfigInheritance.NONE)
+            .runtimeInheritance(ConfigInheritance.NONE)
             .build();
 
     public static final ConfigKey<String> TEMPLATE_ID = 
ConfigKeys.builder(String.class, "camp.template.id")
             .description("UID of the component in the CAMP template from which 
this entity was created")
-            .parentInheritance(ConfigInheritance.NONE)
+            .runtimeInheritance(ConfigInheritance.NONE)
             .build();
 
     public static final ConfigKey<CampPlatform> CAMP_PLATFORM = 
ConfigKeys.newConfigKey(CampPlatform.class, "brooklyn.camp.platform",

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java 
b/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
index a1285d8..2600ae7 100644
--- a/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
+++ b/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigKey.java
@@ -30,7 +30,10 @@ import javax.annotation.Nullable;
 
 import org.apache.brooklyn.api.mgmt.ExecutionContext;
 import org.apache.brooklyn.config.ConfigInheritance;
+import org.apache.brooklyn.config.ConfigInheritance.ConfigInheritanceContext;
 import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys.InheritanceContext;
+import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.internal.ConfigKeySelfExtracting;
 import org.apache.brooklyn.util.core.task.Tasks;
 import org.apache.brooklyn.util.exceptions.Exceptions;
@@ -95,7 +98,7 @@ public class BasicConfigKey<T> implements 
ConfigKeySelfExtracting<T>, Serializab
         protected T defaultValue;
         protected boolean reconfigurable;
         protected Predicate<? super T> constraint = Predicates.alwaysTrue();
-        protected ConfigInheritance parentInheritance;
+        protected ConfigInheritance runtimeInheritance;
         protected ConfigInheritance typeInheritance;
         
         protected abstract B self();
@@ -115,8 +118,8 @@ public class BasicConfigKey<T> implements 
ConfigKeySelfExtracting<T>, Serializab
             description(key.getDescription());
             defaultValue(key.getDefaultValue());
             reconfigurable(key.isReconfigurable());
-            parentInheritance(key.getParentInheritance());
-            typeInheritance(key.getTypeInheritance());
+            
runtimeInheritance(key.getInheritanceByContext(InheritanceContext.RUNTIME_MANAGEMENT));
+            
typeInheritance(key.getInheritanceByContext(InheritanceContext.TYPE_DEFINITION));
             constraint(key.getConstraint());
         }
         public B name(String val) {
@@ -137,8 +140,15 @@ public class BasicConfigKey<T> implements 
ConfigKeySelfExtracting<T>, Serializab
         public B reconfigurable(boolean val) {
             this.reconfigurable = val; return self();
         }
+        /**
+         * @deprecated since 0.10.0; use {@link 
#runtime2Inheritance(ConfigInheritance)}
+         */ 
+        @Deprecated
         public B parentInheritance(ConfigInheritance val) {
-            this.parentInheritance = val; return self();
+            this.runtimeInheritance = val; return self();
+        }
+        public B runtimeInheritance(ConfigInheritance val) {
+            this.runtimeInheritance = val; return self();
         }
         public B typeInheritance(ConfigInheritance val) {
             this.typeInheritance = val; return self();
@@ -148,7 +158,7 @@ public class BasicConfigKey<T> implements 
ConfigKeySelfExtracting<T>, Serializab
          */
         @Deprecated
         public B inheritance(ConfigInheritance val) {
-            return parentInheritance(val);
+            return runtimeInheritance(val);
         }
         @Beta
         public B constraint(Predicate<? super T> constraint) {
@@ -173,16 +183,24 @@ public class BasicConfigKey<T> implements 
ConfigKeySelfExtracting<T>, Serializab
     protected T defaultValue;
     protected boolean reconfigurable;
     protected ConfigInheritance typeInheritance;
-    protected ConfigInheritance parentInheritance;
+    protected ConfigInheritance runtimeInheritance;
     protected Predicate<? super T> constraint;
 
     /**
      * Kept only for backwards compatibility with serialised state; when read, 
it's value is used 
-     * for {@link #parentInheritance} and then set to null.
+     * for {@link #inheritanceByContext} and then set to null.
+     * @deprecated since 0.10.0
      */
     @Deprecated
     private ConfigInheritance inheritance;
-
+    /**
+     * Kept only for backwards compatibility with serialised state; when read, 
it's value is used 
+     * for {@link #inheritanceByContext} and then set to null.
+     * @deprecated since 0.10.0
+     */
+    @Deprecated
+    protected ConfigInheritance parentInheritance;
+    
     // FIXME In groovy, fields were `public final` with a default constructor; 
do we need the gson?
     public BasicConfigKey() { /* for gson */ }
 
@@ -225,7 +243,7 @@ public class BasicConfigKey<T> implements 
ConfigKeySelfExtracting<T>, Serializab
         this.description = builder.description;
         this.defaultValue = builder.defaultValue;
         this.reconfigurable = builder.reconfigurable;
-        this.parentInheritance = builder.parentInheritance;
+        this.parentInheritance = builder.runtimeInheritance;
         this.typeInheritance = builder.typeInheritance;
         // Note: it's intentionally possible to have default values that are 
not valid
         // per the configured constraint. If validity were checked here any 
class that
@@ -262,17 +280,49 @@ public class BasicConfigKey<T> implements 
ConfigKeySelfExtracting<T>, Serializab
         return reconfigurable;
     }
     
+    @Override @Nullable 
+    public ConfigInheritance getInheritanceByContext(ConfigInheritanceContext 
context) {
+        if (context==InheritanceContext.RUNTIME_MANAGEMENT) {
+            // for backwards compatbility
+            if (parentInheritance!=null) {
+                runtimeInheritance = parentInheritance;
+                parentInheritance = null;
+            }
+            if (inheritance!=null) {
+                runtimeInheritance = inheritance;
+                inheritance = null;
+            }
+            
+            return runtimeInheritance;
+        }
+        
+        if (context==InheritanceContext.TYPE_DEFINITION) {
+            return typeInheritance;
+        }
+        
+        return null;
+    }
+    
+    @Override
+    public Map<ConfigInheritanceContext,ConfigInheritance> 
getInheritanceByContext() {
+        MutableMap<ConfigInheritanceContext, ConfigInheritance> result = 
MutableMap.of();
+        for (InheritanceContext context: InheritanceContext.values()) {
+            result.addIfNotNull(context, getInheritanceByContext(context));
+        }
+        return result;
+    }
+
     @Deprecated @Override @Nullable
     public ConfigInheritance getInheritance() {
         return getParentInheritance();
     }
 
-    @Override @Nullable
+    @Deprecated @Override @Nullable
     public ConfigInheritance getTypeInheritance() {
         return typeInheritance;
     }
 
-    @Override @Nullable
+    @Deprecated @Override @Nullable
     public ConfigInheritance getParentInheritance() {
         if (parentInheritance == null && inheritance != null) {
             parentInheritance = inheritance;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/main/java/org/apache/brooklyn/core/config/ConfigKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/config/ConfigKeys.java 
b/core/src/main/java/org/apache/brooklyn/core/config/ConfigKeys.java
index f2bbc4a..21247c0 100644
--- a/core/src/main/java/org/apache/brooklyn/core/config/ConfigKeys.java
+++ b/core/src/main/java/org/apache/brooklyn/core/config/ConfigKeys.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import javax.annotation.Nonnull;
 
 import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.config.ConfigInheritance.ConfigInheritanceContext;
 import 
org.apache.brooklyn.core.config.BasicConfigKey.BasicConfigKeyOverwriting;
 import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
 import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
@@ -46,6 +47,9 @@ public class ConfigKeys {
 
     private static final Logger log = 
LoggerFactory.getLogger(ConfigKeys.class);
     
+    public enum InheritanceContext implements ConfigInheritanceContext
+    { TYPE_DEFINITION, RUNTIME_MANAGEMENT } 
+
     public static <T> ConfigKey<T> newConfigKey(Class<T> type, String name) {
         return new BasicConfigKey<T>(type, name);
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java 
b/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java
index d06e160..b27ba12 100644
--- a/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java
+++ b/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java
@@ -79,7 +79,7 @@ public class MapConfigKey<V> extends 
AbstractStructuredConfigKey<Map<String,V>,M
             description(key.getDescription());
             defaultValue(key.getDefaultValue());
             reconfigurable(key.isReconfigurable());
-            parentInheritance(key.getParentInheritance());
+            runtimeInheritance(key.getParentInheritance());
             typeInheritance(key.getTypeInheritance());
             constraint(key.getConstraint());
         }
@@ -121,7 +121,7 @@ public class MapConfigKey<V> extends 
AbstractStructuredConfigKey<Map<String,V>,M
                 builder.description,
                 builder.defaultValue);
         this.reconfigurable = builder.reconfigurable;
-        this.parentInheritance = builder.parentInheritance;
+        this.runtimeInheritance = builder.runtimeInheritance;
         this.typeInheritance = builder.typeInheritance;
         // Note: it's intentionally possible to have default values that are 
not valid
         // per the configured constraint. If validity were checked here any 
class that

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java 
b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index dc70034..4fae3e1 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -156,7 +156,7 @@ public abstract class AbstractEntity extends 
AbstractBrooklynObject implements E
     /**
      * The default name to use for this entity, if not explicitly overridden.
      */
-    public static final ConfigKey<String> DEFAULT_DISPLAY_NAME = 
BasicConfigKey.builder(String.class).name("defaultDisplayName").parentInheritance(ConfigInheritance.NONE).build();
+    public static final ConfigKey<String> DEFAULT_DISPLAY_NAME = 
BasicConfigKey.builder(String.class).name("defaultDisplayName").runtimeInheritance(ConfigInheritance.NONE).build();
 
     public static final BasicNotificationSensor<Location> LOCATION_ADDED = new 
BasicNotificationSensor<Location>(
             Location.class, "entity.location.added", "Location dynamically 
added to entity");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogic.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogic.java
 
b/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogic.java
index 21ccae2..790fe20 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogic.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogic.java
@@ -390,12 +390,12 @@ public class ServiceStateLogic {
         public static final ConfigKey<QuorumCheck> UP_QUORUM_CHECK = 
ConfigKeys.builder(QuorumCheck.class, 
"enricher.service_state.children_and_members.quorum.up")
             .description("Logic for checking whether this service is up, based 
on children and/or members, defaulting to allowing none but if there are any 
requiring at least one to be up")
             .defaultValue(QuorumCheck.QuorumChecks.atLeastOneUnlessEmpty())
-            .parentInheritance(ConfigInheritance.NONE)
+            .runtimeInheritance(ConfigInheritance.NONE)
             .build();
         public static final ConfigKey<QuorumCheck> RUNNING_QUORUM_CHECK = 
ConfigKeys.builder(QuorumCheck.class, 
"enricher.service_state.children_and_members.quorum.running") 
             .description("Logic for checking whether this service is healthy, 
based on children and/or members running, defaulting to requiring none to be 
ON-FIRE")
             .defaultValue(QuorumCheck.QuorumChecks.all())
-            .parentInheritance(ConfigInheritance.NONE)
+            .runtimeInheritance(ConfigInheritance.NONE)
             .build();
         // TODO items below should probably also have inheritance NONE ?
         public static final ConfigKey<Boolean> DERIVE_SERVICE_NOT_UP = 
ConfigKeys.newBooleanConfigKey("enricher.service_state.children_and_members.service_up.publish",
 "Whether to derive a service-not-up indicator from children", true);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java 
b/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
index cda3696..dc5ba3e 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
@@ -248,7 +248,7 @@ public class BasicSpecParameter<T> implements 
SpecParameter<T>{
                 .description(description)
                 .defaultValue(defaultValue)
                 .constraint(constraints)
-                .parentInheritance(parentInheritance)
+                .runtimeInheritance(parentInheritance)
                 .typeInheritance(typeInheritance);
             
             if (PortRange.class.equals(typeToken.getRawType())) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/test/java/org/apache/brooklyn/core/config/ConfigKeysTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/brooklyn/core/config/ConfigKeysTest.java 
b/core/src/test/java/org/apache/brooklyn/core/config/ConfigKeysTest.java
index 9e82c1a..00cb49b 100644
--- a/core/src/test/java/org/apache/brooklyn/core/config/ConfigKeysTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/config/ConfigKeysTest.java
@@ -82,7 +82,7 @@ public class ConfigKeysTest {
         ConfigKey<String> key = ConfigKeys.builder(String.class, "mykey")
             .description("my descr")
             .defaultValue("my default val")
-            .parentInheritance(ConfigInheritance.NONE)
+            .runtimeInheritance(ConfigInheritance.NONE)
             .reconfigurable(true)
             .build();
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
 
b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
index 3261d6f..7a88550 100644
--- 
a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
+++ 
b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
@@ -167,9 +167,9 @@ public class ConfigEntityInheritanceTest extends 
BrooklynAppUnitTestSupport {
     
     public static class MyEntityWithPartiallyHeritableConfig extends 
AbstractEntity {
         public static final ConfigKey<String> HERITABLE = 
ConfigKeys.builder(String.class, "herit.default").build();
-        public static final ConfigKey<String> UNINHERITABLE = 
ConfigKeys.builder(String.class, 
"herit.none").parentInheritance(ConfigInheritance.NONE).build();
+        public static final ConfigKey<String> UNINHERITABLE = 
ConfigKeys.builder(String.class, 
"herit.none").runtimeInheritance(ConfigInheritance.NONE).build();
         // i find a strange joy in words where the prefix "in-" does not mean 
not, like inflammable 
-        public static final ConfigKey<String> ALWAYS_HERITABLE = 
ConfigKeys.builder(String.class, 
"herit.always").parentInheritance(ConfigInheritance.ALWAYS).build();
+        public static final ConfigKey<String> ALWAYS_HERITABLE = 
ConfigKeys.builder(String.class, 
"herit.always").runtimeInheritance(ConfigInheritance.ALWAYS).build();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
----------------------------------------------------------------------
diff --git 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
index a6c7b18..545f77c 100644
--- 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
+++ 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
@@ -36,7 +36,7 @@ public interface TestCase extends TargetableTestComponent {
     ConfigKey<EntitySpec<?>> ON_ERROR_SPEC = ConfigKeys.builder(new 
TypeToken<EntitySpec<?>>() {})
             .name("on.error.spec")
             .description("Spec of entity to instantiate (and start, if 
startable) if the test-case fails")
-            .parentInheritance(ConfigInheritance.NONE)
+            .runtimeInheritance(ConfigInheritance.NONE)
             .typeInheritance(ConfigInheritance.ALWAYS)
             .build();
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/utils/common/src/main/java/org/apache/brooklyn/config/ConfigInheritance.java
----------------------------------------------------------------------
diff --git 
a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigInheritance.java 
b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigInheritance.java
index 3ff163f..4bdbdda 100644
--- 
a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigInheritance.java
+++ 
b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigInheritance.java
@@ -26,6 +26,9 @@ import com.google.common.annotations.Beta;
 
 @SuppressWarnings("serial")
 public abstract class ConfigInheritance implements Serializable {
+    
+    /** marker interface for inheritance contexts, for keys which can define 
one or more inheritance patterns */
+    public interface ConfigInheritanceContext {}
 
     @Beta
     public enum InheritanceMode {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/utils/common/src/main/java/org/apache/brooklyn/config/ConfigKey.java
----------------------------------------------------------------------
diff --git 
a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigKey.java 
b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigKey.java
index 3b66e98..4426aa8 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigKey.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigKey.java
@@ -19,10 +19,13 @@
 package org.apache.brooklyn.config;
 
 import java.util.Collection;
+import java.util.Map;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import org.apache.brooklyn.config.ConfigInheritance.ConfigInheritanceContext;
+
 import com.google.common.annotations.Beta;
 import com.google.common.base.Predicate;
 import com.google.common.reflect.TypeToken;
@@ -85,20 +88,25 @@ public interface ConfigKey<T> {
 
     /**
      * @return The sub-typing inheritance model, or <code>null</code> for the 
default in any context.
-     */
-    @Nullable ConfigInheritance getTypeInheritance();
+     * @deprecated since 0.10.0 use {@link #getInheritanceByContext()} */
+    @Deprecated @Nullable
+    ConfigInheritance getTypeInheritance();
 
     /**
      * @return The inheritance-from-parent-entities model, or 
<code>null</code> for the default in any context.
-     */
-    @Nullable ConfigInheritance getParentInheritance();
+     * @deprecated since 0.10.0 use {@link #getInheritanceByContext()} */ 
+    @Deprecated @Nullable
+    ConfigInheritance getParentInheritance();
 
     /**
      * @return The inheritance model, or <code>null</code> for the default in 
any context.
-     * @deprecated since 0.10.0; use {@link #getParentInheritance()}.
-     */
-    @Deprecated
-    @Nullable ConfigInheritance getInheritance();
+     * @deprecated since 0.10.0 use {@link #getInheritanceByContext()} */ 
+    @Deprecated @Nullable
+    ConfigInheritance getInheritance();
+    
+    // TODO javadoc
+    @Nullable ConfigInheritance 
getInheritanceByContext(ConfigInheritanceContext context);
+    Map<ConfigInheritanceContext,ConfigInheritance> getInheritanceByContext();
 
     /**
      * @return The predicate constraining the key's value.

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/189677de/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
----------------------------------------------------------------------
diff --git 
a/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
 
b/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
index 95bb76b..71f9aa8 100644
--- 
a/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
+++ 
b/utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableMap.java
@@ -131,9 +131,9 @@ public class MutableMap<K,V> extends LinkedHashMap<K,V> {
         return this;
     }
 
-    /** as {@link #put(Object, Object)} but excluding null values, and fluent 
style */
+    /** as {@link #put(Object, Object)} but excluding null keys and values, 
and fluent style */
     public MutableMap<K,V> addIfNotNull(K key, V value) {
-        if (value!=null) add(key, value);
+        if (key!=null && value!=null) add(key, value);
         return this;
     }
 

Reply via email to