Author: jmarino
Date: Sun May 14 13:12:11 2006
New Revision: 406412
URL: http://svn.apache.org/viewcvs?rev=406412&view=rev
Log:
fix fo TUSCANY-367
Modified:
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
Modified:
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java?rev=406412&r1=406411&r2=406412&view=diff
==============================================================================
---
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
(original)
+++
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
Sun May 14 13:12:11 2006
@@ -22,7 +22,6 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Valve;
import org.apache.catalina.util.StringManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,6 +53,7 @@
private final AssemblyModelLoader modelLoader;
private final RuntimeContext runtime;
private CompositeContext moduleContext;
+ private TuscanyValve valve;
public TuscanyContextListener(RuntimeContext runtimeContext,
AssemblyFactory modelFactory, AssemblyModelLoader modelLoader) {
this.runtime = runtimeContext;
@@ -98,16 +98,13 @@
throw e;
}
- // hack for TUSCANY-367
- Valve[] valves = ctx.getPipeline().getValves();
- for (Valve valve : valves) {
- if (valve instanceof TuscanyValve){
- ctx.getPipeline().removeValve(valve);
- }
- }
-
// add a valve to this context's pipeline that will associate the
request with the runtime
- Valve valve = new TuscanyValve(moduleContext);
+ if (valve == null) {
+ valve = new TuscanyValve(moduleContext);
+ } else {
+ valve.setContext(moduleContext);
+ valve.setEnabled(true);
+ }
ctx.getPipeline().addValve(valve);
// add the RuntimeContext in as a servlet context parameter
ServletContext servletContext = ctx.getServletContext();
@@ -144,6 +141,9 @@
}
CompositeContext rootContext = runtime.getRootContext();
rootContext.removeContext(moduleContext.getName());
+ valve.setEnabled(false);
+ //ctx.getPipeline().removeValve(valve);
+ //valve = null;
moduleContext.stop();
moduleContext = null;
// todo unload module component from runtime
Modified:
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java?rev=406412&r1=406411&r2=406412&view=diff
==============================================================================
---
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
(original)
+++
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
Sun May 14 13:12:11 2006
@@ -46,16 +46,28 @@
private static final ContextBinder BINDER = new ContextBinder();
- private final CompositeContext moduleComponentContext;
+ private CompositeContext moduleComponentContext;
+
+ private boolean enabled = true;
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public void setContext(CompositeContext moduleComponentContext) {
+ this.moduleComponentContext = moduleComponentContext;
+ }
public TuscanyValve(CompositeContext moduleComponentContext) {
this.moduleComponentContext = moduleComponentContext;
}
public void invoke(Request request, Response response) throws IOException,
ServletException {
+ if (!enabled){
+ return;
+ }
Object oldRequestId = request.getNote(REQUEST_ID);
ModuleContext oldContext = CurrentModuleContext.getContext();
-
// bind the current module context to the thread for use by
CurrentModuleContext
BINDER.setContext((ModuleContext) moduleComponentContext);
try {