]> source.dussan.org Git - vaadin-framework.git/commitdiff
Send destroy event to the same listeners that got the init (#9273)
authorLeif Åstrand <leif@vaadin.com>
Mon, 13 Aug 2012 13:33:16 +0000 (16:33 +0300)
committerLeif Åstrand <leif@vaadin.com>
Mon, 13 Aug 2012 13:33:16 +0000 (16:33 +0300)
src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
src/com/vaadin/terminal/gwt/server/AddonContext.java

index f731cbbdd09c1515ac0339e76140bbe9d0972c9d..7b51712904fefc2bf0d505eb2c809506cc18fe52 100644 (file)
@@ -124,8 +124,8 @@ public abstract class AbstractDeploymentConfiguration implements
 
     @Override
     public Iterator<AddonContextListener> getAddonContextListeners() {
-        // Called once for init and once for destroy, so it's probably not worth
-        // the effort caching the ServiceLoader instance
+        // Called once for init and then no more, so there's no point in caching
+        // the instance
         ServiceLoader<AddonContextListener> contextListenerLoader = ServiceLoader
                 .load(AddonContextListener.class, getClassLoader());
         return contextListenerLoader.iterator();
index 0f887b0fbd18ad798b98ee392725383fd1210ae9..41e9046e2281f3b2e6b04911a26b4acfc14b9705 100644 (file)
@@ -25,6 +25,8 @@ public class AddonContext {
 
     private List<BootstrapListener> bootstrapListeners = new ArrayList<BootstrapListener>();
 
+    private List<AddonContextListener> initedListeners = new ArrayList<AddonContextListener>();
+
     public AddonContext(DeploymentConfiguration deploymentConfiguration) {
         this.deploymentConfiguration = deploymentConfiguration;
         deploymentConfiguration.setAddonContext(this);
@@ -41,15 +43,13 @@ public class AddonContext {
         while (listeners.hasNext()) {
             AddonContextListener listener = listeners.next();
             listener.contextCreated(event);
+            initedListeners.add(listener);
         }
     }
 
     public void destroy() {
         AddonContextEvent event = new AddonContextEvent(this);
-        Iterator<AddonContextListener> listeners = deploymentConfiguration
-                .getAddonContextListeners();
-        while (listeners.hasNext()) {
-            AddonContextListener listener = listeners.next();
+        for (AddonContextListener listener : initedListeners) {
             listener.contextDestoryed(event);
         }
     }