sketch better api, remove deprecation, tidy map interfaces

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

Branch: refs/heads/master
Commit: 5e2b7d4b5df57b004e1cc7ac12ef8d215ccc51a4
Parents: 3e266e6
Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Authored: Tue Sep 20 10:21:28 2016 +0100
Committer: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Committed: Wed Sep 21 16:06:06 2016 +0100

----------------------------------------------------------------------
 .../apache/brooklyn/api/entity/EntityLocal.java |  5 --
 .../ExternalConfigBrooklynPropertiesTest.java   |  2 +-
 .../config/internal/AbstractConfigMapImpl.java  | 24 +++---
 .../brooklyn/core/entity/AbstractEntity.java    |  6 --
 .../core/entity/internal/EntityConfigMap.java   | 77 ++++++--------------
 .../internal/EntityTransientCopyInternal.java   |  7 --
 .../core/internal/BrooklynProperties.java       | 15 ++--
 .../core/internal/BrooklynPropertiesImpl.java   | 10 +--
 .../internal/DeferredBrooklynProperties.java    |  5 +-
 .../brooklyn/core/objs/AdjunctConfigMap.java    |  9 +--
 .../org/apache/brooklyn/config/ConfigMap.java   | 45 ++++++------
 .../util/exceptions/ReferenceWithError.java     |  2 +-
 12 files changed, 78 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/api/src/main/java/org/apache/brooklyn/api/entity/EntityLocal.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/EntityLocal.java 
