From 4a1d729534e1232088529afcd48360d868093a67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Mon, 13 Aug 2012 16:33:16 +0300 Subject: [PATCH] Send destroy event to the same listeners that got the init (#9273) --- .../gwt/server/AbstractDeploymentConfiguration.java | 4 ++-- src/com/vaadin/terminal/gwt/server/AddonContext.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java b/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java index f731cbbdd0..7b51712904 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java @@ -124,8 +124,8 @@ public abstract class AbstractDeploymentConfiguration implements @Override public Iterator 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 contextListenerLoader = ServiceLoader .load(AddonContextListener.class, getClassLoader()); return contextListenerLoader.iterator(); diff --git a/src/com/vaadin/terminal/gwt/server/AddonContext.java b/src/com/vaadin/terminal/gwt/server/AddonContext.java index 0f887b0fbd..41e9046e22 100644 --- a/src/com/vaadin/terminal/gwt/server/AddonContext.java +++ b/src/com/vaadin/terminal/gwt/server/AddonContext.java @@ -25,6 +25,8 @@ public class AddonContext { private List bootstrapListeners = new ArrayList(); + private List initedListeners = new ArrayList(); + 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 listeners = deploymentConfiguration - .getAddonContextListeners(); - while (listeners.hasNext()) { - AddonContextListener listener = listeners.next(); + for (AddonContextListener listener : initedListeners) { listener.contextDestoryed(event); } } -- 2.39.5