From 7aada6b7e84f39478b89f71fecdae39efed4147e Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 25 Nov 2009 14:26:16 +0000 Subject: [PATCH] Refactored old PortletApplicationContext a little and fixed removeApplication() svn changeset:10024/svn branch:6.2 --- .../gwt/server/PortletApplicationContext.java | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java index 0e3289dea6..65fe91a267 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java @@ -1,11 +1,10 @@ /** - * + * */ package com.vaadin.terminal.gwt.server; import java.io.Serializable; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -31,9 +30,9 @@ public class PortletApplicationContext extends WebApplicationContext implements protected PortletSession portletSession; - protected Map portletListeners = new HashMap(); + protected Map> portletListeners = new HashMap>(); - protected Map portletToApplication = new HashMap(); + protected Map portletToApplication = new HashMap(); PortletApplicationContext() { @@ -84,10 +83,8 @@ public class PortletApplicationContext extends WebApplicationContext implements @Override protected void removeApplication(Application application) { portletListeners.remove(application); - for (Iterator it = portletToApplication.keySet().iterator(); it - .hasNext();) { - Object key = it.next(); - if (key == application) { + for (Portlet key : portletToApplication.keySet()) { + if (portletToApplication.get(key) == application) { portletToApplication.remove(key); } } @@ -99,7 +96,7 @@ public class PortletApplicationContext extends WebApplicationContext implements } public Application getPortletApplication(Portlet portlet) { - return (Application) portletToApplication.get(portlet); + return portletToApplication.get(portlet); } public PortletSession getPortletSession() { @@ -107,16 +104,16 @@ public class PortletApplicationContext extends WebApplicationContext implements } public void addPortletListener(Application app, PortletListener listener) { - Set l = (Set) portletListeners.get(app); + Set l = portletListeners.get(app); if (l == null) { - l = new LinkedHashSet(); + l = new LinkedHashSet(); portletListeners.put(app, l); } l.add(listener); } public void removePortletListener(Application app, PortletListener listener) { - Set l = (Set) portletListeners.get(app); + Set l = portletListeners.get(app); if (l != null) { l.remove(listener); } @@ -143,10 +140,9 @@ public class PortletApplicationContext extends WebApplicationContext implements public void firePortletRenderRequest(Portlet portlet, RenderRequest request, RenderResponse response) { Application app = getPortletApplication(portlet); - Set listeners = (Set) portletListeners.get(app); + Set listeners = portletListeners.get(app); if (listeners != null) { - for (Iterator it = listeners.iterator(); it.hasNext();) { - PortletListener l = (PortletListener) it.next(); + for (PortletListener l : listeners) { l.handleRenderRequest(request, new RestrictedRenderResponse( response)); } @@ -156,10 +152,9 @@ public class PortletApplicationContext extends WebApplicationContext implements public void firePortletActionRequest(Portlet portlet, ActionRequest request, ActionResponse response) { Application app = getPortletApplication(portlet); - Set listeners = (Set) portletListeners.get(app); + Set listeners = portletListeners.get(app); if (listeners != null) { - for (Iterator it = listeners.iterator(); it.hasNext();) { - PortletListener l = (PortletListener) it.next(); + for (PortletListener l : listeners) { l.handleActionRequest(request, response); } } -- 2.39.5