b/api/src/main/java/org/apache/brooklyn/api/entity/EntityLocal.java
index aeb7249..4e4e75f 100644
--- a/api/src/main/java/org/apache/brooklyn/api/entity/EntityLocal.java
+++ b/api/src/main/java/org/apache/brooklyn/api/entity/EntityLocal.java
@@ -95,11 +95,6 @@ public interface EntityLocal extends Entity {
      * @deprecated in 0.5; use {@link #getConfig(ConfigKey)}
      */
     <T> T getConfig(ConfigKey<T> key, T defaultValue);
-    
-    /**
-     * @deprecated in 0.5; use {@link #getConfig(HasConfigKey)}
-     */
-    <T> T getConfig(HasConfigKey<T> key, T defaultValue);
 
     /**
      * Allow us to subscribe to data from a {@link Sensor} on another entity.

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigBrooklynPropertiesTest.java
----------------------------------------------------------------------
diff --git 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigBrooklynPropertiesTest.java
 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigBrooklynPropertiesTest.java
index afa3b36..d7f09de 100644
--- 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigBrooklynPropertiesTest.java
+++ 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ExternalConfigBrooklynPropertiesTest.java
@@ -126,7 +126,7 @@ public class ExternalConfigBrooklynPropertiesTest extends 
AbstractYamlTest {
         String val1 = props.getConfig(ConfigKeys.newStringConfigKey(property));
         assertEquals(val1, expectedVal);
         
-        DeferredSupplier<?> val2 = (DeferredSupplier<?>) 
props.getRawConfig(ConfigKeys.newStringConfigKey(property));
+        DeferredSupplier<?> val2 = (DeferredSupplier<?>) 
props.getConfigRaw(ConfigKeys.newStringConfigKey(property)).get();
         assertEquals(Tasks.resolveValue(val2, String.class, exec), 
expectedVal);
         
         DeferredSupplier<?> val3 = (DeferredSupplier<?>) 
props.getConfigRaw(ConfigKeys.newStringConfigKey(property), false).get();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
 
b/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
index 26e44b6..eb99157 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
@@ -24,8 +24,9 @@ import java.util.Map;
 import java.util.concurrent.Future;
 
 import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.config.ConfigMap;
 import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
+import org.apache.brooklyn.config.ConfigMap;
+import org.apache.brooklyn.core.config.Sanitizer;
 import org.apache.brooklyn.core.config.StructuredConfigKey;
 import org.apache.brooklyn.core.entity.internal.ConfigMapViewWithStringKeys;
 import org.apache.brooklyn.util.core.flags.TypeCoercions;
@@ -51,19 +52,12 @@ public abstract class AbstractConfigMapImpl implements 
ConfigMap {
         return getConfig(key, null);
     }
     
+    protected abstract <T> T getConfig(ConfigKey<T> key, T defaultValue);
+
     public <T> T getConfig(HasConfigKey<T> key) {
         return getConfig(key.getConfigKey(), null);
     }
     
-    public <T> T getConfig(HasConfigKey<T> key, T defaultValue) {
-        return getConfig(key.getConfigKey(), defaultValue);
-    }
-    
-    @Override @Deprecated
-    public Object getRawConfig(ConfigKey<?> key) {
-        return getConfigRaw(key, true).orNull();
-    }
-    
     @Override
     public Maybe<Object> getConfigLocalRaw(ConfigKey<?> key) {
         return getConfigRaw(key, false);
@@ -113,4 +107,14 @@ public abstract class AbstractConfigMapImpl implements 
ConfigMap {
     public boolean isEmpty() {
         return ownConfig.isEmpty();
     }
+    
+    @Override
+    public String toString() {
+        Map<ConfigKey<?>, Object> sanitizeConfig;
+        synchronized (ownConfig) {
+            sanitizeConfig = Sanitizer.sanitize(ownConfig);
+        }
+        return super.toString()+"[local="+sanitizeConfig+"]";
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/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 0b40e32..750adb2 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
@@ -1304,12 +1304,6 @@ public abstract class AbstractEntity extends 
AbstractBrooklynObject implements E
         return config().get(key);
     }
     
-    @Override
-    @Deprecated
-    public <T> T getConfig(HasConfigKey<T> key, T defaultValue) {
-        return configsInternal.getConfig(key, defaultValue);
-    }
-    
     //don't use groovy defaults for defaultValue as that doesn't implement the 
contract; we need the above
     @Override
     @Deprecated

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
 
b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
index 9014d84..a76a592 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
@@ -60,9 +60,6 @@ public class EntityConfigMap extends AbstractConfigMapImpl {
 
     /** entity against which config resolution / task execution will occur */
     private final AbstractEntity entity;
-    /** config bag cache for local anonymous key lookup */
-    // TODO this could be removed and everything made more like 
AdjunctConfigMap
-    private final ConfigBag ownConfigBag;
 
     public EntityConfigMap(AbstractEntity entity) {
         // Not using ConcurrentMap, because want to (continue to) allow null 
values.
@@ -73,21 +70,8 @@ public class EntityConfigMap extends AbstractConfigMapImpl {
     public EntityConfigMap(AbstractEntity entity, Map<ConfigKey<?>, Object> 
storage) {
         this.entity = checkNotNull(entity, "entity must be specified");
         this.ownConfig = checkNotNull(storage, "storage map must be 
specified");
-        this.ownConfigBag = ConfigBag.newInstance();
     }
     
-    /* These flags are included for documentation.
-     * Changes will require testing.
-     * Note that trying to get a raw inherited value can be problematic
-     * if it is merging resolved values.
-     */
-    final static boolean RESOLVE_AND_COERCE_EXTRACTING_KEYS = true;
-    final static boolean COERCE_DEFAULT_VALUES = true;
-    // TODO We're notifying of config-changed because currently persistence 
needs to know when the
-    // attributeWhenReady is complete (so it can persist the result).
-    // Long term, we'll just persist tasks properly so the call to 
onConfigChanged will go!
-    final static boolean NOTIFY_ON_TASK_RESOLUTION = true;
-
     protected static class LocalEvaluateKeyValue<T> implements 
Function<Entity,Maybe<T>> {
         ConfigKey<T> keyIgnoringInheritance;
         
@@ -100,28 +84,32 @@ public class EntityConfigMap extends AbstractConfigMapImpl 
{
             ExecutionContext exec = 
((EntityInternal)entity).getExecutionContext();
             ConfigMap configMap = 
((ConfigurationSupportInternal)entity.config()).getInternalConfigMap();
             Map<ConfigKey<?>,Object> ownConfig = 
((EntityConfigMap)configMap).ownConfig;
-            ConfigBag ownConfigBag = ((EntityConfigMap)configMap).ownConfigBag;
             Maybe<Object> rawValue = 
configMap.getConfigLocalRaw(keyIgnoringInheritance);
             Maybe<T> ownValue;
             
             // Get own value
-            if (RESOLVE_AND_COERCE_EXTRACTING_KEYS && keyIgnoringInheritance 
instanceof ConfigKeySelfExtracting && 
((ConfigKeySelfExtracting<T>)keyIgnoringInheritance).isSet(ownConfig)) {
-                Map<ConfigKey<?>, ?> ownCopy;
-                synchronized (ownConfig) {
-                    // TODO wasteful to make a copy to look up; maybe try once 
opportunistically?
-                    ownCopy = MutableMap.copyOf(ownConfig);
+            if (keyIgnoringInheritance instanceof ConfigKeySelfExtracting) {
+                if 
(((ConfigKeySelfExtracting<T>)keyIgnoringInheritance).isSet(ownConfig)) {
+                    Map<ConfigKey<?>, ?> ownCopy;
+                    synchronized (ownConfig) {
+                        // TODO wasteful to make a copy to look up; maybe try 
once opportunistically?
+                        ownCopy = MutableMap.copyOf(ownConfig);
+                    }
+                    ownValue = Maybe.of(((ConfigKeySelfExtracting<T>) 
keyIgnoringInheritance).extractValue(ownCopy, exec));
+                } else {
+                    ownValue = Maybe.<T>absent();
                 }
-                ownValue = Maybe.of(((ConfigKeySelfExtracting<T>) 
keyIgnoringInheritance).extractValue(ownCopy, exec));
-            } else if (ownConfigBag.containsKey(keyIgnoringInheritance)) {
-                // TODO configBag.get doesn't handle tasks/attributeWhenReady 
- it only uses TypeCoercions
-                // Precedence ordering has changed; previously we'd prefer an 
explicit isSet(inheritedConfig)
-                // over the localConfigBag.get(key).
-                ownValue = Maybe.of(ownConfigBag.get(keyIgnoringInheritance));
             } else {
+                // all our keys are self-extracting
+                LOG.warn("Unexpected key type "+keyIgnoringInheritance+" 
("+keyIgnoringInheritance.getClass()+") in "+entity+"; ignoring value");
                 ownValue = Maybe.<T>absent();
             }
-            
-            if (NOTIFY_ON_TASK_RESOLUTION && rawValue.isPresent() && 
(rawValue.get() instanceof Task)) {
+
+            // TEMPORARY CODE
+            // We're notifying of config-changed because currently persistence 
needs to know when the
+            // attributeWhenReady is complete (so it can persist the result).
+            // Long term, we'll just persist tasks properly so the call to 
onConfigChanged will go!
+            if (rawValue.isPresent() && (rawValue.get() instanceof Task)) {
                 
((EntityInternal)entity).getManagementSupport().getEntityChangeListener().onConfigChanged(keyIgnoringInheritance);
             }
             
@@ -152,7 +140,7 @@ public class EntityConfigMap extends AbstractConfigMapImpl {
         } else {
             LOG.warn("Config key {} of {} is not a ConfigKeySelfExtracting; 
cannot retrieve value; returning default", ownKey, this);
         }
-        return COERCE_DEFAULT_VALUES ? TypeCoercions.coerce(defaultValue, 
key.getTypeToken()) : defaultValue;
+        return TypeCoercions.coerce(defaultValue, key.getTypeToken());
     }
 
     private ConfigInheritance getDefaultRuntimeInheritance() {
@@ -186,8 +174,7 @@ public class EntityConfigMap extends AbstractConfigMapImpl {
     /** Creates an immutable copy of the config visible at this entity, local 
and inherited (preferring local), including those that did not match config 
keys */
     // TODO deprecate because key inheritance not respected
     public ConfigBag getAllConfigBag() {
-        ConfigBag result = ConfigBag.newInstanceCopying(ownConfigBag)
-                .putAll(ownConfig);
+        ConfigBag result = ConfigBag.newInstance().putAll(ownConfig);
         if (entity.getParent()!=null) {
             result.putIfAbsent(
                 ((EntityConfigMap) 
((BrooklynObjectInternal)entity.getParent()).config().getInternalConfigMap()).getAllConfigBag()
 );
@@ -197,9 +184,7 @@ public class EntityConfigMap extends AbstractConfigMapImpl {
 
     /** Creates an immutable copy of the config defined at this entity, ie not 
inherited, including those that did not match config keys */
     public ConfigBag getLocalConfigBag() {
-        return ConfigBag.newInstanceCopying(ownConfigBag)
-                .putAll(ownConfig)
-                .seal();
+        return ConfigBag.newInstance().putAll(ownConfig).seal();
     }
 
     @SuppressWarnings("unchecked")
@@ -208,13 +193,8 @@ public class EntityConfigMap extends AbstractConfigMapImpl 
{
         Object oldVal;
         if (key instanceof StructuredConfigKey) {
             oldVal = ((StructuredConfigKey)key).applyValueToMap(val, 
ownConfig);
-            // TODO ConfigBag does not handle structured config keys; quick 
fix is to remove (and should also remove any subkeys;
-            // as it stands if someone set string a.b.c in the config bag then 
removed structured key a.b, then got a.b.c they'd get a vale);
-            // long term fix is to support structured config keys in 
ConfigBag, at which point i think we could remove ownConfig altogether
-            ownConfigBag.remove(key);
         } else {
             oldVal = ownConfig.put(key, val);
-            ownConfigBag.put((ConfigKey<Object>)key, v);
         }
         entity.config().refreshInheritedConfigOfChildren();
         return oldVal;
@@ -223,20 +203,17 @@ public class EntityConfigMap extends 
AbstractConfigMapImpl {
     public void setLocalConfig(Map<ConfigKey<?>, ?> vals) {
         synchronized (ownConfig) {
             ownConfig.clear();
-            ownConfigBag.clear();
             ownConfig.putAll(vals);
-            ownConfigBag.putAll(vals);
         }
     }
  
     public void addToLocalBag(Map<String,?> vals) {
-        ownConfigBag.putAll(vals);
+        ConfigBag ownConfigBag = ConfigBag.newInstance().putAll(vals);
         // TODO quick fix for problem that ownConfig can get out of synch
         ownConfig.putAll(ownConfigBag.getAllConfigAsConfigKeyMap());
     }
 
     public void removeFromLocalBag(String key) {
-        ownConfigBag.remove(key);
         ownConfig.remove(key);
     }
 
@@ -254,7 +231,6 @@ public class EntityConfigMap extends AbstractConfigMapImpl {
         if (entity.getParent()!=null) {
             merge(m, ((EntityConfigMap) 
((ConfigurationSupportInternal)entity.getParent().config()).getInternalConfigMap()).submap(filter));
         }
-        m.ownConfigBag.putAll(ownConfig);
         return m;
     }
 
@@ -267,13 +243,4 @@ public class EntityConfigMap extends AbstractConfigMapImpl 
{
         }
     }
 
-    @Override
-    public String toString() {
-        Map<ConfigKey<?>, Object> sanitizeConfig;
-        synchronized (ownConfig) {
-            sanitizeConfig = Sanitizer.sanitize(ownConfig);
-        }
-        return super.toString()+"[local="+sanitizeConfig+"]";
-    }
-    
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java
 
b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java
index 09a8fdf..c462728 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityTransientCopyInternal.java
@@ -84,13 +84,6 @@ public interface EntityTransientCopyInternal {
     TagSupport tags();
     String getCatalogItemId();
 
-    
-    // from entity local
-    
-    @Deprecated <T> T getConfig(ConfigKey<T> key, T defaultValue);
-    @Deprecated <T> T getConfig(HasConfigKey<T> key, T defaultValue);
-
-    
     // from EntityInternal:
     
     @Deprecated EntityConfigMap getConfigMap();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java 
b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java
index 3d0b128..1bed084 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java
@@ -298,15 +298,20 @@ public interface BrooklynProperties extends Map, 
StringConfigMap {
     @Override
     public <T> T getConfig(HasConfigKey<T> key);
 
-    @Override
     public <T> T getConfig(HasConfigKey<T> key, T defaultValue);
 
-    @Override
+    
+    /**
+     * Returns value stored against the given key,
+     * resolved (if it is a Task, possibly blocking), and coerced to the 
appropriate type, 
+     * or given default value if not set, 
+     * unless the default value is null in which case it returns the default.
+     */
     public <T> T getConfig(ConfigKey<T> key, T defaultValue);
 
-    @Override
-    public Object getRawConfig(ConfigKey<?> key);
-    
+    public Maybe<Object> getConfigRaw(ConfigKey<?> key);
+
+    /** Inheritance is ignored here. Preferable to use {@link 
#getConfigRaw(ConfigKey)}. */
     @Override
     public Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean 
includeInherited);
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
 
b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
index d4593b3..9ed6a17 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
@@ -439,19 +439,19 @@ public class BrooklynPropertiesImpl extends LinkedHashMap 
implements BrooklynPro
     }
 
     @Override
-    public Object getRawConfig(ConfigKey<?> key) {
-        return get(key.getName());
+    public Maybe<Object> getConfigRaw(ConfigKey<?> key) {
+        if (containsKey(key.getName())) return Maybe.of(get(key.getName()));
+        return Maybe.absent();
     }
     
     @Override
     public Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean 
includeInherited) {
-        if (containsKey(key.getName())) return Maybe.of(get(key.getName()));
-        return Maybe.absent();
+        return getConfigRaw(key);
     }
 
     @Override
     public Maybe<Object> getConfigLocalRaw(ConfigKey<?> key) {
-        return getConfigRaw(key, false);
+        return getConfigRaw(key);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/DeferredBrooklynProperties.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/DeferredBrooklynProperties.java
 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/DeferredBrooklynProperties.java
index 4e3d342..2495557 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/DeferredBrooklynProperties.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/DeferredBrooklynProperties.java
@@ -126,10 +126,9 @@ public class DeferredBrooklynProperties implements 
BrooklynProperties {
         return resolve(key, raw);
     }
 
-    @Deprecated
     @Override
-    public Object getRawConfig(ConfigKey<?> key) {
-        return transform(key, delegate.getRawConfig(key));
+    public Maybe<Object> getConfigRaw(ConfigKey<?> key) {
+        return getConfigRaw(key, true);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java 
b/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java
index f0b0811..87e602b 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java
@@ -27,7 +27,6 @@ import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.mgmt.ExecutionContext;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.config.Sanitizer;
 import org.apache.brooklyn.core.config.StructuredConfigKey;
 import org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl;
 import org.apache.brooklyn.core.entity.EntityInternal;
@@ -63,8 +62,7 @@ public class AdjunctConfigMap extends AbstractConfigMapImpl {
     }
 
     @SuppressWarnings("unchecked")
-    @Override
-    public <T> T getConfig(ConfigKey<T> key, T defaultValue) {
+    protected <T> T getConfig(ConfigKey<T> key, T defaultValue) {
         // FIXME What about inherited task in config?!
         //              alex says: think that should work, no?
         // FIXME What if someone calls getConfig on a task, before setting 
parent app?
@@ -131,9 +129,4 @@ public class AdjunctConfigMap extends AbstractConfigMapImpl 
{
         return m;
     }
 
-    @Override
-    public String toString() {
-        return super.toString()+"[own="+Sanitizer.sanitize(ownConfig)+"]";
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java
----------------------------------------------------------------------
diff --git 
a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java 
b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java
index 7838b15..933e0e7 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java
@@ -32,30 +32,7 @@ public interface ConfigMap {
     
     /** @see #getConfig(ConfigKey, Object), with default value as per the key, 
or null */
     public <T> T getConfig(HasConfigKey<T> key);
-    
-    /**
-     * @see #getConfig(ConfigKey, Object), with provided default value if not 
set
-     * @deprecated since 0.7.0; use {@link #getConfig(HasConfigKey)}
-     */
-    @Deprecated
-    public <T> T getConfig(HasConfigKey<T> key, T defaultValue);
-    
-    /**
-     * Returns value stored against the given key,
-     * resolved (if it is a Task, possibly blocking), and coerced to the 
appropriate type, 
-     * or given default value if not set, 
-     * unless the default value is null in which case it returns the default.
-     * 
-     * @deprecated since 0.7.0; use {@link #getConfig(ConfigKey)}
-     */
-    @Deprecated
-    public <T> T getConfig(ConfigKey<T> key, T defaultValue);
 
-    /** as {@link #getConfigRaw(ConfigKey)} but returning null if not present 
-     * @deprecated since 0.7.0 use {@link #getConfigRaw(ConfigKey)} */
-    @Deprecated
-    public Object getRawConfig(ConfigKey<?> key);
-    
     /** returns the value stored against the given key, 
      * <b>not</b> any default,
      * <b>not</b> resolved (and guaranteed non-blocking),
@@ -68,6 +45,28 @@ public interface ConfigMap {
      */
     // TODO behaviour of this is undefined if the key specifies a merge
     public Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean 
includeInherited);
+
+    // TODO sketch of new/better implementations
+//    /** As {@link #getConfigLocalRaw(ConfigKey)} but respecting the 
inheritance rules.
+//     * Because inheritance may not be applicable when working with raw 
values the result
+//     * is wrapped in a {@link ReferenceWithError}, and if any aspect of 
inheritance 
+//     * could not be applied, calls to {@link ReferenceWithError#get()} will 
throw
+//     * (but {@link ReferenceWithError#getWithoutError()} will not).
+//     * <p>
+//     * Note that most modes (eg overwrite, not-inherit) will not cause 
issues during inheritance
+//     * so this method is ordinarily fine to use.  Problems arise when a 
merge inheritance mode
+//     * is specified and it is attempting to merge a raw value which is not 
mergeable.
+//     * <p>
+//     * See also {@link #getConfigAllInheritedRaw(ConfigKey)} which returns 
the complete set
+//     * of inherited values.
+//     * 
+//     * @param key  key to look up
+//     */    
+//    public ReferenceWithError<ContainerAndValue<Object>> 
getConfigInheritedRaw(ConfigKey<?> key);
+//
+//    /** As {@link #getConfigLocalRaw(ConfigKey)} but returning all 
containers through the inheritance
+//     * hierarchy where a value is set (but stopping if it encounters a key 
is not inheritable from a container). */
+//    public List<ContainerAndValue<Object>> 
getConfigAllInheritedRaw(ConfigKey<?> key);
     
     /** returns the value stored against the given key, 
      * <b>not</b> any default,

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5e2b7d4b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/ReferenceWithError.java
----------------------------------------------------------------------
diff --git 
a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/ReferenceWithError.java
 
b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/ReferenceWithError.java
index 87fa3f2..95ddd71 100644
--- 
a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/ReferenceWithError.java
+++ 
b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/ReferenceWithError.java
@@ -41,7 +41,7 @@ public class ReferenceWithError<T> implements Supplier<T> {
         return new ReferenceWithError<T>(object, error, true);
     }
     
-    /** returns a reference which includes an error, but attempts to get the 
content do not cause the error to throw */
+    /** returns a reference which does not have any error; attempts to get the 
content are safe */
     public static <T> ReferenceWithError<T> newInstanceWithoutError(T object) {
         return new ReferenceWithError<T>(object, null, false);
     }

Reply via email to