brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [2/9] git commit: ChangeListener: use BrooklynObject
Date Thu, 07 Aug 2014 21:55:36 GMT
ChangeListener: use BrooklynObject

- instead of having separate methods for Entity, Location, etc,
  just have one for BrooklynObject.
- move requestPersist() impl up to AbstractBrooklynObject


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

Branch: refs/heads/master
Commit: bf0b3e7db3457cc5cc5e407c718555740d5719f3
Parents: 5c5ed96
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Aug 6 22:00:47 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Aug 6 23:17:46 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/rebind/ChangeListener.java  |  44 +----
 .../brooklyn/basic/AbstractBrooklynObject.java  |   9 +-
 .../enricher/basic/AbstractEnricher.java        |   8 -
 .../rebind/ImmediateDeltaChangeListener.java    | 179 +++++++------------
 .../rebind/PeriodicDeltaChangeListener.java     | 153 ++++++----------
 .../entity/rebind/RebindManagerImpl.java        | 100 ++---------
 .../location/basic/AbstractLocation.java        |   8 -
 .../brooklyn/policy/basic/AbstractPolicy.java   |   8 -
 8 files changed, 147 insertions(+), 362 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java b/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java
index 582c7e0..02d4ad2 100644
--- a/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java
+++ b/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java
@@ -18,10 +18,7 @@
  */
 package brooklyn.entity.rebind;
 
