From 40f3283ee3c630efdcb5ef39a6eb8bcfed924797 Mon Sep 17 00:00:00 2001 From: Steven Glover Date: Wed, 24 Sep 2014 11:28:31 +0000 Subject: [PATCH] ACE-2816 "Ensure that Behaviour Bindings are Removed on Event Subsystem Stop" Fix up policy component class behaviour listeners for removal of behaviour git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85600 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/policy/BehaviourChangeObserver.java | 4 ++- .../alfresco/repo/policy/BehaviourMap.java | 6 +++- .../repo/policy/CachedPolicyFactory.java | 6 ++++ .../repo/policy/ClassBehaviourIndex.java | 35 +++++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/source/java/org/alfresco/repo/policy/BehaviourChangeObserver.java b/source/java/org/alfresco/repo/policy/BehaviourChangeObserver.java index c88f326d91..33c42a568e 100644 --- a/source/java/org/alfresco/repo/policy/BehaviourChangeObserver.java +++ b/source/java/org/alfresco/repo/policy/BehaviourChangeObserver.java @@ -34,5 +34,7 @@ package org.alfresco.repo.policy; * @param binding the binding * @param behaviour the behaviour attached to the binding */ - public void addition(B binding, Behaviour behaviour); + void addition(B binding, Behaviour behaviour); + + void removal(B binding, Behaviour behaviour); } diff --git a/source/java/org/alfresco/repo/policy/BehaviourMap.java b/source/java/org/alfresco/repo/policy/BehaviourMap.java index 9fc29d2c7d..dd4e509c81 100644 --- a/source/java/org/alfresco/repo/policy/BehaviourMap.java +++ b/source/java/org/alfresco/repo/policy/BehaviourMap.java @@ -95,8 +95,12 @@ import java.util.Map; { existing.remove(behaviourDefinition); size--; - } + for (BehaviourChangeObserver listener : observers) + { + listener.removal(binding, behaviourDefinition.getBehaviour()); + } + } } diff --git a/source/java/org/alfresco/repo/policy/CachedPolicyFactory.java b/source/java/org/alfresco/repo/policy/CachedPolicyFactory.java index ae7be50130..01daa3ace1 100644 --- a/source/java/org/alfresco/repo/policy/CachedPolicyFactory.java +++ b/source/java/org/alfresco/repo/policy/CachedPolicyFactory.java @@ -89,6 +89,12 @@ import org.apache.commons.logging.LogFactory; clearCache("aggregate delegate", singleCache, binding); clearCache("delegate collection", listCache, binding); } + + public void removal(B binding, Behaviour behaviour) + { + clearCache("aggregate delegate", singleCache, binding); + clearCache("delegate collection", listCache, binding); + } }); } diff --git a/source/java/org/alfresco/repo/policy/ClassBehaviourIndex.java b/source/java/org/alfresco/repo/policy/ClassBehaviourIndex.java index 4ac7b17203..3af61b8e8b 100644 --- a/source/java/org/alfresco/repo/policy/ClassBehaviourIndex.java +++ b/source/java/org/alfresco/repo/policy/ClassBehaviourIndex.java @@ -77,6 +77,33 @@ import org.alfresco.util.LockHelper; listener.addition(binding, behaviour); } } + + public void removal(B binding, Behaviour behaviour) + { + for (BehaviourChangeObserver listener : observers) + { + listener.removal(binding, behaviour); + } + } + }); + + this.classMap.addChangeObserver(new BehaviourChangeObserver() + { + public void addition(B binding, Behaviour behaviour) + { + for (BehaviourChangeObserver listener : observers) + { + listener.addition(binding, behaviour); + } + } + + public void removal(B binding, Behaviour behaviour) + { + for (BehaviourChangeObserver listener : observers) + { + listener.removal(binding, behaviour); + } + } }); // Observe service binding changes and propagate to our own observers @@ -90,6 +117,14 @@ import org.alfresco.util.LockHelper; listener.addition(null, behaviour); } } + + public void removal(ServiceBehaviourBinding binding, Behaviour behaviour) + { + for (BehaviourChangeObserver listener : observers) + { + listener.removal(null, behaviour); + } + } }); // Setup state