You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by pb...@apache.org on 2008/11/26 17:09:25 UTC

svn commit: r720908 - /struts/struts1/trunk/core/src/main/java/org/apache/struts/dispatcher/AbstractDispatcher.java

Author: pbenedict
Date: Wed Nov 26 08:09:25 2008
New Revision: 720908

URL: http://svn.apache.org/viewvc?rev=720908&view=rev
Log:
STR-3168: Serialize the dispatcher and exclude its cache

Modified:
    struts/struts1/trunk/core/src/main/java/org/apache/struts/dispatcher/AbstractDispatcher.java

Modified: struts/struts1/trunk/core/src/main/java/org/apache/struts/dispatcher/AbstractDispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/dispatcher/AbstractDispatcher.java?rev=720908&r1=720907&r2=720908&view=diff
==============================================================================
--- struts/struts1/trunk/core/src/main/java/org/apache/struts/dispatcher/AbstractDispatcher.java (original)
+++ struts/struts1/trunk/core/src/main/java/org/apache/struts/dispatcher/AbstractDispatcher.java Wed Nov 26 08:09:25 2008
@@ -26,6 +26,7 @@
 import org.apache.struts.config.ActionConfig;
 import org.apache.struts.util.MessageResources;
 
+import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.HashMap;
@@ -43,7 +44,7 @@
  * @version $Rev$
  * @since Struts 1.4
  */
-public abstract class AbstractDispatcher implements Dispatcher {
+public abstract class AbstractDispatcher implements Dispatcher, Serializable {
 
     // Package message bundle keys
     static final String LOCAL_STRINGS = "org.apache.struts.dispatcher.LocalStrings";
@@ -84,7 +85,7 @@
      * methods are called, so that introspection needs to occur only once per
      * method name.
      */
-    private final HashMap methods;
+    private transient final HashMap methods;
 
     /**
      * Construct a new dispatcher.
@@ -157,7 +158,12 @@
      */
     protected abstract Object dispatchMethod(ActionContext context, Method method, String name) throws Exception;
 
-    protected final void flushMethodCache() {
+    /**
+     * Empties the method cache.
+     * 
+     * @see #getMethod(ActionContext, String)
+     */
+    final void flushMethodCache() {
 	synchronized (methods) {
 	    methods.clear();
 	}
@@ -189,6 +195,7 @@
      */
     protected final Method getMethod(ActionContext context, String methodName) throws NoSuchMethodException {
 	synchronized (methods) {
+	    // Key the method based on the class-method combination
 	    StringBuffer keyBuf = new StringBuffer(100);
 	    keyBuf.append(context.getAction().getClass().getName());
 	    keyBuf.append(":");