-import brooklyn.entity.Entity;
-import brooklyn.location.Location;
-import brooklyn.policy.Enricher;
-import brooklyn.policy.Policy;
+import brooklyn.basic.BrooklynObject;
 
 /**
  * Listener to be notified of changes within brooklyn, so that the new state
@@ -34,41 +31,14 @@ import brooklyn.policy.Policy;
 public interface ChangeListener {
 
     public static final ChangeListener NOOP = new ChangeListener() {
-        @Override public void onManaged(Entity entity) {}
-        @Override public void onUnmanaged(Entity entity) {}
-        @Override public void onChanged(Entity entity) {}
-        @Override public void onManaged(Location location) {}
-        @Override public void onUnmanaged(Location location) {}
-        @Override public void onChanged(Location location) {}
-        @Override public void onManaged(Policy policy) {}
-        @Override public void onUnmanaged(Policy policy) {}
-        @Override public void onChanged(Policy policy) {}
-        @Override public void onManaged(Enricher enricher) {}
-        @Override public void onUnmanaged(Enricher enricher) {}
-        @Override public void onChanged(Enricher enricher) {}
+        @Override public void onChanged(BrooklynObject instance) {}
+        @Override public void onManaged(BrooklynObject instance) {}
+        @Override public void onUnmanaged(BrooklynObject instance) {}
     };
-    
-    void onManaged(Entity entity);
-    
-    void onUnmanaged(Entity entity);
-    
-    void onChanged(Entity entity);
-    
-    void onManaged(Location location);
-
-    void onUnmanaged(Location location);
 
-    void onChanged(Location location);
+    void onManaged(BrooklynObject instance);
     
-    void onManaged(Policy policy);
-
-    void onUnmanaged(Policy policy);
-
-    void onChanged(Policy policy);
+    void onUnmanaged(BrooklynObject instance);
     
-    void onManaged(Enricher enricher);
-
-    void onUnmanaged(Enricher enricher);
-
-    void onChanged(Enricher enricher);
+    void onChanged(BrooklynObject instance);
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java b/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
index e11e4b9..8764bf0 100644
--- a/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
+++ b/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
@@ -37,8 +37,6 @@ public abstract class AbstractBrooklynObject implements BrooklynObjectInternal
{
 
     private volatile ManagementContext managementContext;
 
-    protected abstract void requestPersist();
-
     public void setManagementContext(ManagementContextInternal managementContext) {
         this.managementContext = managementContext;
     }
@@ -47,6 +45,13 @@ public abstract class AbstractBrooklynObject implements BrooklynObjectInternal
{
         return managementContext;
     }
 
+    protected void requestPersist() {
+        // TODO Could add PolicyChangeListener, similar to EntityChangeListener; should we
do that?
+        if (getManagementContext() != null) {
+            getManagementContext().getRebindManager().getChangeListener().onChanged(this);
+        }
+    }
+    
     @Override
     public String getId() {
         return id;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java b/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java
index e029ab2..8503663 100644
--- a/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java
+++ b/core/src/main/java/brooklyn/enricher/basic/AbstractEnricher.java
@@ -64,12 +64,4 @@ public abstract class AbstractEnricher extends AbstractEntityAdjunct implements
     protected void onChanged() {
         requestPersist();
     }
-    
-    @Override
-    protected void requestPersist() {
-        // TODO Could add PolicyChangeListener, similar to EntityChangeListener; should we
do that?
-        if (getManagementContext() != null) {
-            getManagementContext().getRebindManager().getChangeListener().onChanged(this);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/core/src/main/java/brooklyn/entity/rebind/ImmediateDeltaChangeListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/ImmediateDeltaChangeListener.java b/core/src/main/java/brooklyn/entity/rebind/ImmediateDeltaChangeListener.java
index 06c8519..67a8c96 100644
--- a/core/src/main/java/brooklyn/entity/rebind/ImmediateDeltaChangeListener.java
+++ b/core/src/main/java/brooklyn/entity/rebind/ImmediateDeltaChangeListener.java
@@ -21,12 +21,17 @@ package brooklyn.entity.rebind;
 import java.util.Collection;
 import java.util.Map;
 
+import brooklyn.basic.BrooklynObject;
+import brooklyn.basic.BrooklynObjectInternal;
 import brooklyn.entity.Entity;
-import brooklyn.entity.basic.EntityInternal;
 import brooklyn.location.Location;
 import brooklyn.location.basic.LocationInternal;
 import brooklyn.mementos.BrooklynMementoPersister;
+import brooklyn.mementos.EnricherMemento;
+import brooklyn.mementos.EntityMemento;
 import brooklyn.mementos.LocationMemento;
+import brooklyn.mementos.Memento;
+import brooklyn.mementos.PolicyMemento;
 import brooklyn.policy.Enricher;
 import brooklyn.policy.Policy;
 
@@ -55,133 +60,87 @@ public class ImmediateDeltaChangeListener implements ChangeListener {
     }
     
     @Override
-    public void onManaged(Entity entity) {
-        onChanged(entity);
+    public void onManaged(BrooklynObject instance) {
+        onChanged(instance);
     }
 
     @Override
-    public void onManaged(Location location) {
-        onChanged(location);
-    }
-    
-    @Override
-    public void onManaged(Policy policy) {
-        onChanged(policy);
-    }
-    
-    @Override
-    public void onManaged(Enricher enricher) {
-        onChanged(enricher);
-    }
-    
-    @Override
-    public void onChanged(Entity entity) {
+    public void onUnmanaged(BrooklynObject instance) {
         if (running && persister != null) {
             PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.entities.add(((EntityInternal)entity).getRebindSupport().getMemento());
-
-            // FIXME How to let the policy/location tell us about changes?
-            // Don't do this every time!
-            Map<String, LocationMemento> locations = Maps.newLinkedHashMap();
-            for (Location location : entity.getLocations()) {
-                if (!locations.containsKey(location.getId())) {
-                    Collection<Location> locsInHierachy = TreeUtils.findLocationsInHierarchy(location);
-
-                    /*
-                     * Need to guarantee "happens before", with any thread that has written

-                     * fields of these locations. In particular, saw failures where SshMachineLocation
-                     * had null address field. Our hypothesis is that the location had its
fields set,
-                     * and then set its parent (which goes through a synchronized in AbstractLocation.addChild),
-                     * but that this memento-generating code did not go through any synchronization
or volatiles.
-                     */
-                    synchronized (new Object()) {}
-                    
-                    for (Location locInHierarchy : locsInHierachy) {
-                        locations.put(locInHierarchy.getId(), ((LocationInternal)locInHierarchy).getRebindSupport().getMemento());
-                    }
-                }
+            if (instance instanceof Entity) {
+                delta.removedEntityIds.add(instance.getId());
+            } else if (instance instanceof Location) {
+                delta.removedLocationIds.add(instance.getId());
+            } else if (instance instanceof Policy) {
+                delta.removedPolicyIds.add(instance.getId());
+            } else if (instance instanceof Enricher) {
+                delta.removedEnricherIds.add(instance.getId());
+            } else {
+                throw new IllegalStateException("Unexpected brooklyn type: "+instance);
             }
