Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47299
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 5 Jun 2009 21:38:44 +0000 (21:38 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 5 Jun 2009 21:38:44 +0000 (21:38 +0000)
Simplify fireContainerEvent method and enable it to work with implementations that extend StandardContext.
See http://svn.apache.org/viewvc?view=rev&revision=287710 for why it was written this way originally.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@782145 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/session/StandardSession.java

index 09cafd2..1833fce 100644 (file)
@@ -25,7 +25,6 @@ import java.io.NotSerializableException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.Principal;
 import java.security.PrivilegedAction;
@@ -57,6 +56,7 @@ import org.apache.catalina.SessionListener;
 import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.StringManager;
 
+import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.security.SecurityUtil;
 
 /**
@@ -142,24 +142,6 @@ public class StandardSession
 
 
     /**
-     * The <code>java.lang.Method</code> for the
-     * <code>fireContainerEvent()</code> method of the
-     * <code>org.apache.catalina.core.StandardContext</code> method,
-     * if our Context implementation is of this class.  This value is
-     * computed dynamically the first time it is needed, or after
-     * a session reload (since it is declared transient).
-     */
-    protected transient Method containerEventMethod = null;
-
-
-    /**
-     * The method signature for the <code>fireContainerEvent</code> method.
-     */
-    protected static final Class<?> containerEventTypes[] =
-        { String.class, Object.class };
-
-
-    /**
      * The time this session was created, in milliseconds since midnight,
      * January 1, 1970 GMT.
      */
@@ -1594,21 +1576,10 @@ public class StandardSession
                                     String type, Object data)
         throws Exception {
 
-        if (!"org.apache.catalina.core.StandardContext".equals
-            (context.getClass().getName())) {
-            return; // Container events are not supported
+        if (context instanceof StandardContext) {
+            // NOTE:  Race condition is harmless, so do not synchronize
+            ((StandardContext) context).fireContainerEvent(type, data);
         }
-        // NOTE:  Race condition is harmless, so do not synchronize
-        if (containerEventMethod == null) {
-            containerEventMethod =
-                context.getClass().getMethod("fireContainerEvent",
-                                             containerEventTypes);
-        }
-        Object containerEventParams[] = new Object[2];
-        containerEventParams[0] = type;
-        containerEventParams[1] = data;
-        containerEventMethod.invoke(context, containerEventParams);
-
     }