You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2012/02/06 11:02:19 UTC
svn commit: r1240956 - in
/geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat:
./ interceptor/
Author: xuhaihong
Date: Mon Feb 6 10:02:18 2012
New Revision: 1240956
URL: http://svn.apache.org/viewvc?rev=1240956&view=rev
Log:
GERONIMO-6266 The jndi prefix URL could not work before the web application is totally started
Added:
geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java (with props)
Modified:
geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
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
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=1240956&r1=1240955&r2=1240956&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 Mon Feb 6 10:02:18 2012
@@ -290,7 +290,7 @@ public class GeronimoStandardContext ext
int index = 0;
- BeforeAfter interceptor = new RequestListenerBeforeAfter(null, index++);
+ BeforeAfter interceptor = new RequestListenerBeforeAfter(null, index++, this);
interceptor = new InstanceContextBeforeAfter(interceptor,
index++,
@@ -576,70 +576,7 @@ public class GeronimoStandardContext ext
@Override
public synchronized void setLoader(final Loader delegate) {
- Loader loader = new Loader() {
-
- public void backgroundProcess() {
- delegate.backgroundProcess();
- }
-
- public ClassLoader getClassLoader() {
- // Implementation Note: the actual CL to be used by this
- // context is the Geronimo one and not the Tomcat one.
- return parentClassLoader;
- }
-
- public Container getContainer() {
- return delegate.getContainer();
- }
-
- public void setContainer(Container container) {
- delegate.setContainer(container);
- }
-
- public boolean getDelegate() {
- return delegate.getDelegate();
- }
-
- public void setDelegate(boolean delegateBoolean) {
- delegate.setDelegate(delegateBoolean);
- }
-
- public String getInfo() {
- return delegate.getInfo();
- }
-
- public boolean getReloadable() {
- return false;
- }
-
- public void setReloadable(boolean reloadable) {
- if (reloadable) {
- throw new UnsupportedOperationException("Reloadable context is not supported.");
- }
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- delegate.addPropertyChangeListener(listener);
- }
-
- public void addRepository(String repository) {
- delegate.addRepository(repository);
- }
-
- public String[] findRepositories() {
- return delegate.findRepositories();
- }
-
- public boolean modified() {
- return delegate.modified();
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- delegate.removePropertyChangeListener(listener);
- }
- };
-
- super.setLoader(loader);
+ super.setLoader(new GeronimoWebAppLoader(this, delegate));
}
public ServletContext getInternalServletContext() {
Added: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java?rev=1240956&view=auto
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java (added)
+++ geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java Mon Feb 6 10:02:18 2012
@@ -0,0 +1,140 @@
+/**
+ * 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;
+
+import java.beans.PropertyChangeListener;
+
+import javax.naming.directory.DirContext;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleState;
+import org.apache.catalina.Loader;
+import org.apache.catalina.util.LifecycleBase;
+import org.apache.naming.resources.DirContextURLStreamHandler;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoWebAppLoader extends LifecycleBase implements Loader {
+
+ private final Loader delegate;
+
+ private final GeronimoStandardContext standardContext;
+
+ public GeronimoWebAppLoader(GeronimoStandardContext standardContext, Loader delegate) {
+ this.delegate = delegate;
+ this.standardContext = standardContext;
+ }
+
+ @Override
+ public void backgroundProcess() {
+ delegate.backgroundProcess();
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return standardContext.getParentClassLoader();
+ }
+
+ @Override
+ public Container getContainer() {
+ return delegate.getContainer();
+ }
+
+ @Override
+ public void setContainer(Container container) {
+ delegate.setContainer(container);
+ }
+
+ @Override
+ public boolean getDelegate() {
+ return delegate.getDelegate();
+ }
+
+ @Override
+ public void setDelegate(boolean delegateBoolean) {
+ delegate.setDelegate(delegateBoolean);
+ }
+
+ @Override
+ public String getInfo() {
+ return delegate.getInfo();
+ }
+
+ @Override
+ public boolean getReloadable() {
+ return false;
+ }
+
+ @Override
+ public void setReloadable(boolean reloadable) {
+ if (reloadable) {
+ throw new UnsupportedOperationException("Reloadable context is not supported.");
+ }
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ delegate.addPropertyChangeListener(listener);
+ }
+
+ @Override
+ public void addRepository(String repository) {
+ delegate.addRepository(repository);
+ }
+
+ @Override
+ public String[] findRepositories() {
+ return delegate.findRepositories();
+ }
+
+ @Override
+ public boolean modified() {
+ return delegate.modified();
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ delegate.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ protected void startInternal() throws LifecycleException {
+ DirContext resources = delegate.getContainer().getResources();
+ if (resources == null) {
+ throw new IllegalStateException("JNDI environment was not set up correctly due to previous error");
+ }
+ DirContextURLStreamHandler.bind(standardContext.getParentClassLoader(), resources);
+ setState(LifecycleState.STARTING);
+ }
+
+ @Override
+ protected void stopInternal() throws LifecycleException {
+ setState(LifecycleState.STOPPING);
+ DirContextURLStreamHandler.unbind(standardContext.getParentClassLoader());
+ }
+
+ @Override
+ protected void destroyInternal() throws LifecycleException {
+ }
+
+ @Override
+ protected void initInternal() throws LifecycleException {
+ }
+}
Propchange: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoWebAppLoader.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=1240956&r1=1240955&r2=1240956&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java (original)
+++ geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java Mon Feb 6 10:02:18 2012
@@ -564,12 +564,6 @@ public class TomcatWebAppContext impleme
container.addContext(this);
// Is it necessary - doesn't Tomcat Embedded take care of it?
// super.start();
- //register the classloader <> dir context association so that tomcat's jndi based getResources works.
- DirContext resources = context.getResources();
- if (resources == null) {
- throw new IllegalStateException("JNDI environment was not set up correctly due to previous error");
- }
- DirContextURLStreamHandler.bind(classLoader, resources);
if (context instanceof StandardContext) {
statsProvider = new ModuleStats((StandardContext) context);
}
@@ -584,7 +578,6 @@ public class TomcatWebAppContext impleme
public void doStop() throws Exception {
statsProvider = null;
container.removeContext(this);
- DirContextURLStreamHandler.unbind(classLoader);
log.debug("TomcatWebAppContext stopped");
}
Modified: 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=1240956&r1=1240955&r2=1240956&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/RequestListenerBeforeAfter.java (original)
+++ geronimo/server/branches/3.0-beta/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/RequestListenerBeforeAfter.java Mon Feb 6 10:02:18 2012
@@ -24,35 +24,24 @@ import org.apache.geronimo.tomcat.Geroni
public class RequestListenerBeforeAfter implements BeforeAfter{
private final BeforeAfter next;
private final int index;
+ private final GeronimoStandardContext standardContext;
- public RequestListenerBeforeAfter(BeforeAfter next, int index) {
+ public RequestListenerBeforeAfter(BeforeAfter next, int index, GeronimoStandardContext standardContext) {
this.next = next;
this.index = index;
+ this.standardContext = standardContext;
}
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);
- }
+ standardContext.fireRequestInitEventInBeforeAfter(httpRequest);
+ if (next != null) {
+ next.before(beforeAfterContext, httpRequest, httpResponse, dispatch);
+ }
}
- public void after(BeforeAfterContext beforeAfterContext, ServletRequest httpRequest, ServletResponse httpResponse, int dispatch) {
-
+ public void after(BeforeAfterContext beforeAfterContext, ServletRequest httpRequest, ServletResponse httpResponse, int dispatch) {
if (next != null) {
next.after(beforeAfterContext, httpRequest, httpResponse, dispatch);
}