You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:51:04 UTC

[22/51] [abbrv] [partial] brooklyn-server git commit: move subdir from incubator up a level as it is promoted to its own repo (first non-incubator commit!)

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ListConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ListConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ListConfigKey.java
deleted file mode 100644
index 06a29bd..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/ListConfigKey.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.core.config.internal.AbstractCollectionConfigKey;
-import org.apache.brooklyn.core.internal.storage.impl.ConcurrentMapAcceptingNullVals;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** A config key representing a list of values. 
- * If a value is set on this key, it is _added_ to the list.
- * (With a warning is issued if a collection is passed in.)
- * If a value is set against an equivalent *untyped* key which *is* a collection,
- * it will be treated as a list upon discovery and used as a base to which subkey values are appended.
- * If a value is discovered against this key which is not a map or collection,
- * it is ignored.
- * <p>
- * To add all items in a collection, to add a collection as a single element, 
- * to clear the list, or to set a collection (clearing first), 
- * use the relevant {@link ListModification} in {@link ListModifications}.
- * <p>  
- * Specific values can be added in a replaceable way by referring to a subkey.
- * 
- * @deprecated since 0.6; use SetConfigKey. 
- * The ListConfigKey does not guarantee order when subkeys are used,
- * due to distribution and the use of the {@link ConcurrentMapAcceptingNullVals} 
- * as a backing store.
- * However the class will likely be kept around with tests for the time being
- * as we would like to repair this.
- */
-//TODO Create interface
-@Deprecated
-public class ListConfigKey<V> extends AbstractCollectionConfigKey<List<? extends V>,List<Object>,V> {
-
-    private static final long serialVersionUID = 751024268729803210L;
-    @SuppressWarnings("unused")
-    private static final Logger log = LoggerFactory.getLogger(ListConfigKey.class);
-    
-    public ListConfigKey(Class<V> subType, String name) {
-        this(subType, name, name, null);
-    }
-
-    public ListConfigKey(Class<V> subType, String name, String description) {
-        this(subType, name, description, null);
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public ListConfigKey(Class<V> subType, String name, String description, List<? extends V> defaultValue) {
-        super((Class)List.class, subType, name, description, (List<V>)defaultValue);
-    }
-
-    @Override
-    protected List<Object> merge(boolean unmodifiable, Iterable<?>... sets) {
-        MutableList<Object> result = MutableList.of();
-        for (Iterable<?> set: sets) result.addAll(set);
-        if (unmodifiable) return result.asUnmodifiable();
-        return result;
-    }
-
-    public interface ListModification<T> extends StructuredModification<ListConfigKey<T>>, List<T> {
-    }
-    
-    public static class ListModifications extends StructuredModifications {
-        /** when passed as a value to a ListConfigKey, causes each of these items to be added.
-         * if you have just one, no need to wrap in a mod. */
-        // to prevent confusion (e.g. if a list is passed) we require two objects here.
-        public static final <T> ListModification<T> add(final T o1, final T o2, final T ...oo) {
-            List<T> l = new ArrayList<T>();
-            l.add(o1); l.add(o2);
-            for (T o: oo) l.add(o);
-            return new ListModificationBase<T>(l, false);
-        }
-        /** when passed as a value to a ListConfigKey, causes each of these items to be added */
-        public static final <T> ListModification<T> addAll(final Collection<T> items) { 
-            return new ListModificationBase<T>(items, false);
-        }
-        /** when passed as a value to a ListConfigKey, causes the items to be added as a single element in the list */
-        public static final <T> ListModification<T> addItem(final T item) {
-            return new ListModificationBase<T>(Collections.singletonList(item), false);
-        }
-        /** when passed as a value to a ListConfigKey, causes the list to be cleared and these items added */
-        public static final <T> ListModification<T> set(final Collection<T> items) { 
-            return new ListModificationBase<T>(items, true);
-        }
-    }
-
-    public static class ListModificationBase<T> extends ArrayList<T> implements ListModification<T> {
-        private static final long serialVersionUID = 7131812294560446235L;
-        private final boolean clearFirst;
-        public ListModificationBase(Collection<T> delegate, boolean clearFirst) {
-            super(delegate);
-            this.clearFirst = clearFirst;
-        }
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        @Override
-        public Object applyToKeyInMap(ListConfigKey<T> key, Map target) {
-            if (clearFirst) {
-                StructuredModification<StructuredConfigKey> clearing = StructuredModifications.clearing();
-                clearing.applyToKeyInMap(key, target);
-            }
-            for (T o: this) target.put(key.subKey(), o);
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java
deleted file mode 100644
index 96216ff..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/MapConfigKey.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutionException;
-
-import org.apache.brooklyn.api.mgmt.ExecutionContext;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.internal.AbstractStructuredConfigKey;
-import org.apache.brooklyn.util.collections.Jsonya;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Supplier;
-import com.google.common.collect.Maps;
-
-/** A config key which represents a map, where contents can be accessed directly via subkeys.
- * Items added directly to the map must be of type map, and can be updated by:
- * <ul>
- * <li>Putting individual subkeys ({@link SubElementConfigKey})
- * <li>Passing an an appropriate {@link MapModification} from {@link MapModifications}
- *      to clear, clear-and-set, or update
- * <li>Setting a value against a dot-extension of the key
- *     (e.g. setting <code>a.map.subkey=1</code> will cause getConfig(a.map[type=MapConfigKey])
- *     to return {subkey=1}; but note the above are preferred where possible)  
- * <li>Setting a map directly against the MapConfigKey (but note that the above are preferred where possible)
- * </ul>
- */
-//TODO Create interface
-public class MapConfigKey<V> extends AbstractStructuredConfigKey<Map<String,V>,Map<String,Object>,V> {
-    
-    private static final long serialVersionUID = -6126481503795562602L;
-    private static final Logger log = LoggerFactory.getLogger(MapConfigKey.class);
-    
-    public MapConfigKey(Class<V> subType, String name) {
-        this(subType, name, name, null);
-    }
-
-    public MapConfigKey(Class<V> subType, String name, String description) {
-        this(subType, name, description, null);
-    }
-
-    // TODO it isn't clear whether defaultValue is an initialValue, or a value to use when map is empty
-    // probably the latter, currently ... but maybe better to say that map configs are never null, 
-    // and defaultValue is really an initial value?
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public MapConfigKey(Class<V> subType, String name, String description, Map<String, V> defaultValue) {
-        super((Class)Map.class, subType, name, description, defaultValue);
-    }
-
-    public ConfigKey<V> subKey(String subName) {
-        return super.subKey(subName);
-    }
-    public ConfigKey<V> subKey(String subName, String description) {
-        return super.subKey(subName, description);
-    }   
-
-    @SuppressWarnings("unchecked")
-    @Override
-    protected Map<String, Object> extractValueMatchingThisKey(Object potentialBase, ExecutionContext exec, boolean coerce) throws InterruptedException, ExecutionException {
-        if (coerce) {
-            potentialBase = resolveValue(potentialBase, exec);
-        }
-
-        if (potentialBase==null) return null;
-        if (potentialBase instanceof Map<?,?>) {
-            return Maps.<String,Object>newLinkedHashMap( (Map<String,Object>) potentialBase);
-        }
-        log.warn("Unable to extract "+getName()+" as Map; it is "+potentialBase.getClass().getName()+" "+potentialBase);
-        return null;
-    }
-    
-    @Override
-    protected Map<String, Object> merge(Map<String, Object> base, Map<String, Object> subkeys, boolean unmodifiable) {
-        Map<String, Object> result = MutableMap.copyOf(base).add(subkeys);
-        if (unmodifiable) result = Collections.unmodifiableMap(result);
-        return result;
-    }
-    
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Override
-    public Object applyValueToMap(Object value, Map target) {
-        if (value == null)
-            return null;
-        if (value instanceof StructuredModification)
-            return ((StructuredModification)value).applyToKeyInMap(this, target);
-        if (value instanceof Map.Entry)
-            return applyEntryValueToMap((Map.Entry)value, target);
-        if (!(value instanceof Map)) 
-            throw new IllegalArgumentException("Cannot set non-map entries "+value+" on "+this);
-        
-        Map result = new MutableMap();
-        for (Object entry: ((Map)value).entrySet()) {
-            Map.Entry entryT = (Map.Entry)entry;
-            result.put(entryT.getKey(), applyEntryValueToMap(entryT, target));
-        }
-        if (((Map)value).isEmpty() && !isSet(target))
-            target.put(this, MutableMap.of());
-        return result;
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected Object applyEntryValueToMap(Entry value, Map target) {
-        Object k = value.getKey();
-        if (acceptsSubkeyStronglyTyped(k)) {
-            // do nothing
-        } else if (k instanceof ConfigKey<?>) {
-            k = subKey( ((ConfigKey<?>)k).getName() );
-        } else if (k instanceof String) {
-            k = subKey((String)k);
-        } else {
-            // supplier or other unexpected value
-            if (k instanceof Supplier) {
-                Object mapAtRoot = target.get(this);
-                if (mapAtRoot==null) {
-                    mapAtRoot = new LinkedHashMap();
-                    target.put(this, mapAtRoot);
-                }
-                // TODO above is not thread-safe, and below is assuming synching on map 
-                // is the best way to prevent CME's, which is often but not always true
-                if (mapAtRoot instanceof Map) {
-                    if (mapAtRoot instanceof ConcurrentMap) {
-                        return ((Map)mapAtRoot).put(k, value.getValue());
-                    } else {
-                        synchronized (mapAtRoot) {
-                            return ((Map)mapAtRoot).put(k, value.getValue());
-                        }
-                    }
-                }
-            }
-            log.warn("Unexpected subkey "+k+" being inserted into "+this+"; ignoring");
-            k = null;
-        }
-        if (k!=null)
-            return target.put(k, value.getValue());
-        else 
-            return null;
-    }
-
-    public interface MapModification<V> extends StructuredModification<MapConfigKey<V>>, Map<String,V> {
-    }
-    
-    public static class MapModifications extends StructuredModifications {
-        /** when passed as a value to a MapConfigKey, causes each of these items to be put 
-         * (this Mod is redundant as no other value is really sensible) */
-        public static final <V> MapModification<V> put(final Map<String,V> itemsToPutInMapReplacing) { 
-            return new MapModificationBase<V>(itemsToPutInMapReplacing, false);
-        }
-        /** when passed as a value to a MapConfigKey, causes the map to be cleared and these items added */
-        public static final <V> MapModification<V> set(final Map<String,V> itemsToPutInMapAfterClearing) {
-            return new MapModificationBase<V>(itemsToPutInMapAfterClearing, true);
-        }
-        /** when passed as a value to a MapConfigKey, causes the items to be added to the underlying map
-         * using {@link Jsonya} add semantics (combining maps and lists) */
-        public static final <V> MapModification<V> add(final Map<String,V> itemsToAdd) {
-            return new MapModificationBase<V>(itemsToAdd, false /* ignored */) {
-                private static final long serialVersionUID = 1L;
-                @SuppressWarnings("rawtypes")
-                @Override
-                public Object applyToKeyInMap(MapConfigKey<V> key, Map target) {
-                    return key.applyValueToMap(Jsonya.of(key.rawValue(target)).add(this).getRootMap(), target);
-                }
-            };
-        }
-    }
-
-    public static class MapModificationBase<V> extends LinkedHashMap<String,V> implements MapModification<V> {
-        private static final long serialVersionUID = -1670820613292286486L;
-        private final boolean clearFirst;
-        public MapModificationBase(Map<String,V> delegate, boolean clearFirst) {
-            super(delegate);
-            this.clearFirst = clearFirst;
-        }
-        @SuppressWarnings({ "rawtypes" })
-        @Override
-        public Object applyToKeyInMap(MapConfigKey<V> key, Map target) {
-            if (clearFirst) {
-                StructuredModification<StructuredConfigKey> clearing = StructuredModifications.clearing();
-                clearing.applyToKeyInMap(key, target);
-            }
-            return key.applyValueToMap(new LinkedHashMap<String,V>(this), target);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/Sanitizer.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/Sanitizer.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/Sanitizer.java
deleted file mode 100644
index 59ca6af..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/Sanitizer.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.util.core.config.ConfigBag;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-public final class Sanitizer {
-
-    /**
-     * Names that, if they appear anywhere in an attribute/config/field
-     * indicates that it may be private, so should not be logged etc.
-     */
-    public static final List<String> SECRET_NAMES = ImmutableList.of(
-            "password", 
-            "passwd", 
-            "credential", 
-            "secret", 
-            "private",
-            "access.cert", 
-            "access.key");
-
-    public static final Predicate<Object> IS_SECRET_PREDICATE = new IsSecretPredicate();
-
-    private static class IsSecretPredicate implements Predicate<Object> {
-        @Override
-        public boolean apply(Object name) {
-            String lowerName = name.toString().toLowerCase();
-            for (String secretName : SECRET_NAMES) {
-                if (lowerName.contains(secretName))
-                    return true;
-            }
-            return false;
-        }
-    };
-
-    /**
-     * Kept only in case this anonymous inner class has made it into any persisted state.
-     * 
-     * @deprecated since 0.7.0
-     */
-    @Deprecated
-    @SuppressWarnings("unused")
-    private static final Predicate<Object> IS_SECRET_PREDICATE_DEPRECATED = new Predicate<Object>() {
-        @Override
-        public boolean apply(Object name) {
-            String lowerName = name.toString().toLowerCase();
-            for (String secretName : SECRET_NAMES) {
-                if (lowerName.contains(secretName))
-                    return true;
-            }
-            return false;
-        }
-    };
-
-    public static Sanitizer newInstance(Predicate<Object> sanitizingNeededCheck) {
-        return new Sanitizer(sanitizingNeededCheck);
-    }
-    
-    public static Sanitizer newInstance(){
-        return newInstance(IS_SECRET_PREDICATE);
-    }
-
-    public static Map<String, Object> sanitize(ConfigBag input) {
-        return sanitize(input.getAllConfig());
-    }
-
-    public static <K> Map<K, Object> sanitize(Map<K, ?> input) {
-        return sanitize(input, Sets.newHashSet());
-    }
-
-    static <K> Map<K, Object> sanitize(Map<K, ?> input, Set<Object> visited) {
-        return newInstance().apply(input, visited);
-    }
-    
-    private Predicate<Object> predicate;
-
-    private Sanitizer(Predicate<Object> sanitizingNeededCheck) {
-        predicate = sanitizingNeededCheck;
-    }
-
-    public <K> Map<K, Object> apply(Map<K, ?> input) {
-        return apply(input, Sets.newHashSet());
-    }
-
-    private <K> Map<K, Object> apply(Map<K, ?> input, Set<Object> visited) {
-        Map<K, Object> result = Maps.newLinkedHashMap();
-        for (Map.Entry<K, ?> e : input.entrySet()) {
-            if (predicate.apply(e.getKey())){
-                result.put(e.getKey(), "xxxxxxxx");
-                continue;
-            } 
-            
-            // need to compare object reference, not equality since we may miss some.
-            // not a perfect identifier, but very low probability of collision.
-            if (visited.contains(System.identityHashCode(e.getValue()))) {
-                result.put(e.getKey(), e.getValue());
-                continue;
-            }
-
-            visited.add(System.identityHashCode(e.getValue()));
-            if (e.getValue() instanceof Map) {
-                result.put(e.getKey(), apply((Map<?, ?>) e.getValue(), visited));
-            } else if (e.getValue() instanceof List) {
-                result.put(e.getKey(), applyList((List<?>) e.getValue(), visited));
-            } else if (e.getValue() instanceof Set) {
-                result.put(e.getKey(), applySet((Set<?>) e.getValue(), visited));
-            } else {
-                result.put(e.getKey(), e.getValue());
-            }
-        }
-        return result;
-    }
-    
-    private List<Object> applyIterable(Iterable<?> input, Set<Object> visited){
-        List<Object> result = Lists.newArrayList();
-        for(Object o : input){
-            if(visited.contains(System.identityHashCode(o))){
-                result.add(o);
-                continue;
-            }
-
-            visited.add(System.identityHashCode(o));
-            if (o instanceof Map) {
-                result.add(apply((Map<?, ?>) o, visited));
-            } else if (o instanceof List) {
-                result.add(applyList((List<?>) o, visited));
-            } else if (o instanceof Set) {
-                result.add(applySet((Set<?>) o, visited));
-            } else {
-                result.add(o);
-            }
-
-        }
-        return result;
-    }
-    
-    private List<Object> applyList(List<?> input, Set<Object> visited) {
-       return applyIterable(input, visited);
-    }
-    
-    private Set<Object> applySet(Set<?> input, Set<Object> visited) {
-        Set<Object> result = Sets.newLinkedHashSet();
-        result.addAll(applyIterable(input, visited));
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SetConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SetConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SetConfigKey.java
deleted file mode 100644
index f199c38..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SetConfigKey.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.core.config.internal.AbstractCollectionConfigKey;
-import org.apache.brooklyn.util.collections.MutableSet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** A config key representing a set of values. 
- * If a value is set using this *typed* key, it is _added_ to the set
- * (with a warning issued if a collection is passed in).
- * If a value is set against an equivalent *untyped* key which *is* a collection,
- * it will be treated as a set upon discovery and used as a base to which subkey values are added.
- * If a value is discovered against this key which is not a map or collection,
- * it is ignored.
- * <p>
- * To add all items in a collection, to add a collection as a single element, 
- * to clear the list, or to set a collection (clearing first), 
- * use the relevant {@link SetModification} in {@link SetModifications}.
- * <p>  
- * Specific values can be added in a replaceable way by referring to a subkey.
- */
-//TODO Create interface
-public class SetConfigKey<V> extends AbstractCollectionConfigKey<Set<? extends V>, Set<Object>, V> {
-
-    private static final long serialVersionUID = 751024268729803210L;
-    @SuppressWarnings("unused")
-    private static final Logger log = LoggerFactory.getLogger(SetConfigKey.class);
-
-    public SetConfigKey(Class<V> subType, String name) {
-        this(subType, name, name, null);
-    }
-
-    public SetConfigKey(Class<V> subType, String name, String description) {
-        this(subType, name, description, null);
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public SetConfigKey(Class<V> subType, String name, String description, Set<? extends V> defaultValue) {
-        super((Class)Set.class, subType, name, description, defaultValue);
-    }
-
-    @Override
-    protected Set<Object> merge(boolean unmodifiable, Iterable<?>... sets) {
-        MutableSet<Object> result = MutableSet.of();
-        for (Iterable<?> set: sets) result.addAll(set);
-        if (unmodifiable) return result.asUnmodifiable();
-        return result;
-    }
-    
-    public interface SetModification<T> extends StructuredModification<SetConfigKey<T>>, Set<T> {
-    }
-    
-    public static class SetModifications extends StructuredModifications {
-        /** when passed as a value to a SetConfigKey, causes each of these items to be added.
-         * if you have just one, no need to wrap in a mod. */
-        // to prevent confusion (e.g. if a set is passed) we require two objects here.
-        public static final <T> SetModification<T> add(final T o1, final T o2, final T ...oo) {
-            Set<T> l = new LinkedHashSet<T>();
-            l.add(o1); l.add(o2);
-            for (T o: oo) l.add(o);
-            return new SetModificationBase<T>(l, false);
-        }
-        /** when passed as a value to a SetConfigKey, causes each of these items to be added */
-        public static final <T> SetModification<T> addAll(final Collection<T> items) { 
-            return new SetModificationBase<T>(items, false);
-        }
-        /** when passed as a value to a SetConfigKey, causes the items to be added as a single element in the set */
-        public static final <T> SetModification<T> addItem(final T item) {
-            return new SetModificationBase<T>(Collections.singleton(item), false);
-        }
-        /** when passed as a value to a SetConfigKey, causes the set to be cleared and these items added */
-        public static final <T> SetModification<T> set(final Collection<T> items) { 
-            return new SetModificationBase<T>(items, true);
-        }
-    }
-
-    public static class SetModificationBase<T> extends LinkedHashSet<T> implements SetModification<T> {
-        private static final long serialVersionUID = 2715025591272457705L;
-        private final boolean clearFirst;
-        public SetModificationBase(Collection<T> delegate, boolean clearFirst) {
-            super(delegate);
-            this.clearFirst = clearFirst;
-        }
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        @Override
-        public Object applyToKeyInMap(SetConfigKey<T> key, Map target) {
-            if (clearFirst) {
-                StructuredModification<StructuredConfigKey> clearing = StructuredModifications.clearing();
-                clearing.applyToKeyInMap(key, target);
-            }
-            for (T o: this) target.put(key.subKey(), o);
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/StructuredConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/StructuredConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/StructuredConfigKey.java
deleted file mode 100644
index 7384b45..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/StructuredConfigKey.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config;
-
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-public interface StructuredConfigKey {
-    
-    /** for internal use */
-    Object applyValueToMap(Object value, @SuppressWarnings("rawtypes") Map target);
-    
-    boolean acceptsKeyMatch(Object contender);
-    boolean acceptsSubkey(Object contender);
-    boolean acceptsSubkeyStronglyTyped(Object contender);
-
-    public static class StructuredModifications {
-        /** when passed as a value to a StructuredConfigKey, causes the structure to be cleared */
-        @SuppressWarnings("unchecked")
-        public static final <U extends StructuredConfigKey,T extends StructuredModification<U>> T clearing() {
-            return (T) new StructuredModification<U>() {
-                @SuppressWarnings("rawtypes")
-                @Override
-                public Object applyToKeyInMap(U key, Map target) {
-                    Set keysToRemove = new LinkedHashSet();
-                    for (Object k : target.keySet()) {
-                        if (key.acceptsKeyMatch(k) || key.acceptsSubkey(k))
-                            keysToRemove.add(k);
-                    }
-                    for (Object k : keysToRemove) {
-                        target.remove(k);
-                    }
-                    return null;
-                }
-            };
-        }
-    }
-    
-    public interface StructuredModification<T extends StructuredConfigKey> {
-        Object applyToKeyInMap(T key, @SuppressWarnings("rawtypes") Map target);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SubElementConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SubElementConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SubElementConfigKey.java
deleted file mode 100644
index 1c0b525..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/SubElementConfigKey.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.mgmt.ExecutionContext;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-
-@SuppressWarnings("rawtypes")
-public class SubElementConfigKey<T> extends BasicConfigKey<T> {
-    
-    private static final long serialVersionUID = -1587240876351450665L;
-    
-    public final ConfigKey parent;
-
-    public SubElementConfigKey(ConfigKey parent, Class<T> type, String name) {
-        this(parent, type, name, name, null);
-    }
-    public SubElementConfigKey(ConfigKey parent, Class<T> type, String name, String description) {
-        this(parent, type, name, description, null);
-    }
-    public SubElementConfigKey(ConfigKey parent, Class<T> type, String name, String description, T defaultValue) {
-        super(type, name, description, defaultValue);
-        this.parent = parent;
-    }
-    
-    @SuppressWarnings("unchecked")
-    @Override
-    public T extractValue(Map vals, ExecutionContext exec) {
-        if (vals.containsKey(this)) return super.extractValue(vals, exec);
-        if (parent instanceof StructuredConfigKey) {
-            // look for subkey in map at parent, in the event that the parent was set as an unstructured key
-            Object parentVals = vals.get(parent);
-            if (parentVals instanceof Map) {
-                String subName = getName().substring(parent.getName().length()+1);
-                if ( ((Map) parentVals).containsKey(subName) ) {
-                    try {
-                        return (T) resolveValue( ((Map) parentVals).get(subName), exec );
-                    } catch (Exception e) { throw Exceptions.propagate(e); }
-                }
-            }
-        }
-        return null;
-    }
-    
-    @Override
-    public boolean isSet(Map<?,?> vals) {
-        if (super.isSet(vals)) return true;
-        if (parent instanceof StructuredConfigKey) {
-            // look for subkey in map at parent, in the event that the parent was set as an unstructured key
-            Object parentVals = vals.get(parent);
-            if (parentVals instanceof Map) {
-                String subName = getName().substring(parent.getName().length()+1);
-                if ( ((Map) parentVals).containsKey(subName) ) return true;
-            }
-        }
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/WrappedConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/WrappedConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/WrappedConfigKey.java
deleted file mode 100644
index 0f09ccd..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/WrappedConfigKey.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config;
-
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
-
-import com.google.common.base.Preconditions;
-
-public class WrappedConfigKey<T> implements HasConfigKey<T> {
-
-    private final ConfigKey<T> key;
-    
-    public WrappedConfigKey(ConfigKey<T> key) {
-        this.key = Preconditions.checkNotNull(key);
-    }
-
-    @Override
-    public ConfigKey<T> getConfigKey() {
-        return key;
-    }
-
-    @Override
-    public String toString() {
-        return key.toString()+"(wrapped)";
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/AbstractExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/AbstractExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/AbstractExternalConfigSupplier.java
deleted file mode 100644
index 18b25eb..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/AbstractExternalConfigSupplier.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-
-
-/**
- * Default superclass for all {@link ExternalConfigSupplier} implementations.
- */
-abstract public class AbstractExternalConfigSupplier implements ExternalConfigSupplier {
-
-    private final ManagementContext managementContext;
-    private final String name;
-
-    protected AbstractExternalConfigSupplier(ManagementContext managementContext, String name) {
-        this.managementContext = managementContext;
-        this.name = name;
-    }
-
-    public ManagementContext getManagementContext() {
-        return managementContext;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/ExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/ExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/ExternalConfigSupplier.java
deleted file mode 100644
index c43f7ed..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/ExternalConfigSupplier.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Provider of "externalised" entity configuration that is resolved at runtime.
- *
- * @since 0.8.0
- */
-@Beta
-public interface ExternalConfigSupplier {
-
-    String getName();
-    String get(String key);
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/InPlaceExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/InPlaceExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/InPlaceExternalConfigSupplier.java
deleted file mode 100644
index a5445e9..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/InPlaceExternalConfigSupplier.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-
-
-/**
- * Instances are populated via sub-keys specified directly in the <tt>brooklyn.properties</tt> file:
- *
- * <pre>
- * brooklyn.external.foo = brooklyn.management.config.external.InPlaceConfigSupplier
- * brooklyn.external.foo.key1 = value1
- * brooklyn.external.foo.key2 = value2
- * </pre>
- *
- * This will instantiate an <code>InPlaceExternalConfigSupplier</code> populated with values for <code>key1</code>
- * and <code>key2</code>. Note that the <code>brooklyn.external.&lt;name&gt;</code> prefix is stripped.
- */
-public class InPlaceExternalConfigSupplier extends AbstractExternalConfigSupplier {
-
-    private final Map<String, String> config;
-
-    public InPlaceExternalConfigSupplier(ManagementContext managementContext, String name, Map<String, String> config) {
-        super(managementContext, name);
-        this.config = config;
-    }
-
-    public String get(String key) {
-        return config.get(key);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/PropertiesFileExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/PropertiesFileExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/PropertiesFileExternalConfigSupplier.java
deleted file mode 100644
index f76cdf6..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/PropertiesFileExternalConfigSupplier.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.util.stream.Streams;
-
-
-/**
- * Instances are populated from a plain java properties file named in the passed <code>config</code> map
- * under the <code>propertiesUrl</code> key:
- *
- * <pre>
- * brooklyn.external.foo = brooklyn.management.config.external.PropertiesFileExternalConfigSupplier
- * brooklyn.external.foo.propertiesUrl = http://brooklyn.example.com/config/foo.properties
- * </pre>
- */
-public class PropertiesFileExternalConfigSupplier extends AbstractExternalConfigSupplier {
-
-    public static final String PROPERTIES_URL = "propertiesUrl";
-
-    private final Properties properties;
-
-    public PropertiesFileExternalConfigSupplier(ManagementContext managementContext, String name, Map<String, String> config) throws IOException {
-        super(managementContext, name);
-        this.properties = loadProperties(config.get(PROPERTIES_URL));
-    }
-
-    public String get(String key) {
-        return properties.getProperty(key);
-    }
-
-    private static Properties loadProperties(String propertiesUrl) throws IOException {
-        InputStream is = null;
-        try {
-            is = new URL(propertiesUrl).openStream();
-            Properties p = new Properties();
-            p.load(is);
-            return p;
-
-        } finally {
-            Streams.closeQuietly(is);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultAppIdExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultAppIdExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultAppIdExternalConfigSupplier.java
deleted file mode 100644
index c71d57a..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultAppIdExternalConfigSupplier.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external.vault;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.text.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.gson.JsonObject;
-
-public class VaultAppIdExternalConfigSupplier extends VaultExternalConfigSupplier {
-
-    private static final Logger LOG = LoggerFactory.getLogger(VaultAppIdExternalConfigSupplier.class);
-
-    public VaultAppIdExternalConfigSupplier(ManagementContext managementContext, String name, Map<String, String> config) {
-        super(managementContext, name, config);
-    }
-
-    protected String initAndLogIn(Map<String, String> config) {
-        List<String> errors = Lists.newArrayListWithCapacity(1);
-        String appId = config.get("appId");
-        if (Strings.isBlank(appId)) errors.add("missing configuration 'appId'");
-        if (!errors.isEmpty()) {
-            String message = String.format("Problem configuration Vault external config supplier '%s': %s",
-                    name, Joiner.on(System.lineSeparator()).join(errors));
-            throw new IllegalArgumentException(message);
-        }
-
-        String userId = getUserId(config);
-
-        LOG.info("Config supplier named {} using Vault at {} appID {} userID {} path {}", new Object[] {
-                name, endpoint, appId, userId, path });
-
-        String path = "v1/auth/app-id/login";
-        ImmutableMap<String, String> requestData = ImmutableMap.of("app_id", appId, "user_id", userId);
-        ImmutableMap<String, String> headers = MINIMAL_HEADERS;
-        JsonObject response = apiPost(path, headers, requestData);
-        return response.getAsJsonObject("auth").get("client_token").getAsString();
-    }
-
-    private String getUserId(Map<String, String> config) {
-        String userId = config.get("userId");
-        if (Strings.isBlank(userId))
-            userId = getUserIdFromMacAddress();
-        return userId;
-    }
-
-    private static String getUserIdFromMacAddress() {
-        byte[] mac;
-        try {
-            InetAddress ip = InetAddress.getLocalHost();
-            NetworkInterface network = NetworkInterface.getByInetAddress(ip);
-            mac = network.getHardwareAddress();
-        } catch (Throwable t) {
-            throw Exceptions.propagate(t);
-        }
-        StringBuilder sb = new StringBuilder();
-        for (byte aMac : mac) {
-            sb.append(String.format("%02x", aMac));
-        }
-        return sb.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultExternalConfigSupplier.java
deleted file mode 100644
index f58dbc5..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultExternalConfigSupplier.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external.vault;
-
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.config.external.AbstractExternalConfigSupplier;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.http.HttpTool;
-import org.apache.brooklyn.util.http.HttpToolResponse;
-import org.apache.brooklyn.util.net.Urls;
-import org.apache.brooklyn.util.text.Strings;
-import org.apache.http.client.HttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-
-public abstract class VaultExternalConfigSupplier extends AbstractExternalConfigSupplier {
-    public static final String CHARSET_NAME = "UTF-8";
-    public static final ImmutableMap<String, String> MINIMAL_HEADERS = ImmutableMap.of(
-            "Content-Type", "application/json; charset=" + CHARSET_NAME,
-            "Accept", "application/json",
-            "Accept-Charset", CHARSET_NAME);
-    private static final Logger LOG = LoggerFactory.getLogger(VaultExternalConfigSupplier.class);
-    protected final Map<String, String> config;
-    protected final String name;
-    protected final HttpClient httpClient;
-    protected final Gson gson;
-    protected final String endpoint;
-    protected final String path;
-    protected final String token;
-    protected final ImmutableMap<String, String> headersWithToken;
-
-    public VaultExternalConfigSupplier(ManagementContext managementContext, String name, Map<String, String> config) {
-        super(managementContext, name);
-        this.config = config;
-        this.name = name;
-        httpClient = HttpTool.httpClientBuilder().build();
-        gson = new GsonBuilder().create();
-
-        List<String> errors = Lists.newArrayListWithCapacity(2);
-        endpoint = config.get("endpoint");
-        if (Strings.isBlank(endpoint)) errors.add("missing configuration 'endpoint'");
-        path = config.get("path");
-        if (Strings.isBlank(path)) errors.add("missing configuration 'path'");
-        if (!errors.isEmpty()) {
-            String message = String.format("Problem configuration Vault external config supplier '%s': %s",
-                    name, Joiner.on(System.lineSeparator()).join(errors));
-            throw new IllegalArgumentException(message);
-        }
-
-        token = initAndLogIn(config);
-        headersWithToken = ImmutableMap.<String, String>builder()
-                .putAll(MINIMAL_HEADERS)
-                .put("X-Vault-Token", token)
-                .build();
-    }
-
-    protected abstract String initAndLogIn(Map<String, String> config);
-
-    @Override
-    public String get(String key) {
-        JsonObject response = apiGet(Urls.mergePaths("v1", path), headersWithToken);
-        return response.getAsJsonObject("data").get(key).getAsString();
-    }
-
-    protected JsonObject apiGet(String path, ImmutableMap<String, String> headers) {
-        try {
-            String uri = Urls.mergePaths(endpoint, path);
-            LOG.debug("Vault request - GET: {}", uri);
-            LOG.debug("Vault request - headers: {}", headers.toString());
-            HttpToolResponse response = HttpTool.httpGet(httpClient, Urls.toUri(uri), headers);
-            LOG.debug("Vault response - code: {} {}", new Object[]{Integer.toString(response.getResponseCode()), response.getReasonPhrase()});
-            LOG.debug("Vault response - headers: {}", response.getHeaderLists().toString());
-            String responseBody = new String(response.getContent(), CHARSET_NAME);
-            LOG.debug("Vault response - body: {}", responseBody);
-            if (HttpTool.isStatusCodeHealthy(response.getResponseCode())) {
-                return gson.fromJson(responseBody, JsonObject.class);
-            } else {
-                throw new IllegalStateException("HTTP request returned error");
-            }
-        } catch (UnsupportedEncodingException e) {
-            throw Exceptions.propagate(e);
-        }
-    }
-
-    protected JsonObject apiPost(String path, ImmutableMap<String, String> headers, ImmutableMap<String, String> requestData) {
-        try {
-            String body = gson.toJson(requestData);
-            String uri = Urls.mergePaths(endpoint, path);
-            LOG.debug("Vault request - POST: {}", uri);
-            LOG.debug("Vault request - headers: {}", headers.toString());
-            LOG.debug("Vault request - body: {}", body);
-            HttpToolResponse response = HttpTool.httpPost(httpClient, Urls.toUri(uri), headers, body.getBytes(CHARSET_NAME));
-            LOG.debug("Vault response - code: {} {}", new Object[]{Integer.toString(response.getResponseCode()), response.getReasonPhrase()});
-            LOG.debug("Vault response - headers: {}", response.getHeaderLists().toString());
-            String responseBody = new String(response.getContent(), CHARSET_NAME);
-            LOG.debug("Vault response - body: {}", responseBody);
-            if (HttpTool.isStatusCodeHealthy(response.getResponseCode())) {
-                return gson.fromJson(responseBody, JsonObject.class);
-            } else {
-                throw new IllegalStateException("HTTP request returned error");
-            }
-        } catch (UnsupportedEncodingException e) {
-            throw Exceptions.propagate(e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultTokenExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultTokenExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultTokenExternalConfigSupplier.java
deleted file mode 100644
index d17aad5..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultTokenExternalConfigSupplier.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external.vault;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.util.text.Strings;
-
-public class VaultTokenExternalConfigSupplier extends VaultExternalConfigSupplier {
-    public VaultTokenExternalConfigSupplier(ManagementContext managementContext, String name, Map<String, String> config) {
-        super(managementContext, name, config);
-    }
-
-    @Override
-    protected String initAndLogIn(Map<String, String> config) {
-        String tokenProperty = config.get("token");
-        checkArgument(Strings.isNonBlank(tokenProperty), "property not set: token");
-        return tokenProperty;
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultUserPassExternalConfigSupplier.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultUserPassExternalConfigSupplier.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultUserPassExternalConfigSupplier.java
deleted file mode 100644
index 15a8576..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/external/vault/VaultUserPassExternalConfigSupplier.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.external.vault;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.util.text.Strings;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.gson.JsonObject;
-
-public class VaultUserPassExternalConfigSupplier extends VaultExternalConfigSupplier {
-    public VaultUserPassExternalConfigSupplier(ManagementContext managementContext, String name, Map<String, String> config) {
-        super(managementContext, name, config);
-    }
-
-    @Override
-    protected String initAndLogIn(Map<String, String> config) {
-        List<String> errors = Lists.newArrayListWithCapacity(2);
-        String username = config.get("username");
-        if (Strings.isBlank(username)) errors.add("missing configuration 'username'");
-        String password = config.get("password");
-        if (Strings.isBlank(username)) errors.add("missing configuration 'password'");
-        if (!errors.isEmpty()) {
-            String message = String.format("Problem configuration Vault external config supplier '%s': %s",
-                    name, Joiner.on(System.lineSeparator()).join(errors));
-            throw new IllegalArgumentException(message);
-        }
-
-        String path = "v1/auth/userpass/login/" + username;
-        ImmutableMap<String, String> requestData = ImmutableMap.of("password", password);
-        ImmutableMap<String, String> headers = MINIMAL_HEADERS;
-        JsonObject response = apiPost(path, headers, requestData);
-        return response.getAsJsonObject("auth").get("client_token").getAsString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractCollectionConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractCollectionConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractCollectionConfigKey.java
deleted file mode 100644
index cc536e8..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractCollectionConfigKey.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.internal;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import org.apache.brooklyn.api.mgmt.ExecutionContext;
-import org.apache.brooklyn.api.mgmt.TaskAdaptable;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.SubElementConfigKey;
-import org.apache.brooklyn.util.collections.MutableSet;
-import org.apache.brooklyn.util.text.Identifiers;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Iterables;
-
-public abstract class AbstractCollectionConfigKey<T, RawT extends Collection<Object>, V> extends AbstractStructuredConfigKey<T, RawT, V> {
-
-    private static final long serialVersionUID = 8225955960120637643L;
-    private static final Logger log = LoggerFactory.getLogger(AbstractCollectionConfigKey.class);
-    
-    public AbstractCollectionConfigKey(Class<T> type, Class<V> subType, String name, String description, T defaultValue) {
-        super(type, subType, name, description, defaultValue);
-    }
-
-    public ConfigKey<V> subKey() {
-        String subName = Identifiers.makeRandomId(8);
-        return new SubElementConfigKey<V>(this, subType, getName()+"."+subName, "element of "+getName()+", uid "+subName, null);
-    }
-
-    protected abstract RawT merge(boolean unmodifiable, Iterable<?> ...items);
-
-    @Override
-    protected RawT merge(RawT base, Map<String, Object> subkeys, boolean unmodifiable) {
-        return merge(unmodifiable, base, subkeys.values());
-    }
-
-    @Override
-    protected RawT extractValueMatchingThisKey(Object potentialBase, ExecutionContext exec, boolean coerce) throws InterruptedException, ExecutionException {
-        if (coerce) {
-            potentialBase = resolveValue(potentialBase, exec);
-        }
-
-        if (potentialBase==null) return null;
-        if (potentialBase instanceof Map<?,?>) {
-            return merge(false, ((Map<?,?>) potentialBase).values() );
-        } else if (potentialBase instanceof Collection<?>) {
-            return merge(false, (Collection<?>) potentialBase );
-        }
-        log.warn("Unable to extract "+getName()+" as Collection; it is "+potentialBase.getClass().getName()+" "+potentialBase);
-        return null;
-    }
-
-    @SuppressWarnings({ "rawtypes" })
-    @Override
-    public Object applyValueToMap(Object value, Map target) {
-        return applyValueToMap(value, target, false);
-    }
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected Object applyValueToMap(Object value, Map target, boolean isInCollection) {
-        if (value instanceof StructuredModification) {
-            return ((StructuredModification)value).applyToKeyInMap(this, target);
-        } else if ((value instanceof Iterable) && (!isInCollection)) {
-            // collections set _here_ (not in subkeys) get added
-            boolean isSet = isSet(target);
-            if (isSet) {
-                String warning = "Discouraged undecorated setting of a collection to in-use StructuredConfigKey "+this+": use SetModification.{set,add}. " +
-                    "Defaulting to 'add'. Look at debug logging for call stack.";
-                log.warn(warning);
-                if (log.isDebugEnabled())
-                    log.debug("Trace for: "+warning, new Throwable("Trace for: "+warning));
-            }
-            Iterable<?> valueI = (Iterable<?>)value;
-            for (Object v: valueI) { 
-                // don't continue to recurse into these collections, however
-                applyValueToMap(v, target, true);
-            }
-            if (Iterables.isEmpty(valueI) && !isSet) {
-                target.put(this, MutableSet.of());
-            }
-            return null;
-        } else if (value instanceof TaskAdaptable) {
-            boolean isSet = isSet(target);
-            if (isSet) {
-                String warning = "Discouraged undecorated setting of a task to in-use StructuredConfigKey "+this+": use SetModification.{set,add}. " +
-                    "Defaulting to 'add'. Look at debug logging for call stack.";
-                log.warn(warning);
-                if (log.isDebugEnabled())
-                    log.debug("Trace for: "+warning, new Throwable("Trace for: "+warning));
-            }
-            // just add to set, using anonymous key
-            target.put(subKey(), value);
-            return null;
-        } else {
-            // just add to set, using anonymous key
-            target.put(subKey(), value);
-            return null;
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
deleted file mode 100644
index fd02fc1..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.internal;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-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.core.config.StructuredConfigKey;
-import org.apache.brooklyn.core.entity.internal.ConfigMapViewWithStringKeys;
-import org.apache.brooklyn.util.core.flags.TypeCoercions;
-import org.apache.brooklyn.util.core.task.DeferredSupplier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractConfigMapImpl implements ConfigMap {
-
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigMapImpl.class);
-    
-    protected final ConfigMapViewWithStringKeys mapViewWithStringKeys = new ConfigMapViewWithStringKeys(this);
-    
-    /**
-     * Map of configuration information that is defined at start-up time for the entity. These
-     * configuration parameters are shared and made accessible to the "children" of this
-     * entity.
-     */
-    protected Map<ConfigKey<?>,Object> ownConfig = Collections.synchronizedMap(new LinkedHashMap<ConfigKey<?>, Object>());
-
-    public <T> T getConfig(ConfigKey<T> key) {
-        return getConfig(key, null);
-    }
-    
-    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();
-    }
-    
-    protected Object coerceConfigVal(ConfigKey<?> key, Object v) {
-        Object val;
-        if ((v instanceof Future) || (v instanceof DeferredSupplier)) {
-            // no coercion for these (coerce on exit)
-            val = v;
-        } else if (key instanceof StructuredConfigKey) {
-            // no coercion for these structures (they decide what to do)
-            val = v;
-        } else if ((v instanceof Map || v instanceof Iterable) && key.getType().isInstance(v)) {
-            // don't do coercion on put for these, if the key type is compatible, 
-            // because that will force resolution deeply
-            val = v;
-        } else {
-            try {
-                // try to coerce on input, to detect errors sooner
-                val = TypeCoercions.coerce(v, key.getTypeToken());
-            } catch (Exception e) {
-                throw new IllegalArgumentException("Cannot coerce or set "+v+" to "+key, e);
-                // if can't coerce, we could just log as below and *throw* the error when we retrieve the config
-                // but for now, fail fast (above), because we haven't encountered strong use cases
-                // where we want to do coercion on retrieval, except for the exceptions above
-//                Exceptions.propagateIfFatal(e);
-//                LOG.warn("Cannot coerce or set "+v+" to "+key+" (ignoring): "+e, e);
-//                val = v;
-            }
-        }
-        return val;
-    }
-
-    
-    @Override
-    public Map<String,Object> asMapWithStringKeys() {
-        return mapViewWithStringKeys;
-    }
-
-    @Override
-    public int size() {
-        return ownConfig.size();
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return ownConfig.isEmpty();
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractStructuredConfigKey.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractStructuredConfigKey.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractStructuredConfigKey.java
deleted file mode 100644
index 8c7c610..0000000
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractStructuredConfigKey.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.config.internal;
-
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import org.apache.brooklyn.api.mgmt.ExecutionContext;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.BasicConfigKey;
-import org.apache.brooklyn.core.config.StructuredConfigKey;
-import org.apache.brooklyn.core.config.SubElementConfigKey;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-
-import com.google.common.collect.Maps;
-
-public abstract class AbstractStructuredConfigKey<T,RawT,V> extends BasicConfigKey<T> implements StructuredConfigKey {
-
-    private static final long serialVersionUID = 7806267541029428561L;
-
-    public final Class<V> subType;
-
-    public AbstractStructuredConfigKey(Class<T> type, Class<V> subType, String name, String description, T defaultValue) {
-        super(type, name, description, defaultValue);
-        this.subType = subType;
-    }
-
-    protected ConfigKey<V> subKey(String subName) {
-        return subKey(subName, "sub-element of " + getName() + ", named " + subName);
-    }
-    // it is not possible to supply default values
-    protected ConfigKey<V> subKey(String subName, String description) {
-        return new SubElementConfigKey<V>(this, subType, getName() + "." + subName, description, null);
-    }   
-
-    protected static String getKeyName(Object contender) {
-        if (contender==null) return null;
-        if (contender instanceof ConfigKey) return ((ConfigKey<?>)contender).getName();
-        return contender.toString();
-    }
-    
-    public boolean acceptsKeyMatch(Object contender) {
-        return (getName().equalsIgnoreCase(getKeyName(contender)));
-    }
-    
-    public boolean acceptsSubkey(Object contender) {
-        return contender!=null && getKeyName(contender).startsWith(getName()+".");        
-    }
-    
-    public String extractSubKeyName(Object o) {
-        String name = getKeyName(o);
-        assert name.startsWith(getName()+".");
-        return name.substring(getName().length() + 1);
-    }
-
-    @Override
-    public boolean acceptsSubkeyStronglyTyped(Object contender) {
-        return (contender instanceof SubElementConfigKey) && 
-            acceptsKeyMatch( ((SubElementConfigKey<?>) contender).parent );
-    }
-    
-    @Override
-    public boolean isSet(Map<?, ?> vals) {
-        if (vals.containsKey(this))
-            return true;
-        for (Object contender : vals.keySet()) {
-            if (acceptsKeyMatch(contender) || acceptsSubkey(contender)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    protected RawT extractValue(Map<?,?> vals, ExecutionContext exec, boolean coerce, boolean unmodifiable) {
-        RawT base = null; 
-        Map<String,Object> subkeys = Maps.newLinkedHashMap();
-        for (Map.Entry<?,?> entry : vals.entrySet()) {
-            Object k = entry.getKey();
-            // we don't resolve the key above because this map is the root map;
-            // deferred values as keys must be at an explicit config key entry
-            
-            if (acceptsKeyMatch(k)) {
-                try {
-                    base = extractValueMatchingThisKey(entry.getValue(), exec, coerce);
-                } catch (Exception e) { throw Exceptions.propagate(e); }
-            }
-            
-            if (acceptsSubkey(k)) {
-                String subKeyName = extractSubKeyName(k);
-                Object value;
-                if (coerce) {
-                    @SuppressWarnings("unchecked")
-                    SubElementConfigKey<V> kk = k instanceof SubElementConfigKey<?> ? 
-                        (SubElementConfigKey<V>) k : (SubElementConfigKey<V>) subKey(subKeyName);
-                    value = kk.extractValue(vals, exec);
-                } else {
-                    value = vals.get(k);
-                }
-                subkeys.put(subKeyName, value);
-            }
-        }
-        return merge(base, subkeys, unmodifiable);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public T extractValue(Map<?,?> vals, ExecutionContext exec) {
-        return (T) extractValue(vals, exec, true, true);
-    }
-
-    /** returns the entries in the map against this config key and any sub-config-keys, without resolving
-     * (like {@link #extractValue(Map, ExecutionContext)} but without resolving/coercing;
-     * useful because values in this "map" are actually stored against {@link SubElementConfigKey}s */
-    public RawT rawValue(Map<?,?> vals) {
-        return extractValue(vals, null, false, false);
-    }
-
-    /** returns value against *this* key, if it is of an acceptable type (ignoring subkeys which are added on top) */
-    protected abstract RawT extractValueMatchingThisKey(Object potentialBase, ExecutionContext exec, boolean coerce) throws InterruptedException, ExecutionException;
-    
-    protected abstract RawT merge(RawT base, Map<String, Object> subkeys, boolean unmodifiable);
-    
-}