brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [2/3] brooklyn-server git commit: Delete EntityFactory
Date Fri, 03 Feb 2017 16:55:07 GMT
Delete EntityFactory

Also:
* refactors tests so that they use memberSpec instead of 
entityFactory.
* adds BlockingEntity.STARTUP_DELAY/SHUTDOWN_DELAY

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

Branch: refs/heads/master
Commit: 0bf373a4ab6af4a5120c1b759a38598fe7761e39
Parents: 4c75815
Author: Aled Sage <aled.sage@gmail.com>
Authored: Mon Jan 30 19:12:40 2017 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Mon Jan 30 19:12:40 2017 +0000

----------------------------------------------------------------------
 .../AbstractConfigurableEntityFactory.java      |  88 -----
 .../factory/BasicConfigurableEntityFactory.java |  77 -----
 .../entity/factory/ClosureEntityFactory.java    |  54 ----
 .../factory/ConfigurableEntityFactory.java      |  33 --
 ...figurableEntityFactoryFromEntityFactory.java |  45 ---
 .../core/entity/factory/EntityFactory.java      |  32 --
 .../factory/EntityFactoryForLocation.java       |  30 --
 .../brooklyn/entity/group/DynamicCluster.java   |  12 -
 .../entity/group/DynamicClusterImpl.java        |  42 +--
 .../brooklyn/entity/group/DynamicFabric.java    |   7 -
 .../entity/group/DynamicFabricImpl.java         |  26 +-
 .../brooklyn/util/core/flags/TypeCoercions.java |  23 --
 .../core/test/entity/BlockingEntity.java        |   5 +
 .../core/test/entity/BlockingEntityImpl.java    |   3 +
 .../entity/group/DynamicClusterTest.java        | 324 +++++++------------
 .../entity/group/DynamicFabricTest.java         | 253 ++++-----------
 16 files changed, 207 insertions(+), 847 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/core/entity/factory/AbstractConfigurableEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/factory/AbstractConfigurableEntityFactory.java b/core/src/main/java/org/apache/brooklyn/core/entity/factory/AbstractConfigurableEntityFactory.java
