brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [4/9] incubator-brooklyn git commit: when doing Entity.addChild, create a copy of the spec and set the parent *there* if needed, so that config is inherited even when running `AbstractEntity.init()`
Date Mon, 15 Dec 2014 16:57:31 GMT
when doing Entity.addChild, create a copy of the spec and set the parent *there* if needed,
so that config is inherited even when running `AbstractEntity.init()`


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

Branch: refs/heads/master
Commit: ff7126af967f50f87810da7980b7e3159f7b9c54
Parents: 67d05d6
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Nov 25 08:50:17 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Dec 12 13:54:55 2014 +0000

----------------------------------------------------------------------
 core/src/main/java/brooklyn/entity/basic/AbstractEntity.java  | 5 ++++-
 .../java/brooklyn/entity/proxying/InternalEntityFactory.java  | 7 -------
 2 files changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ff7126af/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
index 6a64cb0..ae0179f 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
@@ -622,7 +622,10 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements
E
      */
     @Override
     public <T extends Entity> T addChild(EntitySpec<T> spec) {
-        if (spec.getParent() != null && !this.equals(spec.getParent())) {
+        if (spec.getParent()==null) {
+            spec = EntitySpec.create(spec).parent(this);
+        }
+        if (!this.equals(spec.getParent())) {
             throw new IllegalArgumentException("Attempt to create child of "+this+" with
entity spec "+spec+
                 " failed because spec has different parent: "+spec.getParent());
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ff7126af/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java b/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
index 50e15e6..40885b4 100644
--- a/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
+++ b/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
@@ -295,13 +295,6 @@ public class InternalEntityFactory extends InternalFactory {
                 
                 ((AbstractEntity)entity).addLocations(spec.getLocations());
 
-                /* 31 Mar 2014, moved initialization (below) into this task: primarily for
consistency and traceability on failure.
-                 * TBC whether this is good/bad/indifferent. My (Alex) opinion is that whether
it is done in a subtask 
-                 * should be the same as whether enricher/policy/etc (below) is done subtasks,
which is was added recently
-                 * in 249c96fbb18bd9d763029475e0a3dc251c01b287. @nakomis can you give exact
reason code below is needed in a task
-                 * commit message said was to do with wiring up yaml sensors and policies
-- which makes sense but specifics would be handy!
-                 * and would let me know if there is any reason to do / not_do the initializer
code below also here! 
-                 */
                 for (EntityInitializer initializer: spec.getInitializers()) {
                     initializer.apply((EntityInternal)entity);
                 }


Mime
View raw message