You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jg...@apache.org on 2005/11/07 04:03:41 UTC
svn commit: r331186 - in
/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat:
GeronimoStandardContext.java TomcatContainer.java
Author: jgenender
Date: Sun Nov 6 19:03:24 2005
New Revision: 331186
URL: http://svn.apache.org/viewcvs?rev=331186&view=rev
Log:
Fix for GERONIMO-1131
Modified:
geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=331186&r1=331185&r2=331186&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java Sun Nov 6 19:03:24 2005
@@ -24,12 +24,18 @@
import javax.security.auth.Subject;
import javax.security.jacc.PolicyContext;
import javax.servlet.Servlet;
+import javax.servlet.ServletException;
import org.apache.catalina.Container;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Valve;
import org.apache.catalina.Wrapper;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ValveBase;
import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardPipeline;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -65,8 +71,9 @@
private Map webServiceMap = null;
- public void setContextProperties(TomcatContext ctx) throws DeploymentException {
+ private boolean pipelineInitialized;
+ public void setContextProperties(TomcatContext ctx) throws DeploymentException {
// Create ReadOnlyContext
javax.naming.Context enc = null;
Map componentContext = ctx.getComponentContext();
@@ -90,8 +97,8 @@
//Set the InstanceContextValve
InstanceContextValve instanceContextValve =
new InstanceContextValve(ctx.getUnshareableResources(),
- ctx.getApplicationManagedSecurityResources(),
- ctx.getTrackedConnectionAssociator());
+ ctx.getApplicationManagedSecurityResources(),
+ ctx.getTrackedConnectionAssociator());
addValve(instanceContextValve);
// Set ComponentContext valve
@@ -103,8 +110,7 @@
// Set TransactionContextValve
TransactionContextManager transactionContextManager = ctx.getTransactionContextManager();
if (transactionContextManager != null) {
- TransactionContextValve transactionValve = new TransactionContextValve(
- transactionContextManager);
+ TransactionContextValve transactionValve = new TransactionContextValve(transactionContextManager);
addValve(transactionValve);
}
@@ -126,25 +132,30 @@
defaultSubject.getPrincipals().add(new IdentificationPrincipal(id));
}
- PolicyContextValve policyValve = new PolicyContextValve(
- securityHolder.getPolicyContextID());
+ PolicyContextValve policyValve = new PolicyContextValve(securityHolder.getPolicyContextID());
addValve(policyValve);
//This is definitely a hack, but I don't see a reasonable way to install the defaultSubject.
//Obviously this won't work if there are permissions. Setting the default subject if there are
//permissions breaks authentication.
boolean hasPermissions = securityHolder.getChecked().elements().hasMoreElements() ||
- securityHolder.getExcluded().elements().hasMoreElements();
+ securityHolder.getExcluded().elements().hasMoreElements();
+ Valve defaultSubjectValve;
if (!hasPermissions && defaultSubject != null) {
- Valve defaultSubjectValve = new DefaultSubjectValve(defaultSubject);
- addValve(defaultSubjectValve);
+ defaultSubjectValve = new DefaultSubjectValve(defaultSubject);
} else {
//this will clear the thread of any read subject added by some other web app
- addValve(new DefaultSubjectValve(null));
+ defaultSubjectValve = new DefaultSubjectValve(null);
}
+ addValve(defaultSubjectValve);
}
}
+ //Not clear if user defined valves should be involved in init processing. Probably not since
+ //request and response are null.
+
+ addValve(new SystemMethodValve());
+
// Add User Defined Valves
List valveChain = ctx.getValveChain();
if (valveChain != null) {
@@ -154,14 +165,27 @@
addValve(valve);
}
}
-
+ pipelineInitialized = true;
this.webServiceMap = ctx.getWebServices();
this.setCrossContext(ctx.isCrossContext());
}
public synchronized void start() throws LifecycleException {
- super.start();
+ if (pipelineInitialized) {
+ try {
+ Valve valve = getFirst();
+ valve.invoke(null, null);
+ } catch (IOException e) {
+ if (e.getCause() instanceof LifecycleException) {
+ throw (LifecycleException) e.getCause();
+ }
+ throw new LifecycleException(e);
+ } catch (ServletException e) {
+ throw new LifecycleException(e);
+ }
+ } else
+ super.start();
}
public synchronized void stop() throws LifecycleException {
@@ -172,7 +196,7 @@
super.stop();
}
-
+
public void addChild(Container child) {
Wrapper wrapper = (Wrapper) child;
@@ -223,5 +247,22 @@
}
super.addChild(child);
+ }
+
+
+ private class SystemMethodValve extends ValveBase {
+
+ public void invoke(Request request, Response response) throws IOException, ServletException {
+ if (request == null && response == null) {
+ try {
+ GeronimoStandardContext.super.start();
+ } catch (LifecycleException e) {
+ throw (IOException) new IOException("wrapping lifecycle exception").initCause(e);
+ }
+ } else {
+ getNext().invoke(request, response);
+ }
+
+ }
}
}
Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=331186&r1=331185&r2=331186&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java Sun Nov 6 19:03:24 2005
@@ -291,8 +291,9 @@
Context context = ctx.getContext();
if (context != null){
- if (context instanceof StandardContext){
- StandardContext stdctx = (StandardContext)context;
+ if (context instanceof GeronimoStandardContext){
+ GeronimoStandardContext stdctx = (GeronimoStandardContext)context;
+
try{
stdctx.stop();
stdctx.destroy();