brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [16/25] git commit: Call entity-change listener on enrichers change
Date Sun, 01 Jun 2014 20:15:31 GMT
Call entity-change listener on enrichers change


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

Branch: refs/heads/master
Commit: 284743ab6fb8209f0cd44cfe5654ed163266467f
Parents: a03853e
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed May 28 19:13:07 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Fri May 30 10:24:39 2014 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/entity/basic/AbstractEntity.java  | 11 ++++++++++-
 .../management/internal/EntityChangeListener.java        |  3 +++
 .../management/internal/EntityManagementSupport.java     |  4 ++++
 3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/284743ab/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 aaad7d5..0fa2a5c 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
@@ -1105,12 +1105,21 @@ public abstract class AbstractEntity implements EntityLocal, EntityInternal
{
     public void addEnricher(Enricher enricher) {
         enrichers.add((AbstractEnricher) enricher);
         ((AbstractEnricher)enricher).setEntity(this);
+        
+        getManagementSupport().getEntityChangeListener().onEnrichersChanged();
+        // TODO Could add equivalent of AbstractEntity.POLICY_ADDED for enrichers; no use-case
for that yet
     }
 
     @Override
     public boolean removeEnricher(Enricher enricher) {
         ((AbstractEnricher)enricher).destroy();
-        return enrichers.remove(enricher);
+        boolean changed = enrichers.remove(enricher);
+        
+        if (changed) {
+            getManagementSupport().getEntityChangeListener().onEnrichersChanged();
+        }
+        return changed;
+
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/284743ab/core/src/main/java/brooklyn/management/internal/EntityChangeListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/EntityChangeListener.java b/core/src/main/java/brooklyn/management/internal/EntityChangeListener.java
index d564074..31805e6 100644
--- a/core/src/main/java/brooklyn/management/internal/EntityChangeListener.java
+++ b/core/src/main/java/brooklyn/management/internal/EntityChangeListener.java
@@ -14,6 +14,7 @@ public interface EntityChangeListener {
         @Override public void onMembersChanged() {}
         @Override public void onChildrenChanged() {}
         @Override public void onPoliciesChanged() {}
+        @Override public void onEnrichersChanged() {}
         @Override public void onEffectorStarting(Effector<?> effector) {}
         @Override public void onEffectorCompleted(Effector<?> effector) {}
     };
@@ -34,6 +35,8 @@ public interface EntityChangeListener {
     //       Do we want a separate PolicyChangeListener instead? Or everything through EntityChangeListener?
     void onPoliciesChanged();
 
+    void onEnrichersChanged();
+
     void onEffectorStarting(Effector<?> effector);
     
     void onEffectorCompleted(Effector<?> effector);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/284743ab/core/src/main/java/brooklyn/management/internal/EntityManagementSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/EntityManagementSupport.java
b/core/src/main/java/brooklyn/management/internal/EntityManagementSupport.java
index 6b9dcde..83b42e1 100644
--- a/core/src/main/java/brooklyn/management/internal/EntityManagementSupport.java
+++ b/core/src/main/java/brooklyn/management/internal/EntityManagementSupport.java
@@ -343,6 +343,10 @@ public class EntityManagementSupport {
             getManagementContext().getRebindManager().getChangeListener().onChanged(entity);
         }
         @Override
+        public void onEnrichersChanged() {
+            getManagementContext().getRebindManager().getChangeListener().onChanged(entity);
+        }
+        @Override
         public void onAttributeChanged(AttributeSensor<?> attribute) {
             // TODO Could make this more efficient by inspecting the attribute to decide
if needs persisted
             // immediately, or not important, or transient (e.g. do we really need to persist



Mime
View raw message