cherrypicked a01940fac58d397b384b709631921810d95606cd Merge pull request #639 
from ahgittin/fix/addChild-with-spec-on-interface onto 0.5


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

Branch: refs/heads/0.5.0
Commit: 5d79bc1340679bdc65378cd615c5e9d19bf38e4d
Parents: bba778b
Author: Andrea Turli <[email protected]>
Authored: Fri Apr 19 15:11:28 2013 +0200
Committer: Andrea Turli <[email protected]>
Committed: Fri Apr 19 15:56:30 2013 +0200

----------------------------------------------------------------------
 api/src/main/java/brooklyn/entity/Entity.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5d79bc13/api/src/main/java/brooklyn/entity/Entity.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/Entity.java 
b/api/src/main/java/brooklyn/entity/Entity.java
index 3c555e7..7211821 100644
--- a/api/src/main/java/brooklyn/entity/Entity.java
+++ b/api/src/main/java/brooklyn/entity/Entity.java
@@ -5,12 +5,14 @@ import java.util.Collection;
 import java.util.Map;
 
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.rebind.RebindSupport;
 import brooklyn.entity.rebind.Rebindable;
 import brooklyn.event.AttributeSensor;
 import brooklyn.location.Location;
 import brooklyn.management.Task;
 import brooklyn.mementos.EntityMemento;
+import brooklyn.mementos.PolicyMemento;
 import brooklyn.policy.Enricher;
 import brooklyn.policy.Policy;
 
@@ -91,11 +93,16 @@ public interface Entity extends Serializable, Rebindable {
      * 
      * TODO Signature will change to {@code <T extends Entity> T addChild(T 
child)}, but
      * that currently breaks groovy AbstractEntity subclasses sometimes so 
deferring that
-     * until (hopefully) the next release.
+     * until (hopefully) the next release. For now use addChild(EntitySpec).
      */
     Entity addChild(Entity child);
     
     /** 
+     * Creates an {@link Entity} from the given spec and adds it, setting this 
entity as the parent,
+     * returning the added child. */
+    <T extends Entity> T addChild(EntitySpec<T> spec);
+    
+    /** 
      * Removes the specified child {@link Entity}; its parent will be set to 
null.
      * 
      * @return True if the given entity was contained in the set of children

Reply via email to