deleted file mode 100644
index 24a02c7..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/factory/AbstractConfigurableEntityFactory.java
+++ /dev/null
@@ -1,88 +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.entity.factory;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.config.ConfigKey;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractConfigurableEntityFactory<T extends Entity> implements ConfigurableEntityFactory<T>, Serializable {
-    private static final Logger log = LoggerFactory.getLogger(AbstractConfigurableEntityFactory.class);
-    
-    protected final Map config = new LinkedHashMap();
-
-    public AbstractConfigurableEntityFactory(){
-        this(new HashMap());
-    }
-
-    public AbstractConfigurableEntityFactory(Map flags) {
-        this.config.putAll(flags);
-
-    }
-    @Override
-    public AbstractConfigurableEntityFactory<T> configure(Map flags) {
-        config.putAll(flags);
-        return this;
-    }
-
-    @Override
-    public AbstractConfigurableEntityFactory<T> configure(ConfigKey key, Object value) {
-        config.put(key, value);
-        return this;
-    }
-
-    @Override
-    public AbstractConfigurableEntityFactory<T> configure(ConfigKey.HasConfigKey key, Object value) {
-        return setConfig(key.getConfigKey(), value);
-    }
-
-    @Override
-    public AbstractConfigurableEntityFactory<T> setConfig(ConfigKey key, Object value) {
-        return configure(key, value);
-    }
-
-    @Override
-    public AbstractConfigurableEntityFactory<T> setConfig(ConfigKey.HasConfigKey key, Object value) {
-        return configure(key.getConfigKey(), value);
-    }
-
-    public T newEntity(Entity parent){
-        return newEntity(new HashMap(),parent);
-    }
-
-    @Override
-    public T newEntity(Map flags, Entity parent) {
-        Map flags2 = new HashMap();
-        flags2.putAll(config);
-        flags2.putAll(flags);
-        T result = newEntity2(flags2, parent);
-        // we rely increasingly on init, which factory doesn't call; really should remove factories!
-        log.warn("Deprecated legacy compatibility, using factory (init will not be invoked): "+result);
-        return result;
-    }
-
-    public abstract T newEntity2(Map flags, Entity parent);
-}
-

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/core/entity/factory/BasicConfigurableEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/factory/BasicConfigurableEntityFactory.java b/core/src/main/java/org/apache/brooklyn/core/entity/factory/BasicConfigurableEntityFactory.java
deleted file mode 100644
index 32d730b..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/factory/BasicConfigurableEntityFactory.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.entity.factory;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.core.mgmt.persist.DeserializingClassRenamesProvider;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Throwables;
-
-/** @deprecated since 0.7.0; use EntitySpec instead, as per {@link EntityFactory} javadoc */
-@Deprecated
-public class BasicConfigurableEntityFactory<T extends Entity> extends AbstractConfigurableEntityFactory<T> {
-    private transient Class<? extends T> clazz;
-    private final String clazzName;
-
-    public BasicConfigurableEntityFactory(Class<? extends T> clazz) {
-        this(new HashMap(), clazz);
-    }
-
-    public BasicConfigurableEntityFactory(Map flags, Class<? extends T> clazz) {
-        super(flags);
-        this.clazz = checkNotNull(clazz, "clazz");
-        this.clazzName = DeserializingClassRenamesProvider.INSTANCE.findMappedName(clazz.getName());
-    }
-
-    @Override
-    public T newEntity2(Map flags, Entity parent) {
-        try {
-            Constructor<? extends T> constructor = clazz.getConstructor(Map.class, Entity.class);
-            return constructor.newInstance(flags, parent);
-        } catch (InstantiationException e) {
-            throw Throwables.propagate(e);
-        } catch (IllegalAccessException e) {
-            throw Throwables.propagate(e);
-        } catch (InvocationTargetException e) {
-            throw Throwables.propagate(e);
-        } catch (NoSuchMethodException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-    
-    private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
-        s.defaultReadObject();
-        clazz = (Class<T>) getClass().getClassLoader().loadClass(clazzName);
-    }
-    
-    @Override
-    public String toString() {
-        return Objects.toStringHelper(this).add("type", clazzName).toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/core/entity/factory/ClosureEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/factory/ClosureEntityFactory.java b/core/src/main/java/org/apache/brooklyn/core/entity/factory/ClosureEntityFactory.java
deleted file mode 100644
index 5a5e003..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/factory/ClosureEntityFactory.java
+++ /dev/null
@@ -1,54 +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.entity.factory;
-
-import groovy.lang.Closure;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-public class ClosureEntityFactory<T extends Entity> extends AbstractConfigurableEntityFactory<T> {
-    private final Closure<T> closure;
-
-    public ClosureEntityFactory(Closure<T> closure){
-        this(new HashMap(),closure);
-    }
-
-    public ClosureEntityFactory(Map flags, Closure<T> closure) {
-        super(flags);
-        this.closure = closure;
-    }
-
-    @Override
-    public T newEntity2(Map flags, Entity parent) {
-        if (closure.getMaximumNumberOfParameters()>1)
-            return closure.call(flags, parent);
-        else {
-            //leaving out the parent is discouraged
-            T entity = closure.call(flags);
-            if(parent!=null && entity.getParent()==null){
-                entity.setParent(parent);
-            }
-
-            return entity;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactory.java b/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactory.java
deleted file mode 100644
index af5fba3..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactory.java
+++ /dev/null
@@ -1,33 +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.entity.factory;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.config.ConfigKey;
-
-public interface ConfigurableEntityFactory<T extends Entity> extends EntityFactory<T> {
-   ConfigurableEntityFactory<T> configure(Map flags);
-   ConfigurableEntityFactory<T> configure(ConfigKey key, Object value);
-   ConfigurableEntityFactory<T> configure(ConfigKey.HasConfigKey key, Object value);
-   
-   ConfigurableEntityFactory<T> setConfig(ConfigKey key, Object value);
-   ConfigurableEntityFactory<T> setConfig(ConfigKey.HasConfigKey key, Object value);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactoryFromEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactoryFromEntityFactory.java b/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactoryFromEntityFactory.java
deleted file mode 100644
index 1fc36c3..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/factory/ConfigurableEntityFactoryFromEntityFactory.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.entity.factory;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-public class ConfigurableEntityFactoryFromEntityFactory<T extends Entity> extends AbstractConfigurableEntityFactory<T> {
-
-   private final EntityFactory<? extends T> factory;
-
-    public ConfigurableEntityFactoryFromEntityFactory(EntityFactory<? extends T> entityFactory){
-        this(new HashMap(),entityFactory);
-    }
-
-    public ConfigurableEntityFactoryFromEntityFactory(Map flags, EntityFactory<? extends T> factory) {
-        super(flags);
-        this.factory = checkNotNull(factory, "factory");
-    }
-
-    @Override
-    public T newEntity2(Map flags, Entity parent) {
-        return factory.newEntity(flags, parent);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactory.java b/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactory.java
deleted file mode 100644
index 2f4ede7..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactory.java
+++ /dev/null
@@ -1,32 +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.entity.factory;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-/**
- * A Factory for creating entities.
- *
- * @deprecated since 0.7.0; use EntitySpec instead, as the factory does not put the entity through the initialization process */
-@Deprecated
-public interface EntityFactory<T extends Entity> {
-    T newEntity(Map flags, Entity parent);
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactoryForLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactoryForLocation.java b/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactoryForLocation.java
deleted file mode 100644
index 79f72d7..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/factory/EntityFactoryForLocation.java
+++ /dev/null
@@ -1,30 +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.entity.factory;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.Location;
-
-/**
- * dispatch interface to allow an EntityFactory to indicate it might be able to discover
- * other factories for specific locations (e.g. if the location implements a custom entity-aware interface)
- */
-public interface EntityFactoryForLocation<T extends Entity> {
-    ConfigurableEntityFactory<T> newFactoryForLocation(Location l);
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
index 3f62f82..d4bb556 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
@@ -35,7 +35,6 @@ import org.apache.brooklyn.core.annotation.EffectorParam;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.effector.MethodEffector;
 import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.trait.MemberReplaceable;
 import org.apache.brooklyn.core.sensor.BasicAttributeSensor;
@@ -141,13 +140,6 @@ public interface DynamicCluster extends AbstractGroup, Cluster, MemberReplaceabl
             new TypeToken<EntitySpec<?>>() { },
             "dynamiccluster.firstmemberspec", "entity spec for creating new cluster members, used for the very first member if different", null);
 
-    /** @deprecated since 0.7.0; use {@link #MEMBER_SPEC} instead. */
-    @SuppressWarnings("rawtypes")
-    @Deprecated
-    @SetFromFlag("factory")
-    ConfigKey<EntityFactory> FACTORY = ConfigKeys.newConfigKey(
-            EntityFactory.class, "dynamiccluster.factory", "factory for creating new cluster members", null);
-
     @SetFromFlag("removalStrategy")
     ConfigKey<Function<Collection<Entity>, Entity>> REMOVAL_STRATEGY = ConfigKeys.newConfigKey(
             new TypeToken<Function<Collection<Entity>, Entity>>() {},
@@ -227,9 +219,5 @@ public interface DynamicCluster extends AbstractGroup, Cluster, MemberReplaceabl
 
     void setMemberSpec(EntitySpec<?> memberSpec);
 
-    /** @deprecated since 0.7.0; use {@link #setMemberSpec(EntitySpec)} */
-    @Deprecated
-    void setFactory(EntityFactory<?> factory);
-
     Entity addNode(Location loc, Map<?,?> extraFlags);
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
index 4ed0ac0..a207ec6 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
@@ -50,8 +50,6 @@ import org.apache.brooklyn.core.config.render.RendererHints;
 import org.apache.brooklyn.core.effector.Effectors;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityPredicates;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
-import org.apache.brooklyn.core.entity.factory.EntityFactoryForLocation;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic.ServiceProblemsLogic;
@@ -108,6 +106,8 @@ import com.google.common.util.concurrent.MoreExecutors;
  */
 public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicCluster {
 
+    private static final Logger LOG = LoggerFactory.getLogger(DynamicClusterImpl.class);
+
     @SuppressWarnings("serial")
     private static final AttributeSensor<Supplier<Integer>> NEXT_CLUSTER_MEMBER_ID = Sensors.newSensor(new TypeToken<Supplier<Integer>>() {},
             "next.cluster.member.id", "Returns the ID number of the next member to be added");
@@ -153,9 +153,6 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
         RendererHints.register(CLUSTER, RendererHints.namedActionWithUrl("Open", DelegateEntity.EntityUrl.entityUrl()));
     }
 
-
-    private static final Logger LOG = LoggerFactory.getLogger(DynamicClusterImpl.class);
-
     /**
      * Mutex for synchronizing during re-size operations.
      * Sub-classes should use with great caution, to not introduce deadlocks!
@@ -337,24 +334,11 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
         return getConfig(MEMBER_SPEC);
     }
 
-    /** @deprecated since 0.7.0; use {@link #getMemberSpec()} */
-    @Deprecated
-    protected EntityFactory<?> getFactory() {
-        return getConfig(FACTORY);
-    }
-
     @Override
     public void setMemberSpec(EntitySpec<?> memberSpec) {
         setConfigEvenIfOwned(MEMBER_SPEC, memberSpec);
     }
 
-    /** @deprecated since 0.7.0; use {@link #setMemberSpec(EntitySpec)} */
-    @Deprecated
-    @Override
-    public void setFactory(EntityFactory<?> factory) {
-        setConfigEvenIfOwned(FACTORY, factory);
-    }
-
     private Location getLocation(boolean required) {
         Collection<? extends Location> ll = Locations.getLocationsCheckingAncestors(getLocations(), this);
         if (ll.isEmpty()) {
@@ -995,24 +979,12 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
         if (getMembers().isEmpty()) memberSpec = getFirstMemberSpec();
         if (memberSpec == null) memberSpec = getMemberSpec();
         
-        if (memberSpec != null) {
-            EntitySpec<?> specConfigured = EntitySpec.create(memberSpec).configure(flags);
-            if (loc!=null) specConfigured.location(loc);
-            return addChild(specConfigured);
-        }
-
-        EntityFactory<?> factory = getFactory();
-        if (factory == null) {
-            throw new IllegalStateException("No member spec nor entity factory supplied for dynamic cluster "+this);
-        }
-        EntityFactory<?> factoryToUse = (factory instanceof EntityFactoryForLocation) ? ((EntityFactoryForLocation<?>) factory).newFactoryForLocation(loc) : factory;
-        Entity entity = factoryToUse.newEntity(flags, this);
-        if (entity==null) {
-            throw new IllegalStateException("EntityFactory factory routine returned null entity, in "+this);
+        if (memberSpec == null) {
+            throw new IllegalStateException("No member spec supplied for dynamic cluster "+this);
         }
-        if (entity.getParent()==null) entity.setParent(this);
-
-        return entity;
+        EntitySpec<?> specConfigured = EntitySpec.create(memberSpec).configure(flags);
+        if (loc!=null) specConfigured.location(loc);
+        return addChild(specConfigured);
     }
 
     protected List<Entity> pickAndRemoveMembers(int delta) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabric.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabric.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabric.java
index 92b9621..07fea0a 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabric.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabric.java
@@ -25,7 +25,6 @@ import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.config.MapConfigKey;
 import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.sensor.Sensors;
@@ -55,10 +54,6 @@ public interface DynamicFabric extends AbstractGroup, Startable, Fabric {
     ConfigKey<EntitySpec<?>> MEMBER_SPEC = ConfigKeys.newConfigKey(
             new TypeToken<EntitySpec<?>>() {}, "dynamiccfabric.memberspec", "entity spec for creating new cluster members", null);
 
-    @SetFromFlag("factory")
-    ConfigKey<EntityFactory<?>> FACTORY = ConfigKeys.newConfigKey(
-        new TypeToken<EntityFactory<?>>() {}, "dynamicfabric.factory", "factory for creating new cluster members", null);
-
     @SetFromFlag("displayNamePrefix")
     ConfigKey<String> DISPLAY_NAME_PREFIX = ConfigKeys.newStringConfigKey(
             "dynamicfabric.displayNamePrefix", "Display name prefix, for created children");
@@ -77,8 +72,6 @@ public interface DynamicFabric extends AbstractGroup, Startable, Fabric {
 
     public void setMemberSpec(EntitySpec<?> memberSpec);
     
-    public void setFactory(EntityFactory<?> factory);
-    
     public Integer getFabricSize();
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java
index 3148a4e..e9fd58d 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java
@@ -35,8 +35,6 @@ import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.core.effector.Effectors;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
-import org.apache.brooklyn.core.entity.factory.EntityFactoryForLocation;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.core.entity.trait.Changeable;
@@ -85,10 +83,6 @@ public class DynamicFabricImpl extends AbstractGroupImpl implements DynamicFabri
         return getConfig(MEMBER_SPEC);
     }
     
-    protected EntityFactory<?> getFactory() {
-        return getConfig(FACTORY);
-    }
-    
     protected String getDisplayNamePrefix() {
         return getConfig(DISPLAY_NAME_PREFIX);
     }
@@ -103,11 +97,6 @@ public class DynamicFabricImpl extends AbstractGroupImpl implements DynamicFabri
     }
     
     @Override
-    public void setFactory(EntityFactory<?> factory) {
-        setConfigEvenIfOwned(FACTORY, factory);
-    }
-    
-    @Override
     public void start(Collection<? extends Location> locsO) {
         boolean includeInitialChildren = Boolean.TRUE.equals(config().get(INCLUDE_INITIAL_CHILDREN));
         
@@ -285,20 +274,9 @@ public class DynamicFabricImpl extends AbstractGroupImpl implements DynamicFabri
     
     protected Entity createCluster(Location location, Map flags) {
         EntitySpec<?> memberSpec = getMemberSpec();
-        if (memberSpec != null) {
-            return addChild(EntitySpec.create(memberSpec).configure(flags));
-        }
-        
-        EntityFactory<?> factory = getFactory();
-        if (factory == null) { 
+        if (memberSpec == null) {
             throw new IllegalStateException("No member spec nor entity factory supplied for dynamic fabric "+this);
         }
-        EntityFactory<?> factoryToUse = (factory instanceof EntityFactoryForLocation) ? ((EntityFactoryForLocation)factory).newFactoryForLocation(location) : factory;
-        Entity entity = factoryToUse.newEntity(flags, this);
-        if (entity==null) 
-            throw new IllegalStateException("EntityFactory factory routine returned null entity, in "+this);
-        
-        return entity;
+        return addChild(EntitySpec.create(memberSpec).configure(flags));
     }
-    
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java b/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
index 95d1767..923a082 100644
--- a/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
+++ b/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
@@ -29,9 +29,6 @@ import javax.annotation.Nullable;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.api.sensor.Sensor;
-import org.apache.brooklyn.core.entity.factory.ClosureEntityFactory;
-import org.apache.brooklyn.core.entity.factory.ConfigurableEntityFactory;
-import org.apache.brooklyn.core.entity.factory.ConfigurableEntityFactoryFromEntityFactory;
 import org.apache.brooklyn.core.internal.BrooklynInitialization;
 import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.sensor.Sensors;
@@ -89,27 +86,7 @@ public class TypeCoercions {
         return coercer.function(type);
     }
 
-    @SuppressWarnings({"unused", "deprecation", "unchecked", "rawtypes"})
     public static void registerDeprecatedBrooklynAdapters() {
-        registerAdapter(Closure.class, ConfigurableEntityFactory.class, new Function<Closure,ConfigurableEntityFactory>() {
-            @Override
-            public ConfigurableEntityFactory apply(Closure input) {
-                return new ClosureEntityFactory(input);
-            }
-        });
-        Function<?,?> ignoredVarHereToAllowSuppressDeprecationWarning1 = registerAdapter(org.apache.brooklyn.core.entity.factory.EntityFactory.class, ConfigurableEntityFactory.class, new Function<org.apache.brooklyn.core.entity.factory.EntityFactory,ConfigurableEntityFactory>() {
-            @Override
-            public ConfigurableEntityFactory apply(org.apache.brooklyn.core.entity.factory.EntityFactory input) {
-                if (input instanceof ConfigurableEntityFactory) return (ConfigurableEntityFactory)input;
-                return new ConfigurableEntityFactoryFromEntityFactory(input);
-            }
-        });
-        Function<?,?> ignoredVarHereToAllowSuppressDeprecationWarning2 = registerAdapter(Closure.class, org.apache.brooklyn.core.entity.factory.EntityFactory.class, new Function<Closure,org.apache.brooklyn.core.entity.factory.EntityFactory>() {
-            @Override
-            public org.apache.brooklyn.core.entity.factory.EntityFactory apply(Closure input) {
-                return new ClosureEntityFactory(input);
-            }
-        });
     }
     
     @SuppressWarnings("rawtypes")

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntity.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntity.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntity.java
index 12fcad2..dcf3e5c 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntity.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntity.java
@@ -24,6 +24,7 @@ import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.BasicConfigKey;
 import org.apache.brooklyn.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.time.Duration;
 
 /**
  * Mock entity that blocks on startup via the {@link CountDownLatch} argument.
@@ -42,4 +43,8 @@ public interface BlockingEntity extends TestEntity {
     
     @SetFromFlag("executingShutdownNotificationLatch")
     public static final ConfigKey<CountDownLatch> EXECUTING_SHUTDOWN_NOTIFICATION_LATCH = new BasicConfigKey<CountDownLatch>(CountDownLatch.class, "test.executingShutdownNotificationLatch", "");
+    
+    public static final ConfigKey<Duration> STARTUP_DELAY = new BasicConfigKey<Duration>(Duration.class, "startupLatch", "Delay before starting");
+    
+    public static final ConfigKey<Duration> SHUTDOWN_DELAY = new BasicConfigKey<Duration>(Duration.class, "startupLatch", "Delay before stopping");
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntityImpl.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntityImpl.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntityImpl.java
index 0090780..dcd5da4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntityImpl.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/BlockingEntityImpl.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.util.time.Time;
 
 import com.google.common.base.Throwables;
 
@@ -37,6 +38,7 @@ public class BlockingEntityImpl extends TestEntityImpl implements BlockingEntity
     public void start(Collection<? extends Location> locs) {
         try {
             if (getConfig(EXECUTING_STARTUP_NOTIFICATION_LATCH) != null) getConfig(EXECUTING_STARTUP_NOTIFICATION_LATCH).countDown();
+            if (getConfig(STARTUP_DELAY) != null) Time.sleep(getConfig(STARTUP_DELAY));
             if (getConfig(STARTUP_LATCH) != null) getConfig(STARTUP_LATCH).await();
             super.start(locs);
         } catch (InterruptedException e) {
@@ -49,6 +51,7 @@ public class BlockingEntityImpl extends TestEntityImpl implements BlockingEntity
     public void stop() {
         try {
             if (getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH) != null) getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH).countDown();
+            if (getConfig(SHUTDOWN_DELAY) != null) Time.sleep(getConfig(SHUTDOWN_DELAY));
             if (getConfig(SHUTDOWN_LATCH) != null) getConfig(SHUTDOWN_LATCH).await();
             super.stop();
         } catch (InterruptedException e) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0bf373a4/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
index b443f29..3c827f6 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
@@ -40,7 +40,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.entity.Entity;
@@ -49,14 +48,16 @@ import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.NoMachinesAvailableException;
 import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.api.sensor.SensorEvent;
+import org.apache.brooklyn.api.sensor.SensorEventListener;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityAsserts;
 import org.apache.brooklyn.core.entity.RecordingSensorEventListener;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.core.entity.trait.Changeable;
@@ -65,18 +66,21 @@ import org.apache.brooklyn.core.entity.trait.Resizable;
 import org.apache.brooklyn.core.location.SimulatedLocation;
 import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.sensor.DependentConfiguration;
+import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.core.test.entity.BlockingEntity;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.core.test.entity.TestEntityImpl;
 import org.apache.brooklyn.entity.stock.BasicEntity;
 import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.collections.CollectionFunctionals;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.collections.MutableSet;
 import org.apache.brooklyn.util.collections.QuorumCheck.QuorumChecks;
 import org.apache.brooklyn.util.core.task.DynamicTasks;
 import org.apache.brooklyn.util.core.task.Tasks;
 import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.time.Time;
+import org.apache.brooklyn.util.time.Duration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -87,12 +91,12 @@ import org.testng.annotations.Test;
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
+import com.google.common.base.Suppliers;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.Atomics;
 
 
 public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
@@ -117,10 +121,10 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     }
 
     @Test
-    public void constructionRequiresThatNewEntityArgumentIsAnEntityFactory() throws Exception {
+    public void testRequiresThatMemberSpecArgumentIsAnEntitySpec() throws Exception {
         try {
             app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                    .configure("factory", "error"));
+                    .configure("memberSpec", "error"));
             Asserts.shouldHaveFailedPreviously();
         } catch (Exception e) {
             Asserts.expectedFailure(e);
@@ -128,7 +132,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     }
 
     @Test
-    public void startRequiresThatNewEntityArgumentIsGiven() throws Exception {
+    public void startRequiresThatMemberSpecArgumentIsGiven() throws Exception {
         DynamicCluster c = app.createAndManageChild(EntitySpec.create(DynamicCluster.class));
         try {
             c.start(ImmutableList.of(loc));
@@ -199,12 +203,9 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     }
 
     @Test
-    public void resizeFromZeroToOneStartsANewEntityAndSetsItsParent() throws Exception {
+    public void resizeFromZeroToOneStartsANewChildEntity() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         cluster.start(ImmutableList.of(loc));
 
@@ -300,10 +301,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     @Test
     public void resizeDownByTwoAndDownByOne() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         cluster.start(ImmutableList.of(loc));
 
@@ -325,11 +323,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     @Test
     public void currentSizePropertyReflectsActualClusterSize() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
-
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         assertEquals(cluster.getCurrentSize(), (Integer)0);
 
@@ -359,10 +353,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     @Test
     public void clusterSizeAfterStartIsInitialSize() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }})
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
                 .configure("initialSize", 2));
 
         cluster.start(ImmutableList.of(loc));
@@ -374,36 +365,21 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     @Test
     public void clusterLocationIsPassedOnToEntityStart() throws Exception {
         List<SimulatedLocation> locations = ImmutableList.of(loc);
-        final AtomicReference<Collection<? extends Location>> stashedLocations = Atomics.newReference();
         
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(parent) {
-                            @Override
-                            public void start(Collection<? extends Location> loc) {
-                                super.start(loc);
-                                stashedLocations.set(loc);
-                            }
-                        };
-                    }})
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
                 .configure("initialSize", 1));
 
         cluster.start(locations);
         TestEntity entity = (TestEntity) Iterables.get(cluster.getMembers(), 0);
         
-        assertNotNull(stashedLocations.get());
-        assertEquals(stashedLocations.get().size(), 1);
-        assertEquals(ImmutableList.copyOf(stashedLocations.get()), locations);
+        assertEquals(ImmutableList.copyOf(entity.getLocations()), locations);
     }
 
     @Test
     public void resizeFromOneToZeroChangesClusterSize() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }})
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
                 .configure("initialSize", 1));
 
         cluster.start(ImmutableList.of(loc));
@@ -419,15 +395,19 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     @Test
     public void concurrentResizesToSameNumberCreatesCorrectNumberOfNodes() throws Exception {
         final int OVERHEAD_MS = 500;
-        final int STARTUP_TIME_MS = 50;
-        final AtomicInteger numStarted = new AtomicInteger(0);
+        final Duration STARTUP_TIME = Duration.millis(50);
+        final AtomicInteger numCreated = new AtomicInteger(0);
+
         final DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        Time.sleep(STARTUP_TIME_MS);
-                        numStarted.incrementAndGet();
-                        return new TestEntityImpl(flags, parent);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(BlockingEntity.class)
+                        .configure(BlockingEntity.STARTUP_DELAY, STARTUP_TIME)));
+
+        cluster.subscriptions().subscribe(cluster, AbstractEntity.CHILD_ADDED, new SensorEventListener<Entity>() {
+            @Override public void onEvent(SensorEvent<Entity> event) {
+                if (event.getValue() instanceof BlockingEntity) {
+                    numCreated.incrementAndGet();
+                }
+            }});
 
         assertEquals(cluster.getCurrentSize(), (Integer)0);
         cluster.start(ImmutableList.of(loc));
@@ -449,31 +429,34 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
             }
 
             executor.shutdown();
-            assertTrue(executor.awaitTermination(10*STARTUP_TIME_MS+OVERHEAD_MS, TimeUnit.MILLISECONDS));
+            assertTrue(executor.awaitTermination(10*STARTUP_TIME.toMilliseconds()+OVERHEAD_MS, TimeUnit.MILLISECONDS));
             if (throwables.size() > 0) throw Exceptions.propagate(throwables.get(0));
             assertEquals(cluster.getCurrentSize(), (Integer)2);
             assertEquals(cluster.getAttribute(Changeable.GROUP_SIZE), (Integer)2);
-            assertEquals(numStarted.get(), 2);
+            Asserts.succeedsEventually(new Runnable() {
+                public void run() {
+                    assertEquals(numCreated.get(), 2);
+                }});
         } finally {
             executor.shutdownNow();
         }
     }
 
-    @Test(enabled = false)
+    @Test
     public void stoppingTheClusterStopsTheEntity() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }})
+                .configure("memberSpec", EntitySpec.create(BlockingEntity.class))
                 .configure("initialSize", 1));
 
         cluster.start(ImmutableList.of(loc));
         TestEntity entity = (TestEntity) Iterables.get(cluster.getMembers(), 0);
-        
+        TestEntityImpl deproxiedEntity = (TestEntityImpl) Entities.deproxy(entity);
         assertEquals(entity.getCounter().get(), 1);
         cluster.stop();
-        assertEquals(entity.getCounter().get(), 0);
+        
+        // Need to use deproxiedEntity, because entity-proxy would intercept method call, and it
+        // would fail because the entity has been unmanaged.
+        assertEquals(deproxiedEntity.getCounter().get(), 0);
     }
 
     /**
@@ -485,14 +468,11 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         final AtomicInteger counter = new AtomicInteger(0);
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 0)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.incrementAndGet();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_START, (num==failNum))
-                                .parent(parent));
-                    }}));
+                .configure("memberSpec", EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START_CONDITION, new Predicate<FailingEntity>() {
+                            @Override public boolean apply(FailingEntity input) {
+                                return counter.incrementAndGet() == failNum;
+                            }})));
 
         cluster.start(ImmutableList.of(loc));
         resizeExpectingError(cluster, 3);
@@ -524,14 +504,11 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 2)
                 .configure(DynamicCluster.INITIAL_QUORUM_SIZE, 1)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.incrementAndGet();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_START, (num==failNum))
-                                .parent(parent));
-                    }}));
+                .configure("memberSpec", EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START_CONDITION, new Predicate<FailingEntity>() {
+                            @Override public boolean apply(FailingEntity input) {
+                                return counter.incrementAndGet() == failNum;
+                            }})));
 
         cluster.start(ImmutableList.of(loc));
         
@@ -549,14 +526,11 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         final AtomicInteger counter = new AtomicInteger(0);
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 2)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.incrementAndGet();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_START, (num==failNum))
-                                .parent(parent));
-                    }}));
+                .configure("memberSpec", EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START_CONDITION, new Predicate<FailingEntity>() {
+                            @Override public boolean apply(FailingEntity input) {
+                                return counter.incrementAndGet() == failNum;
+                            }})));
 
         try {
             cluster.start(ImmutableList.of(loc));
@@ -592,19 +566,19 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
 
     @Test
     public void testCanQuarantineFailedEntities() throws Exception {
+        final AttributeSensor<Boolean> failureMarker = Sensors.newBooleanSensor("failureMarker");
         final int failNum = 2;
         final AtomicInteger counter = new AtomicInteger(0);
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("quarantineFailedEntities", true)
                 .configure("initialSize", 0)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.incrementAndGet();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_START, (num==failNum))
-                                .parent(parent));
-                    }}));
+                .configure("memberSpec", EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START_CONDITION, new Predicate<FailingEntity>() {
+                            @Override public boolean apply(FailingEntity input) {
+                                boolean fail = counter.incrementAndGet() == failNum;
+                                input.sensors().set(failureMarker, fail);
+                                return fail;
+                            }})));
 
         cluster.start(ImmutableList.of(loc));
         resizeExpectingError(cluster, 3);
@@ -617,7 +591,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
 
         assertEquals(cluster.getAttribute(DynamicCluster.QUARANTINE_GROUP).getMembers().size(), 1);
         for (Entity member : cluster.getAttribute(DynamicCluster.QUARANTINE_GROUP).getMembers()) {
-            assertTrue(((FailingEntity)member).getConfig(FailingEntity.FAIL_ON_START));
+            assertTrue(member.sensors().get(failureMarker));
         }
     }
 
@@ -629,14 +603,11 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
                 // default is quarantineFailedEntities==true
                 .configure("quarantineFailedEntities", false)
                 .configure("initialSize", 0)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.incrementAndGet();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_START, (num==failNum))
-                                .parent(parent));
-                    }}));
+                .configure("memberSpec", EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START_CONDITION, new Predicate<FailingEntity>() {
+                            @Override public boolean apply(FailingEntity input) {
+                                return counter.incrementAndGet() == failNum;
+                            }})));
 
         cluster.start(ImmutableList.of(loc));
         
@@ -684,23 +655,18 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         runQuarantineFailedEntitiesRespectsFilter(AllowedException.class, NoMachinesAvailableException.class, filter);
     }
     
-    protected void runQuarantineFailedEntitiesRespectsFilter(Class<? extends Exception> allowedException, 
-            Class<? extends Exception> disallowedException, Predicate<Throwable> quarantineFilter) throws Exception {
-        final List<Class<? extends Exception>> failureCauses = ImmutableList.<Class<? extends Exception>>of(allowedException, disallowedException);
-        final AtomicInteger counter = new AtomicInteger(0);
+    protected void runQuarantineFailedEntitiesRespectsFilter(final Class<? extends Exception> allowedException, 
+            final Class<? extends Exception> disallowedException, Predicate<Throwable> quarantineFilter) throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("quarantineFailedEntities", true)
                 .configure("initialSize", 0)
                 .configure("quarantineFilter", quarantineFilter)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.getAndIncrement();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_START, true)
-                                .configure(FailingEntity.EXCEPTION_CLAZZ, failureCauses.get(num))
-                                .parent(parent));
-                    }}));
+                .configure(DynamicCluster.FIRST_MEMBER_SPEC, EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START, true)
+                        .configure(FailingEntity.EXCEPTION_CLAZZ, allowedException))
+                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START, true)
+                        .configure(FailingEntity.EXCEPTION_CLAZZ, disallowedException)));
 
         cluster.start(ImmutableList.of(loc));
         resizeExpectingError(cluster, 2);
@@ -715,14 +681,17 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     @Test
     public void defaultRemovalStrategyShutsDownNewestFirstWhenResizing() throws Exception {
         final List<Entity> creationOrder = Lists.newArrayList();
+        
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 0)
-                .configure("factory", new EntityFactory<Entity>() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        Entity result = new TestEntityImpl(flags);
-                        creationOrder.add(result);
-                        return result;
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
+
+        cluster.subscriptions().subscribe(cluster, AbstractEntity.CHILD_ADDED, new SensorEventListener<Entity>() {
+            @Override public void onEvent(SensorEvent<Entity> event) {
+                if (event.getValue() instanceof TestEntity) {
+                    creationOrder.add(event.getValue());
+                }
+            }});
 
         cluster.start(ImmutableList.of(loc));
         cluster.resize(1);
@@ -733,6 +702,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         Thread.sleep(1);
         
         cluster.resize(2);
+        Asserts.eventually(Suppliers.ofInstance(creationOrder), CollectionFunctionals.sizeEquals(2));
         assertEquals(cluster.getCurrentSize(), (Integer)2);
         assertEquals(ImmutableSet.copyOf(cluster.getMembers()), ImmutableSet.copyOf(creationOrder), "actual="+cluster.getMembers());
 
@@ -745,10 +715,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     @Test
     public void resizeLoggedAsEffectorCall() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         app.start(ImmutableList.of(loc));
         cluster.resize(1);
@@ -761,18 +728,14 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     }
 
     @Test
-    public void testStoppedChildIsRemoveFromGroup() throws Exception {
+    public void testUnmanagedChildIsRemoveFromGroup() throws Exception {
         final DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         cluster.start(ImmutableList.of(loc));
 
         final TestEntity child = (TestEntity) Iterables.get(cluster.getMembers(), 0);
-        child.stop();
         Entities.unmanage(child);
 
         Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
@@ -796,15 +759,12 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         };
 
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }})
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
                 .configure("initialSize", 10)
                 .configure("removalStrategy", removalStrategy));
 
         cluster.start(ImmutableList.of(loc));
-        Set origMembers = ImmutableSet.copyOf(cluster.getMembers());
+        Set<?> origMembers = ImmutableSet.copyOf(cluster.getMembers());
 
         for (int i = 10; i >= 0; i--) {
             cluster.resize(i);
@@ -827,14 +787,11 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         };
         
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }})
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
                 .configure("initialSize", 10));
 
         cluster.start(ImmutableList.of(loc));
-        Set origMembers = ImmutableSet.copyOf(cluster.getMembers());
+        Set<?> origMembers = ImmutableSet.copyOf(cluster.getMembers());
 
         cluster.setRemovalStrategy(removalStrategy);
 
@@ -853,16 +810,9 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         
         final DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 0)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        try {
-                            executingLatch.countDown();
-                            continuationLatch.await();
-                            return new TestEntityImpl(flags);
-                        } catch (InterruptedException e) {
-                            throw Exceptions.propagate(e);
-                        }
-                    }}));
+                .configure("memberSpec", EntitySpec.create(BlockingEntity.class)
+                        .configure(BlockingEntity.STARTUP_LATCH, continuationLatch)
+                        .configure(BlockingEntity.EXECUTING_STARTUP_NOTIFICATION_LATCH, executingLatch)));
 
         cluster.start(ImmutableList.of(loc));
 
@@ -872,15 +822,16 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
                 }});
         
         try {
-            // wait for resize to be executing
+            // wait for resize to be executing; it will be waiting for start() to complete on
+            // the newly created member.
             thread.start();
             executingLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS);
 
             // ensure can still call methods on group, to query/update membership
-            assertEquals(ImmutableList.copyOf(cluster.getMembers()), ImmutableList.of());
-            assertEquals(cluster.getCurrentSize(), (Integer)0);
+            assertEquals(cluster.getMembers().size(), 1);
+            assertEquals(cluster.getCurrentSize(), (Integer)1);
             assertFalse(cluster.hasMember(cluster));
-            cluster.addMember(cluster);
+            assertTrue(cluster.addMember(cluster));
             assertTrue(cluster.removeMember(cluster));
 
             // allow the resize to complete
@@ -896,10 +847,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     public void testReplacesMember() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         cluster.start(ImmutableList.of(loc));
         Entity member = Iterables.get(cluster.getMembers(), 0);
@@ -919,10 +867,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     public void testReplaceMemberThrowsIfMemberIdDoesNotResolve() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         cluster.start(ImmutableList.of(loc));
         Entity member = Iterables.get(cluster.getMembers(), 0);
@@ -942,10 +887,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
     public void testReplaceMemberThrowsIfNotMember() throws Exception {
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }}));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class)));
 
         cluster.start(ImmutableList.of(loc));
         Entity member = Iterables.get(cluster.getMembers(), 0);
@@ -966,14 +908,11 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         final int failNum = 2;
         final AtomicInteger counter = new AtomicInteger(0);
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.incrementAndGet();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_START, (num==failNum))
-                                .parent(parent));
-                    }}));
+                .configure("memberSpec", EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_START_CONDITION, new Predicate<FailingEntity>() {
+                            @Override public boolean apply(FailingEntity input) {
+                                return counter.incrementAndGet() == failNum;
+                            }})));
 
         cluster.start(ImmutableList.of(loc));
         Entity member = Iterables.get(cluster.getMembers(), 0);
@@ -994,14 +933,11 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         final AtomicInteger counter = new AtomicInteger(0);
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
-                .configure("factory", new EntityFactory() {
-                    @Override public Entity newEntity(Map flags, Entity parent) {
-                        int num = counter.incrementAndGet();
-                        return app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(FailingEntity.class)
-                                .configure(flags)
-                                .configure(FailingEntity.FAIL_ON_STOP, (num==failNum))
-                                .parent(parent));
-                    }}));
+                .configure("memberSpec", EntitySpec.create(FailingEntity.class)
+                        .configure(FailingEntity.FAIL_ON_STOP_CONDITION, new Predicate<FailingEntity>() {
+                            @Override public boolean apply(FailingEntity input) {
+                                return counter.incrementAndGet() == failNum;
+                            }})));
 
         cluster.start(ImmutableList.of(loc));
         Entity member = Iterables.get(cluster.getMembers(), 0);
@@ -1101,12 +1037,8 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         int clusterSize = 5;
 
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override
-                    public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }
-                }).configure("initialSize", clusterSize));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
+                .configure("initialSize", clusterSize));
 
         cluster.start(ImmutableList.of(loc));
 
@@ -1123,12 +1055,8 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         int clusterSize = 5;
 
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override
-                    public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }
-                }).configure("initialSize", clusterSize));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
+                .configure("initialSize", clusterSize));
 
         cluster.start(ImmutableList.of(loc));
 
@@ -1148,12 +1076,8 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
         int clusterSize = 5;
 
         DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure("factory", new EntityFactory() {
-                    @Override
-                    public Entity newEntity(Map flags, Entity parent) {
-                        return new TestEntityImpl(flags);
-                    }
-                }).configure("initialSize", clusterSize));
+                .configure("memberSpec", EntitySpec.create(TestEntity.class))
+                .configure("initialSize", clusterSize));
 
         cluster.start(ImmutableList.of(loc));
 


Mime
View raw message