geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r1232780 - in /geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat: GeronimoStandardContext.java interceptor/RequestListenerBeforeAfter.java
Date Wed, 18 Jan 2012 08:13:02 GMT
Author: genspring
Date: Wed Jan 18 08:13:01 2012
New Revision: 1232780

URL: http://svn.apache.org/viewvc?rev=1232780&view=rev
Log:
GERONIMO-6264 Can't access geronimo Java:com jndi tree from javax.servlet.ServletRequestListener.requestInitialized(ServletRequestEvent)
- a workaround

Added:
    geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/RequestListenerBeforeAfter.java
Modified:
    geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java

Modified: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=1232780&r1=1232779&r2=1232780&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Wed Jan 18 08:13:01 2012
@@ -47,11 +47,15 @@ import javax.security.auth.Subject;
 import javax.security.auth.login.LoginException;
 import javax.security.jacc.PolicyContext;
 import javax.security.jacc.PolicyContextException;
+import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
 import javax.servlet.ServletContainerInitializer;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRegistration;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
 import javax.servlet.ServletSecurityElement;
 
 import org.apache.catalina.Container;
@@ -87,6 +91,7 @@ import org.apache.geronimo.tomcat.interc
 import org.apache.geronimo.tomcat.interceptor.ComponentContextBeforeAfter;
 import org.apache.geronimo.tomcat.interceptor.InstanceContextBeforeAfter;
 import org.apache.geronimo.tomcat.interceptor.PolicyContextBeforeAfter;
+import org.apache.geronimo.tomcat.interceptor.RequestListenerBeforeAfter;
 import org.apache.geronimo.tomcat.interceptor.UserTransactionBeforeAfter;
 import org.apache.geronimo.tomcat.interceptor.WebApplicationIdentityBeforeAfter;
 import org.apache.geronimo.tomcat.listener.DispatchListener;
@@ -104,6 +109,7 @@ import org.apache.geronimo.webservices.W
 import org.apache.geronimo.webservices.WebServiceContainerInvoker;
 import org.apache.naming.resources.FileDirContext;
 import org.apache.tomcat.InstanceManager;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.IntrospectionUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -283,7 +289,10 @@ public class GeronimoStandardContext ext
         }
 
         int index = 0;
-        BeforeAfter interceptor = new InstanceContextBeforeAfter(null,
+        
+        BeforeAfter interceptor = new RequestListenerBeforeAfter(null, index++);
+        
+        interceptor = new InstanceContextBeforeAfter(interceptor,
                 index++,
                 index++, ctx.getUnshareableResources(),
                 ctx.getApplicationManagedSecurityResources(),
@@ -1048,6 +1057,15 @@ public class GeronimoStandardContext ext
             }
         }
     }
+    
+    @Override
+    public boolean fireRequestInitEvent(ServletRequest request) {
+        return true;
+    } 
+    
+    public boolean fireRequestInitEventInBeforeAfter(ServletRequest request) {
+        return super.fireRequestInitEvent(request);
+    } 
 
     private static byte[] getChecksum(URL url) throws Exception {
         InputStream in = null;

Added: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/RequestListenerBeforeAfter.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/RequestListenerBeforeAfter.java?rev=1232780&view=auto
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/RequestListenerBeforeAfter.java
(added)
+++ geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/RequestListenerBeforeAfter.java
Wed Jan 18 08:13:01 2012
@@ -0,0 +1,61 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.tomcat.interceptor;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.geronimo.tomcat.GeronimoStandardContext;
+
+public class RequestListenerBeforeAfter implements BeforeAfter{
+    private final BeforeAfter next;
+    private final int index;
+
+    public RequestListenerBeforeAfter(BeforeAfter next, int index) {
+        this.next = next;
+        this.index = index;
+    }
+
+    public void before(BeforeAfterContext beforeAfterContext, ServletRequest httpRequest,
ServletResponse httpResponse, int dispatch) {
+
+            if (httpRequest instanceof org.apache.catalina.connector.Request){
+                
+                org.apache.catalina.connector.Request catalinaRequest = (org.apache.catalina.connector.Request)
httpRequest;
+
+                if (catalinaRequest.getContext() instanceof GeronimoStandardContext) {
+
+                    GeronimoStandardContext GeronimoContext = (GeronimoStandardContext) catalinaRequest.getContext();
+                    GeronimoContext.fireRequestInitEventInBeforeAfter(httpRequest);
+                }
+
+            }
+
+            if (next != null) {
+                next.before(beforeAfterContext, httpRequest, httpResponse, dispatch);
+            }
+
+    }
+    
+
+    public void after(BeforeAfterContext beforeAfterContext, ServletRequest httpRequest,
ServletResponse httpResponse, int dispatch) {
+       
+            if (next != null) {
+                next.after(beforeAfterContext, httpRequest, httpResponse, dispatch);
+            }
+    }
+
+}



Mime
View raw message