struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r722386 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
Date Tue, 02 Dec 2008 06:41:53 GMT
Author: wesw
Date: Mon Dec  1 22:41:52 2008
New Revision: 722386

URL: http://svn.apache.org/viewvc?rev=722386&view=rev
Log:
incorporating Concurrency API. Per WW-2880, thanks for the patch Mathias Bogaert

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?rev=722386&r1=722385&r2=722386&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
Mon Dec  1 22:41:52 2008
@@ -31,6 +31,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -105,7 +106,7 @@
      * Store list of DispatcherListeners.
      */
     private static List<DispatcherListener> dispatcherListeners =
-        new ArrayList<DispatcherListener>();
+        new CopyOnWriteArrayList<DispatcherListener>();
 
     /**
      * Store ConfigurationManager instance, set on init.
@@ -169,7 +170,7 @@
      *
      * @param listener The listener to add
      */
-    public static synchronized void addDispatcherListener(DispatcherListener listener) {
+    public static void addDispatcherListener(DispatcherListener listener) {
         dispatcherListeners.add(listener);
     }
 
@@ -178,7 +179,7 @@
      *
      * @param listener The listener
      */
-    public static synchronized void removeDispatcherListener(DispatcherListener listener)
{
+    public static void removeDispatcherListener(DispatcherListener listener) {
         dispatcherListeners.remove(listener);
     }
 
@@ -264,11 +265,9 @@
         instance.set(null);
 
         // clean up DispatcherListeners
-        synchronized(Dispatcher.class) {
-            if (dispatcherListeners.size() > 0) {
-                for (DispatcherListener l : dispatcherListeners) {
-                    l.dispatcherDestroyed(this);
-                }
+        if (!dispatcherListeners.isEmpty()) {
+            for (DispatcherListener l : dispatcherListeners) {
+                l.dispatcherDestroyed(this);
             }
         }
 
@@ -382,15 +381,6 @@
             paramsWorkaroundEnabled = "true".equals(container.getInstance(String.class,
                     StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND));
         }
-
-        synchronized(Dispatcher.class) {
-            if (dispatcherListeners.size() > 0) {
-                for (DispatcherListener l : dispatcherListeners) {
-                    l.dispatcherInitialized(this);
-                }
-            }
-        }
-
     }
 
     /**
@@ -415,6 +405,11 @@
         init_CheckConfigurationReloading(container);
         init_CheckWebLogicWorkaround(container);
 
+        if (!dispatcherListeners.isEmpty()) {
+            for (DispatcherListener l : dispatcherListeners) {
+                l.dispatcherInitialized(this);
+            }
+        }
     }
 
     /**



Mime
View raw message