-            delta.locations = locations.values();
-
-            // FIXME Not including policies, because lots of places regiser anonymous inner
class policies
-            // (e.g. AbstractController registering a AbstractMembershipTrackingPolicy)
-            // Also, the entity constructor often re-creates the policy.
-            // Also see MementosGenerator.newEntityMementoBuilder()
-//            List<PolicyMemento> policies = Lists.newArrayList();
-//            for (Policy policy : entity.getPolicies()) {
-//                policies.add(policy.getRebindSupport().getMemento());
-//            }
-//            delta.policies = policies;
-
-            /*
-             * Make the writes to the mementos visible to other threads.
-             */
-            synchronized (new Object()) {}
-
-            persister.delta(delta, exceptionHandler);
-        }
-    }
-    
-    @Override
-    public void onUnmanaged(Entity entity) {
-        if (running && persister != null) {
-            PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.removedEntityIds.add(entity.getId());
             persister.delta(delta, exceptionHandler);
         }
     }
 
     @Override
-    public void onUnmanaged(Location location) {
+    public void onChanged(BrooklynObject instance) {
         if (running && persister != null) {
             PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.removedLocationIds.add(location.getId());
+            Memento memento = ((BrooklynObjectInternal)instance).getRebindSupport().getMemento();
+            if (instance instanceof Entity) {
+                delta.entities.add((EntityMemento) memento);
+                addEntityAdjuncts((Entity)instance, delta);
+            } else if (instance instanceof Location) {
+                delta.locations.add((LocationMemento) memento);
+            } else if (instance instanceof Policy) {
+                delta.policies.add((PolicyMemento) memento);
+            } else if (instance instanceof Enricher) {
+                delta.enrichers.add((EnricherMemento) memento);
+            } else {
+                throw new IllegalStateException("Unexpected brooklyn type: "+instance);
+            }
             persister.delta(delta, exceptionHandler);
         }
     }
-
-    @Override
-    public void onUnmanaged(Policy policy) {
-        if (running && persister != null) {
-            PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.removedPolicyIds.add(policy.getId());
-            persister.delta(delta, exceptionHandler);
+    
+    private void addEntityAdjuncts(Entity entity, PersisterDeltaImpl delta) {
+        // FIXME How to let the policy/location tell us about changes?
+        // Don't do this every time!
+        Map<String, LocationMemento> locations = Maps.newLinkedHashMap();
+        for (Location location : entity.getLocations()) {
+            if (!locations.containsKey(location.getId())) {
+                Collection<Location> locsInHierachy = TreeUtils.findLocationsInHierarchy(location);
+
+                /*
+                 * Need to guarantee "happens before", with any thread that has written 
+                 * fields of these locations. In particular, saw failures where SshMachineLocation
+                 * had null address field. Our hypothesis is that the location had its fields
set,
+                 * and then set its parent (which goes through a synchronized in AbstractLocation.addChild),
+                 * but that this memento-generating code did not go through any synchronization
or volatiles.
+                 */
+                synchronized (new Object()) {}
+                
+                for (Location locInHierarchy : locsInHierachy) {
+                    locations.put(locInHierarchy.getId(), ((LocationInternal)locInHierarchy).getRebindSupport().getMemento());
+                }
+            }
         }
-    }
+        delta.locations = locations.values();
 
-    @Override
-    public void onUnmanaged(Enricher enricher) {
-        if (running && persister != null) {
-            PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.removedEnricherIds.add(enricher.getId());
-            persister.delta(delta, exceptionHandler);
-        }
-    }
+        // FIXME Not including policies, because lots of places regiser anonymous inner class
policies
+        // (e.g. AbstractController registering a AbstractMembershipTrackingPolicy)
+        // Also, the entity constructor often re-creates the policy.
+        // Also see MementosGenerator.newEntityMementoBuilder()
+//            List<PolicyMemento> policies = Lists.newArrayList();
+//            for (Policy policy : entity.getPolicies()) {
+//                policies.add(policy.getRebindSupport().getMemento());
+//            }
+//            delta.policies = policies;
 
-    @Override
-    public void onChanged(Location location) {
-        if (running && persister != null) {
-            PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.locations.add(((LocationInternal)location).getRebindSupport().getMemento());
-            persister.delta(delta, exceptionHandler);
-        }
-    }
-    
-    @Override
-    public void onChanged(Policy policy) {
-        if (running && persister != null) {
-            PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.policies.add(policy.getRebindSupport().getMemento());
-            persister.delta(delta, exceptionHandler);
-        }
-    }
-    
-    @Override
-    public void onChanged(Enricher enricher) {
-        if (running && persister != null) {
-            PersisterDeltaImpl delta = new PersisterDeltaImpl();
-            delta.enrichers.add(enricher.getRebindSupport().getMemento());
-            persister.delta(delta, exceptionHandler);
-        }
+        /*
+         * Make the writes to the mementos visible to other threads.
+         */
+        synchronized (new Object()) {}
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java b/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
index 955ba2e..7613c2a 100644
--- a/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
+++ b/core/src/main/java/brooklyn/entity/rebind/PeriodicDeltaChangeListener.java
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import brooklyn.basic.BrooklynObject;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.EntityInternal;
 import brooklyn.internal.BrooklynFeatureEnablement;
@@ -280,120 +281,74 @@ public class PeriodicDeltaChangeListener implements ChangeListener
{
     }
     
     @Override
-    public synchronized void onManaged(Entity entity) {
-        if (LOG.isTraceEnabled()) LOG.trace("onManaged: {}", entity);
-        onChanged(entity);
+    public synchronized void onManaged(BrooklynObject instance) {
+        if (LOG.isTraceEnabled()) LOG.trace("onManaged: {}", instance);
+        onChanged(instance);
     }
 
     @Override
-    public synchronized void onManaged(Location location) {
-        if (LOG.isTraceEnabled()) LOG.trace("onManaged: {}", location);
-        onChanged(location);
-    }
-    
-    @Override
-    public synchronized void onManaged(Policy policy) {
-        if (LOG.isTraceEnabled()) LOG.trace("onManaged: {}", policy);
-        onChanged(policy);
-    }
-    
-    @Override
-    public synchronized void onManaged(Enricher enricher) {
-        if (LOG.isTraceEnabled()) LOG.trace("onManaged: {}", enricher);
-        onChanged(enricher);
-    }
-    
-    @Override
-    public synchronized void onChanged(Entity entity) {
-        if (LOG.isTraceEnabled()) LOG.trace("onChanged: {}", entity);
+    public synchronized void onUnmanaged(BrooklynObject instance) {
+        if (LOG.isTraceEnabled()) LOG.trace("onUnmanaged: {}", instance);
         if (!isStopped()) {
-            deltaCollector.entities.add(entity);
-
-            // FIXME How to let the policy/location tell us about changes? Don't do this
every time!
-            for (Location location : entity.getLocations()) {
-                deltaCollector.locations.addAll(TreeUtils.findLocationsInHierarchy(location));
-            }
-
-            if (persistPoliciesEnabled) {
+            if (instance instanceof Entity) {
+                Entity entity = (Entity) instance;
+                deltaCollector.removedEntityIds.add(entity.getId());
+                deltaCollector.entities.remove(entity);
+                
                 for (Policy policy : entity.getPolicies()) {
-                    deltaCollector.policies.add(policy);
+                    deltaCollector.removedPolicyIds.add(policy.getId());
+                    deltaCollector.policies.remove(policy);
                 }
-            }
-
-            if (persistEnrichersEnabled) {
                 for (Enricher enricher : entity.getEnrichers()) {
-                    deltaCollector.enrichers.add(enricher);
+                    deltaCollector.removedEnricherIds.add(enricher.getId());
+                    deltaCollector.enrichers.remove(enricher);
                 }
+            } else if (instance instanceof Location) {
+                deltaCollector.removedLocationIds.add(instance.getId());
+                deltaCollector.locations.remove(instance);
+            } else if (instance instanceof Policy) {
+                deltaCollector.removedPolicyIds.add(instance.getId());
+                deltaCollector.policies.remove(instance);
+            } else if (instance instanceof Enricher) {
+                deltaCollector.removedEnricherIds.add(instance.getId());
+                deltaCollector.enrichers.remove(instance);
+            } else {
+                throw new IllegalStateException("Unexpected brooklyn type: "+instance);
             }
         }
     }
-    
-    @Override
-    public synchronized void onUnmanaged(Entity entity) {
-        if (LOG.isTraceEnabled()) LOG.trace("onUnmanaged: {}", entity);
-        if (!isStopped()) {
-            deltaCollector.removedEntityIds.add(entity.getId());
-            deltaCollector.entities.remove(entity);
-            
-            for (Policy policy : entity.getPolicies()) {
-                deltaCollector.removedPolicyIds.add(policy.getId());
-                deltaCollector.policies.remove(policy);
-            }
-            for (Enricher enricher : entity.getEnrichers()) {
-                deltaCollector.removedEnricherIds.add(enricher.getId());
-                deltaCollector.enrichers.remove(enricher);
-            }
-        }
-    }
-
-    @Override
-    public synchronized void onUnmanaged(Location location) {
-        if (LOG.isTraceEnabled()) LOG.trace("onUnmanaged: {}", location);
-        if (!isStopped()) {
-            deltaCollector.removedLocationIds.add(location.getId());
-            deltaCollector.locations.remove(location);
-        }
-    }
 
     @Override
-    public synchronized void onUnmanaged(Policy policy) {
-        if (LOG.isTraceEnabled()) LOG.trace("onUnmanaged: {}", policy);
+    public synchronized void onChanged(BrooklynObject instance) {
+        if (LOG.isTraceEnabled()) LOG.trace("onChanged: {}", instance);
         if (!isStopped()) {
-            deltaCollector.removedPolicyIds.add(policy.getId());
-            deltaCollector.policies.remove(policy);
-        }
-    }
-
-    @Override
-    public synchronized void onUnmanaged(Enricher enricher) {
-        if (LOG.isTraceEnabled()) LOG.trace("onUnmanaged: {}", enricher);
-        if (!isStopped()) {
-            deltaCollector.removedEnricherIds.add(enricher.getId());
-            deltaCollector.enrichers.remove(enricher);
-        }
-    }
+            if (instance instanceof Entity) {
+                Entity entity = (Entity) instance;
+                deltaCollector.entities.add(entity);
 
-    @Override
-    public synchronized void onChanged(Location location) {
-        if (LOG.isTraceEnabled()) LOG.trace("onChanged: {}", location);
-        if (!isStopped()) {
-            deltaCollector.locations.add(location);
-        }
-    }
-    
-    @Override
-    public synchronized void onChanged(Policy policy) {
-        if (LOG.isTraceEnabled()) LOG.trace("onChanged: {}", policy);
-        if (!isStopped()) {
-            deltaCollector.policies.add(policy);
-        }
-    }
-    
-    @Override
-    public synchronized void onChanged(Enricher enricher) {
-        if (LOG.isTraceEnabled()) LOG.trace("onChanged: {}", enricher);
-        if (!isStopped()) {
-            deltaCollector.enrichers.add(enricher);
+                // FIXME How to let the policy/location tell us about changes? Don't do this
every time!
+                for (Location location : entity.getLocations()) {
+                    deltaCollector.locations.addAll(TreeUtils.findLocationsInHierarchy(location));
+                }
+                if (persistPoliciesEnabled) {
+                    for (Policy policy : entity.getPolicies()) {
+                        deltaCollector.policies.add(policy);
+                    }
+                }
+                if (persistEnrichersEnabled) {
+                    for (Enricher enricher : entity.getEnrichers()) {
+                        deltaCollector.enrichers.add(enricher);
+                    }
+                }
+            } else if (instance instanceof Location) {
+                deltaCollector.locations.add((Location) instance);
+            } else if (instance instanceof Policy) {
+                deltaCollector.policies.add((Policy) instance);
+            } else if (instance instanceof Enricher) {
+                deltaCollector.enrichers.add((Enricher) instance);
+            } else {
+                throw new IllegalStateException("Unexpected brooklyn type: "+instance);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java b/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
index 2bd121c..4e8ffc8 100644
--- a/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
+++ b/core/src/main/java/brooklyn/entity/rebind/RebindManagerImpl.java
@@ -30,6 +30,7 @@ import java.util.concurrent.TimeoutException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import brooklyn.basic.BrooklynObject;
 import brooklyn.config.ConfigKey;
 import brooklyn.enricher.basic.AbstractEnricher;
 import brooklyn.entity.Application;
@@ -747,110 +748,29 @@ public class RebindManagerImpl implements RebindManager {
         }
         
         @Override
-        public void onManaged(Entity entity) {
+        public void onManaged(BrooklynObject instance) {
             try {
-                delegate.onManaged(entity);
+                delegate.onManaged(instance);
             } catch (Throwable t) {
-                LOG.error("Error persisting mememento onManaged("+entity+"); continuing.",
t);
+                LOG.error("Error persisting mememento onManaged("+instance+"); continuing.",
t);
             }
         }
 
         @Override
-        public void onManaged(Location location) {
+        public void onChanged(BrooklynObject instance) {
             try {
-                delegate.onManaged(location);
+                delegate.onChanged(instance);
             } catch (Throwable t) {
-                LOG.error("Error persisting mememento onManaged("+location+"); continuing.",
t);
+                LOG.error("Error persisting mememento onChanged("+instance+"); continuing.",
t);
             }
         }
         
         @Override
-        public void onManaged(Policy policy) {
+        public void onUnmanaged(BrooklynObject instance) {
             try {
-                delegate.onManaged(policy);
+                delegate.onUnmanaged(instance);
             } catch (Throwable t) {
-                LOG.error("Error persisting mememento onManaged("+policy+"); continuing.",
t);
-            }
-        }
-
-        @Override
-        public void onManaged(Enricher enricher) {
-            try {
-                delegate.onManaged(enricher);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onManaged("+enricher+"); continuing.",
t);
-            }
-        }
-
-        @Override
-        public void onChanged(Entity entity) {
-            try {
-                delegate.onChanged(entity);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onChanged("+entity+"); continuing.",
t);
-            }
-        }
-        
-        @Override
-        public void onUnmanaged(Entity entity) {
-            try {
-                delegate.onUnmanaged(entity);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onUnmanaged("+entity+"); continuing.",
t);
-            }
-        }
-
-        @Override
-        public void onUnmanaged(Location location) {
-            try {
-                delegate.onUnmanaged(location);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onUnmanaged("+location+"); continuing.",
t);
-            }
-        }
-
-        @Override
-        public void onUnmanaged(Policy policy) {
-            try {
-                delegate.onUnmanaged(policy);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onUnmanaged("+policy+"); continuing.",
t);
-            }
-        }
-
-        @Override
-        public void onUnmanaged(Enricher enricher) {
-            try {
-                delegate.onUnmanaged(enricher);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onUnmanaged("+enricher+"); continuing.",
t);
-            }
-        }
-
-        @Override
-        public void onChanged(Location location) {
-            try {
-                delegate.onChanged(location);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onChanged("+location+"); continuing.",
t);
-            }
-        }
-        
-        @Override
-        public void onChanged(Policy policy) {
-            try {
-                delegate.onChanged(policy);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onChanged("+policy+"); continuing.",
t);
-            }
-        }
-        
-        @Override
-        public void onChanged(Enricher enricher) {
-            try {
-                delegate.onChanged(enricher);
-            } catch (Throwable t) {
-                LOG.error("Error persisting mememento onChanged("+enricher+"); continuing.",
t);
+                LOG.error("Error persisting mememento onUnmanaged("+instance+"); continuing.",
t);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/AbstractLocation.java b/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
index f6657c8..9937e47 100644
--- a/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
+++ b/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
@@ -558,14 +558,6 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
     }
 
     @Override
-    public void requestPersist() {
-        // TODO Could add LocationChangeListener, similar to EntityChangeListener; should
we do that?
-        if (getManagementContext() != null) {
-            getManagementContext().getRebindManager().getChangeListener().onChanged(this);
-        }
-    }
-
-    @Override
     public RebindSupport<LocationMemento> getRebindSupport() {
         return new BasicLocationRebindSupport(this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/bf0b3e7d/core/src/main/java/brooklyn/policy/basic/AbstractPolicy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/policy/basic/AbstractPolicy.java b/core/src/main/java/brooklyn/policy/basic/AbstractPolicy.java
index 52fa5b9..1da196e 100644
--- a/core/src/main/java/brooklyn/policy/basic/AbstractPolicy.java
+++ b/core/src/main/java/brooklyn/policy/basic/AbstractPolicy.java
@@ -101,14 +101,6 @@ public abstract class AbstractPolicy extends AbstractEntityAdjunct implements
Po
     }
     
     @Override
-    protected void requestPersist() {
-        // TODO Could add PolicyChangeListener, similar to EntityChangeListener; should we
do that?
-        if (getManagementContext() != null) {
-            getManagementContext().getRebindManager().getChangeListener().onChanged(this);
-        }
-    }
-
-    @Override
     public RebindSupport<PolicyMemento> getRebindSupport() {
         return new BasicPolicyRebindSupport(this);
     }


Mime
View raw message