You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2004/12/04 07:10:15 UTC
svn commit: r109779 - in geronimo/branches/djencks/jetty-deployer1/trunk: etc modules/assembly modules/assembly/src/plan modules/jetty modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF modules/jetty/src/etc/META-INF modules/jetty/src/java/org/apache/geronimo/jetty modules/jetty/src/java/org/apache/geronimo/jetty/interceptor modules/jetty/src/test/org/apache/geronimo/jetty
Author: djencks
Date: Fri Dec 3 22:10:14 2004
New Revision: 109779
URL: http://svn.apache.org/viewcvs?view=rev&rev=109779
Log:
Use interceptors to partly solve GERONIMO-488. Use eclipse compiler for jsps. Use jasper 5.5.4 for easier use of eclipse compiler. Jsps now generally work
Added:
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/BeforeAfter.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ThreadClassloaderBeforeAfter.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java
Removed:
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/etc/META-INF/geronimo-service.xml
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/BaseSecurityTest.java
Modified:
geronimo/branches/djencks/jetty-deployer1/trunk/etc/version-info.ent
geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/project.xml
geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/src/plan/j2ee-server-plan.xml
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF/web.xml
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/project.xml
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletRegistration.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/etc/version-info.ent
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/etc/version-info.ent?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/etc/version-info.ent&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/etc/version-info.ent&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/etc/version-info.ent (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/etc/version-info.ent Fri Dec 3 22:10:14 2004
@@ -18,7 +18,7 @@
<!ENTITY geronimo-spec-j2ee-management-version "1.0-rc3">
<!ENTITY geronimo-spec-javamail-version "1.3.1-rc3">
<!ENTITY geronimo-spec-jaxr-version "1.0-rc3">
-<!ENTITY geronimo-spec-jms-version "1.1-SNAPSHOT">
+<!ENTITY geronimo-spec-jms-version "1.1-rc3">
<!ENTITY geronimo-spec-jsp-version "2.0-rc3">
<!ENTITY geronimo-spec-jta-version "1.0.1B-rc3">
<!ENTITY geronimo-spec-servlet-version "2.4-rc3">
@@ -57,11 +57,12 @@
<!ENTITY derby-version "47170">
<!ENTITY dom4j-version "1.4">
<!ENTITY drools-version "2.0-beta-13">
+<!ENTITY eclipse-compiler-version "3.0.1">
<!ENTITY emberio-version "0.3-alpha">
<!ENTITY ews-version "SNAPSHOT">
<!ENTITY howl-version "0.1.8-SNAPSHOT">
<!ENTITY hsqldb-version "1.7.2.2">
-<!ENTITY jasper-version "5.0.28">
+<!ENTITY jasper-version "5.5.4">
<!ENTITY javacc-version "2.1">
<!ENTITY jaxb-ri-version "SNAPSHOT">
<!ENTITY jdbm-version "0.20-dev">
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/project.xml
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/project.xml?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/project.xml&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/project.xml&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/project.xml (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/project.xml Fri Dec 3 22:10:14 2004
@@ -699,7 +699,16 @@
<dependency>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler</artifactId>
- <version>&tomcat-version;</version>
+ <version>&jasper-version;</version>
+ <properties>
+ <repository>true</repository>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler-jdt</artifactId>
+ <version>&jasper-version;</version>
<properties>
<repository>true</repository>
</properties>
@@ -708,11 +717,30 @@
<dependency>
<groupId>tomcat</groupId>
<artifactId>jasper-runtime</artifactId>
- <version>&tomcat-version;</version>
+ <version>&jasper-version;</version>
+ <properties>
+ <repository>true</repository>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>eclipse</groupId>
+ <artifactId>jdtcore</artifactId>
+ <version>&eclipse-compiler-version;</version>
+ <properties>
+ <repository>true</repository>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>eclipse</groupId>
+ <artifactId>jdtCompilerAdapter</artifactId>
+ <version>&eclipse-compiler-version;</version>
<properties>
<repository>true</repository>
</properties>
</dependency>
+
<!-- demo apps that should be moved out of assembly -->
<dependency>
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/src/plan/j2ee-server-plan.xml
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/src/plan/j2ee-server-plan.xml?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/src/plan/j2ee-server-plan.xml&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/src/plan/j2ee-server-plan.xml&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/src/plan/j2ee-server-plan.xml (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/assembly/src/plan/j2ee-server-plan.xml Fri Dec 3 22:10:14 2004
@@ -106,14 +106,23 @@
<uri>tomcat/jars/jasper-compiler-${jasper_version}.jar</uri>
</dependency>
<dependency>
+ <uri>tomcat/jars/jasper-compiler-jdt-${jasper_version}.jar</uri>
+ </dependency>
+ <dependency>
<uri>tomcat/jars/jasper-runtime-${jasper_version}.jar</uri>
</dependency>
<dependency>
- <uri>commons-el/jars/commons-el-${commons_el_version}.jar</uri>
+ <uri>eclipse/jars/jdtcore-${eclipse_compiler_version}.jar</uri>
</dependency>
<dependency>
- <uri>ant/jars/ant-${ant_version}.jar</uri>
+ <uri>eclipse/jars/jdtCompilerAdapter-${eclipse_compiler_version}.jar</uri>
+ </dependency>
+ <dependency>
+ <uri>commons-el/jars/commons-el-${commons_el_version}.jar</uri>
</dependency>
+ <!-- <dependency>-->
+ <!-- <uri>ant/jars/ant-${ant_version}.jar</uri>-->
+ <!-- </dependency>-->
<!-- Default security realm using properties files -->
<gbean name="geronimo.security:type=LoginModule,name=properties-login"
@@ -128,7 +137,7 @@
</gbean>
<gbean name="geronimo.security:type=SecurityRealm,realm=geronimo-properties-realm"
- class="org.apache.geronimo.security.realm.GenericSecurityRealm">
+ class="org.apache.geronimo.security.realm.GenericSecurityRealm">
<attribute name="realmName" type="java.lang.String">geronimo-properties-realm</attribute>
<attribute name="loginModuleConfiguration" type="java.util.Properties">
LoginModule.1.REQUIRED=geronimo.security:type=LoginModule,name=properties-login
@@ -138,7 +147,7 @@
</gbean>
<gbean name="geronimo.security:type=ConfigurationEntry,jaasId=JMX"
- class="org.apache.geronimo.security.jaas.ServerRealmConfigurationEntry">
+ class="org.apache.geronimo.security.jaas.ServerRealmConfigurationEntry">
<attribute name="applicationConfigName" type="java.lang.String">JMX</attribute>
<attribute name="realmName" type="java.lang.String">geronimo-properties-realm</attribute>
</gbean>
@@ -158,7 +167,7 @@
<gbean name="geronimo.security:type=JaasLoginService" class="org.apache.geronimo.security.jaas.JaasLoginService">
<reference name="Realms">geronimo.security:type=SecurityRealm,*</reference>
-<!-- <attribute name="reclaimPeriod" type="long">100000</attribute>-->
+ <!-- <attribute name="reclaimPeriod" type="long">100000</attribute>-->
<attribute name="algorithm" type="java.lang.String">HmacSHA1</attribute>
<attribute name="password" type="java.lang.String">secret</attribute>
</gbean>
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Fri Dec 3 22:10:14 2004
@@ -474,7 +474,7 @@
TaglibType[] tagLibArray = jspConfigArray[i].getTaglibArray();
for (int j = 0; j < tagLibArray.length; j++) {
TaglibType taglib = tagLibArray[j];
- tagLibMap.put(taglib.getTaglibUri(), taglib.getTaglibLocation().getStringValue());
+ tagLibMap.put(taglib.getTaglibUri().getStringValue().trim(), taglib.getTaglibLocation().getStringValue().trim());
}
}
webModuleData.setAttribute("tagLibMap", tagLibMap);
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF/web.xml
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF/web.xml?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF/web.xml&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF/web.xml&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF/web.xml (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty-builder/src/test-resources/deployables/war4/WEB-INF/web.xml Fri Dec 3 22:10:14 2004
@@ -1,47 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <display-name>war4</display-name>
- <filter>
- <filter-name>Filter1</filter-name>
- <filter-class>org.apache.geronimo.jetty.app.Filter1</filter-class>
- <init-param>
- <param-name>attribute1</param-name>
- <param-value>value1</param-value>
- </init-param>
- </filter>
- <filter>
- <filter-name>Filter2</filter-name>
- <filter-class>org.apache.geronimo.jetty.app.Filter2</filter-class>
- <init-param>
- <param-name>attribute1</param-name>
- <param-value>value2</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>Filter1</filter-name>
- <servlet-name>Servlet1</servlet-name>
- </filter-mapping>
- <filter-mapping>
- <filter-name>Filter2</filter-name>
- <servlet-name>Servlet1</servlet-name>
- </filter-mapping>
- <servlet>
- <servlet-name>Servlet1</servlet-name>
- <servlet-class>org.apache.geronimo.jetty.app.Servlet1</servlet-class>
- </servlet>
- <servlet>
- <servlet-name>Servlet2</servlet-name>
- <servlet-class>org.apache.geronimo.jetty.app.Servlet2</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>Servlet1</servlet-name>
- <url-pattern>/path1</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>Servlet2</servlet-name>
- <url-pattern>/path2</url-pattern>
- </servlet-mapping>
- <session-config>
- <session-timeout>60</session-timeout>
- </session-config>
+ <display-name>war4</display-name>
+ <filter>
+ <filter-name>Filter1</filter-name>
+ <filter-class>org.apache.geronimo.jetty.app.Filter1</filter-class>
+ <init-param>
+ <param-name>attribute1</param-name>
+ <param-value>value1</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>Filter2</filter-name>
+ <filter-class>org.apache.geronimo.jetty.app.Filter2</filter-class>
+ <init-param>
+ <param-name>attribute1</param-name>
+ <param-value>value2</param-value>
+ </init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>Filter1</filter-name>
+ <servlet-name>Servlet1</servlet-name>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>Filter2</filter-name>
+ <servlet-name>Servlet1</servlet-name>
+ </filter-mapping>
+ <servlet>
+ <servlet-name>Servlet1</servlet-name>
+ <servlet-class>org.apache.geronimo.jetty.app.Servlet1</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Servlet2</servlet-name>
+ <servlet-class>org.apache.geronimo.jetty.app.Servlet2</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Servlet1</servlet-name>
+ <url-pattern>/path1</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Servlet2</servlet-name>
+ <url-pattern>/path2</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>60</session-timeout>
+ </session-config>
+ <jsp-config>
+ <taglib>
+ <taglib-uri>http://geronimo.apache.org/jsp/tagliburi1</taglib-uri>
+ <taglib-location>/WEB-INF/taglib1.tld</taglib-location>
+ </taglib>
+ <taglib>
+ <taglib-uri>http://geronimo.apache.org/jsp/tagliburi2</taglib-uri>
+ <taglib-location>/WEB-INF/taglib2.tld</taglib-location>
+ </taglib>
+ </jsp-config>
</web-app>
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/project.xml
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/project.xml?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/project.xml&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/project.xml&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/project.xml (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/project.xml Fri Dec 3 22:10:14 2004
@@ -152,36 +152,18 @@
<url>http://jakarta.apache.org/commons/logging/</url>
</dependency>
- <dependency>
- <groupId>tomcat</groupId>
- <artifactId>jasper-compiler</artifactId>
- <version>&tomcat-version;</version>
- </dependency>
-
- <dependency>
- <groupId>tomcat</groupId>
- <artifactId>jasper-runtime</artifactId>
- <version>&tomcat-version;</version>
- </dependency>
-
- <dependency>
- <groupId>commons-el</groupId>
- <artifactId>commons-el</artifactId>
- <version>&commons-el-version;</version>
- <url>http://jakarta.apache.org/commons/el/</url>
- </dependency>
-
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>&ant-version;</version>
- </dependency>
-
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>&xerces-version;</version>
- </dependency>
+<!-- -->
+<!-- <dependency>-->
+<!-- <groupId>ant</groupId>-->
+<!-- <artifactId>ant</artifactId>-->
+<!-- <version>&ant-version;</version>-->
+<!-- </dependency>-->
+<!---->
+<!-- <dependency>-->
+<!-- <groupId>xerces</groupId>-->
+<!-- <artifactId>xercesImpl</artifactId>-->
+<!-- <version>&xerces-version;</version>-->
+<!-- </dependency>-->
<dependency>
<groupId>cglib</groupId>
Deleted: /geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/etc/META-INF/geronimo-service.xml
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/etc/META-INF/geronimo-service.xml?view=auto&rev=109778
==============================================================================
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java Fri Dec 3 22:10:14 2004
@@ -60,16 +60,20 @@
JettyServletRegistration context) throws Exception {
super(context == null? null: context.getServletHandler(), servletName, servletClassName, jspFile);
//context will be null only for use as "default servlet info holder" in deployer.
+
if (context != null) {
- //TODO add in "classpath" if jspFile is not null.
putAll(initParams);
if (loadOnStartup != null) {
setInitOrder(loadOnStartup.intValue());
}
+ //this now starts the servlet in the appropriate context
context.registerServletHolder(this, servletName, servletMappings, webRoleRefPermissions == null? Collections.EMPTY_MAP: webRoleRefPermissions);
- start();
+// start();
}
}
+
+ //todo how do we stop/destroy the servlet?
+ //todo is start called twice???
public String getServletName() {
return getName();
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletRegistration.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletRegistration.java?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletRegistration.java&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletRegistration.java&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletRegistration.java (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletRegistration.java Fri Dec 3 22:10:14 2004
@@ -28,7 +28,7 @@
*/
public interface JettyServletRegistration {
- void registerServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, Map webRoleRefPermissions) throws PolicyContextException;
+ void registerServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, Map webRoleRefPermissions) throws Exception;
ServletHandler getServletHandler();
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java Fri Dec 3 22:10:14 2004
@@ -17,21 +17,14 @@
package org.apache.geronimo.jetty;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
-import java.util.Set;
-import java.util.Map;
-import java.util.Iterator;
import java.util.Collection;
import java.util.EventListener;
-import javax.resource.ResourceException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.security.jacc.PolicyContextException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,22 +32,21 @@
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.gbean.WaitingException;
+import org.apache.geronimo.jetty.interceptor.BeforeAfter;
+import org.apache.geronimo.jetty.interceptor.ComponentContextBeforeAfter;
+import org.apache.geronimo.jetty.interceptor.InstanceContextBeforeAfter;
+import org.apache.geronimo.jetty.interceptor.ThreadClassloaderBeforeAfter;
+import org.apache.geronimo.jetty.interceptor.TransactionContextBeforeAfter;
import org.apache.geronimo.naming.java.ReadOnlyContext;
-import org.apache.geronimo.naming.java.RootContext;
-import org.apache.geronimo.transaction.DefaultInstanceContext;
-import org.apache.geronimo.transaction.InstanceContext;
import org.apache.geronimo.transaction.OnlineUserTransaction;
import org.apache.geronimo.transaction.TrackedConnectionAssociator;
-import org.apache.geronimo.transaction.context.InheritableTransactionContext;
-import org.apache.geronimo.transaction.context.TransactionContext;
import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.mortbay.http.HttpException;
+import org.mortbay.http.Authenticator;
import org.mortbay.http.HttpRequest;
import org.mortbay.http.HttpResponse;
-import org.mortbay.http.Authenticator;
+import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.servlet.WebApplicationContext;
import org.mortbay.jetty.servlet.WebApplicationHandler;
-import org.mortbay.jetty.servlet.ServletHolder;
/**
* Wrapper for a WebApplicationContext that sets up its J2EE environment.
@@ -64,33 +56,26 @@
public class JettyWebAppContext extends WebApplicationContext implements GBeanLifecycle, JettyServletRegistration {
private static Log log = LogFactory.getLog(JettyWebAppContext.class);
- private final ReadOnlyContext componentContext;
- private final OnlineUserTransaction userTransaction;
private final ClassLoader classLoader;
- private final Set unshareableResources;
- private final Set applicationManagedSecurityResources;
- private final TransactionContextManager transactionContextManager;
- private final TrackedConnectionAssociator trackedConnectionAssociator;
private final JettyContainer jettyContainer;
private final URI webAppRoot;
private final WebApplicationHandler handler;
private String displayName;
+ private final BeforeAfter chain;
+ private final int contextLength;
+
/**
* @deprecated never use this... this is only here because Jetty WebApplicationContext is externalizable
*/
public JettyWebAppContext() {
- componentContext = null;
- userTransaction = null;
classLoader = null;
- unshareableResources = null;
- applicationManagedSecurityResources = null;
- transactionContextManager = null;
- trackedConnectionAssociator = null;
jettyContainer = null;
webAppRoot = null;
handler = null;
+ chain = null;
+ contextLength = 0;
}
public JettyWebAppContext(URI uri,
@@ -116,17 +101,9 @@
assert trackedConnectionAssociator != null;
assert jettyContainer != null;
- this.componentContext = componentContext;
- this.userTransaction = userTransaction;
- this.unshareableResources = unshareableResources;
- this.applicationManagedSecurityResources = applicationManagedSecurityResources;
- this.transactionContextManager = transactionContextManager;
- this.trackedConnectionAssociator = trackedConnectionAssociator;
this.jettyContainer = jettyContainer;
-// setDefaultsDescriptor("META-INF/default-web.xml");
setConfigurationClassNames(new String[]{});
-// setConfigurationClassNames(new String[]{"org.apache.geronimo.jetty.NoXMLConfiguration"});
URI root = URI.create(configurationBaseUrl.toString());
webAppRoot = root.resolve(uri);
@@ -142,79 +119,26 @@
handler = new WebApplicationHandler();
addHandler(handler);
- }
-
- //TODO tx logic may not be complete. exceptions are certainly wrong!
- public void handle(String pathInContext,
- String pathParams,
- HttpRequest httpRequest,
- HttpResponse httpResponse)
- throws HttpException, IOException {
-
- // save previous state
- ReadOnlyContext oldComponentContext = RootContext.getComponentContext();
-
- InstanceContext oldInstanceContext = null;
-
- try {
- // set up java:comp JNDI Context
- RootContext.setComponentContext(componentContext);
-
- TransactionContext oldTransactionContext = transactionContextManager.getContext();
- TransactionContext newTransactionContext = null;
- if (oldTransactionContext == null || !(oldTransactionContext instanceof InheritableTransactionContext)) {
- newTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();
- }
+ userTransaction.setUp(transactionContextManager, trackedConnectionAssociator);
- try {
- try {
- oldInstanceContext = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources));
- } catch (ResourceException e) {
- throw new RuntimeException(e);
- }
-
- super.handle(pathInContext, pathParams, httpRequest, httpResponse);
- } finally {
- try {
- if (newTransactionContext != null) {
- if (newTransactionContext != transactionContextManager.getContext()) {
- transactionContextManager.getContext().rollback();
- newTransactionContext.rollback();
- throw new HttpException(500, "WRONG EXCEPTION! returned from servlet call with wrong tx context");
- }
- newTransactionContext.commit();
-
- } else {
- if (oldTransactionContext != transactionContextManager.getContext()) {
- if (transactionContextManager.getContext() != null) {
- transactionContextManager.getContext().rollback();
- }
- throw new HttpException(500, "WRONG EXCEPTION! returned from servlet call with wrong tx context");
- }
- }
- } catch (SystemException e) {
- throw (HttpException) new HttpException(500, "WRONG EXCEPTION!").initCause(e);
- } catch (HeuristicMixedException e) {
- throw (HttpException) new HttpException(500, "WRONG EXCEPTION!").initCause(e);
- } catch (HeuristicRollbackException e) {
- throw (HttpException) new HttpException(500, "WRONG EXCEPTION!").initCause(e);
- } catch (RollbackException e) {
- throw (HttpException) new HttpException(500, "WRONG EXCEPTION!").initCause(e);
- } finally {
- //this is redundant when we enter with an inheritable context and nothing goes wrong.
- transactionContextManager.setContext(oldTransactionContext);
- }
- }
- } finally {
- try {
- trackedConnectionAssociator.exit(oldInstanceContext);
- } catch (ResourceException e) {
- throw new RuntimeException(e);
- } finally {
- RootContext.setComponentContext(oldComponentContext);
- }
- }
+ int index = 0;
+ BeforeAfter interceptor = new InstanceContextBeforeAfter(null, index++, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator);
+ interceptor = new TransactionContextBeforeAfter(interceptor, index++, index++, transactionContextManager);
+ interceptor = new ComponentContextBeforeAfter(interceptor, index++, componentContext);
+ chain = new ThreadClassloaderBeforeAfter(interceptor, index++, index++, this.classLoader);
+ contextLength = index;
+ }
+
+ public Object enterContextScope(HttpRequest request, HttpResponse response) {
+ Object[] context = new Object[contextLength];
+ chain.before(context);
+ return context;
+ }
+
+ public void leaveContextScope(HttpRequest request, HttpResponse response, Object oldScope) {
+ Object[] context = (Object[]) oldScope;
+ chain.after(context);
}
public void doStart() throws WaitingException, Exception {
@@ -229,57 +153,14 @@
setWAR(webAppRoot.toString());
- userTransaction.setUp(transactionContextManager, trackedConnectionAssociator);
jettyContainer.addContext(this);
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ Object context = enterContextScope(null, null);
try {
- Thread.currentThread().setContextClassLoader(classLoader);
- ReadOnlyContext oldComponentContext = RootContext.getComponentContext();
- InstanceContext oldInstanceContext = null;
- try {
- RootContext.setComponentContext(componentContext);
-//TODO FIXME!!!
- TransactionContext transactionContext = transactionContextManager.getContext();
- if (transactionContext == null) {
- transactionContext = transactionContextManager.newUnspecifiedTransactionContext();
- } else {
- transactionContext = null;
- }
-
- try {
-
- try {
- oldInstanceContext = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources));
- } catch (ResourceException e) {
- throw new RuntimeException(e);
- }
-
- super.doStart();
- } finally {
- if (transactionContext != null) {
- transactionContextManager.setContext(null);
- try {
- transactionContext.commit();
- } catch (Exception e) {
- //TODO this is undoubtedly the wrong error code!
- throw (HttpException) new HttpException(500, "Problem committing unspecified transaction context").initCause(e);
- }
- }
- }
- } finally {
- try {
- trackedConnectionAssociator.exit(oldInstanceContext);
- } catch (ResourceException e) {
- throw new RuntimeException(e);
- } finally {
- RootContext.setComponentContext(oldComponentContext);
- }
- //TODO should we reset the transactioncontext to null if we set it?
- }
+ super.doStart();
} finally {
- Thread.currentThread().setContextClassLoader(oldCL);
+ leaveContextScope(null, null, context);
}
log.info("JettyWebAppContext started");
@@ -292,62 +173,13 @@
return;
}
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ Object context = enterContextScope(null, null);
try {
- Thread.currentThread().setContextClassLoader(classLoader);
- ReadOnlyContext oldComponentContext = RootContext.getComponentContext();
- InstanceContext oldInstanceContext = null;
- try {
- RootContext.setComponentContext(componentContext);
-
- TransactionContext transactionContext = transactionContextManager.getContext();
- if (transactionContext == null) {
- transactionContext = transactionContextManager.newUnspecifiedTransactionContext();
- } else {
- transactionContext = null;
- }
- try {
-
- try {
- oldInstanceContext = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources));
- } catch (ResourceException e) {
- throw new RuntimeException(e);
- }
-
- while (true) {
- try {
- super.doStop();
- break;
- } catch (InterruptedException e) {
- continue;
- }
- }
- } finally {
- if (transactionContext != null) {
- transactionContextManager.setContext(null);
- try {
- transactionContext.commit();
- } catch (Exception e) {
- //TODO this is undoubtedly the wrong error code!
- throw (HttpException) new HttpException(500, "Problem committing unspecified transaction context").initCause(e);
- }
- }
- }
- } finally {
- try {
- trackedConnectionAssociator.exit(oldInstanceContext);
- } catch (ResourceException e) {
- throw new RuntimeException(e);
- } finally {
- RootContext.setComponentContext(oldComponentContext);
- }
- //TODO should we reset the transactioncontext to null if we set it?
- }
- jettyContainer.removeContext(this);
+ super.doStop();
} finally {
- Thread.currentThread().setContextClassLoader(oldCL);
+ leaveContextScope(null, null, context);
}
-
+ jettyContainer.removeContext(this);
log.info("JettyWebAppContext stopped");
}
@@ -404,19 +236,15 @@
}
}
- public void setResourceAliases(Map resourceAliasMap) {
- if (resourceAliasMap != null) {
- for (Iterator iterator = resourceAliasMap.entrySet().iterator(); iterator.hasNext();) {
+ public void setTagLibMap(Map tagLibMap) {
+ if (tagLibMap != null) {
+ for (Iterator iterator = tagLibMap.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
setResourceAlias((String) entry.getKey(), (String) entry.getValue());
}
}
}
- public void setTagLibMap(Map tagLibMap) {
- setResourceAliases(tagLibMap);
- }
-
public void setSessionTimeoutSeconds(int seconds) {
handler.setSessionInactiveInterval(seconds);
}
@@ -433,7 +261,7 @@
}
- public void registerServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, Map webRoleRefPermissions) throws PolicyContextException {
+ public void registerServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, Map webRoleRefPermissions) throws Exception {
//TODO filters
handler.addServletHolder(servletHolder);
if (servletMappings != null) {
@@ -442,6 +270,12 @@
handler.mapPathToServlet(urlPattern, servletName);
}
}
+ Object context = enterContextScope(null, null);
+ try {
+ servletHolder.start();
+ } finally {
+ leaveContextScope(null, null, context);
+ }
}
public static final GBeanInfo GBEAN_INFO;
@@ -459,7 +293,6 @@
infoBuilder.addAttribute("welcomeFiles", String[].class, true);
infoBuilder.addAttribute("localeEncodingMapping", Map.class, true);
infoBuilder.addAttribute("errorPages", Map.class, true);
- infoBuilder.addAttribute("resourceAliases", Map.class, true);
infoBuilder.addAttribute("authenticator", Authenticator.class, true);
infoBuilder.addAttribute("realmName", String.class, true);
infoBuilder.addAttribute("tagLibMap", Map.class, true);
Modified: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java?view=diff&rev=109779&p1=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java&r1=109778&p2=geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java&r2=109779
==============================================================================
--- geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java (original)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java Fri Dec 3 22:10:14 2004
@@ -91,6 +91,7 @@
private final Kernel kernel;
private final String policyContextID;
+ private final String loginDomainName;
private final Security securityConfig;
private final JAASJettyPrincipal defaultPrincipal;
@@ -102,13 +103,7 @@
private String formLoginPath;
- //from jettyxmlconfiguration
private final Set securityRoles;
-// private final Map uncheckedPatterns;
-// private final Map excludedPatterns;
-// private final Map rolesPatterns;
-// private final Set allSet;
-
private final Set excludedPermissions;
private final Set uncheckedPermissions;
private final Map rolePermissions;
@@ -117,6 +112,7 @@
public JettyWebAppJACCContext() {
kernel = null;
policyContextID = null;
+ loginDomainName = null;
securityConfig = null;
defaultPrincipal = null;
this.securityRoles = null;
@@ -171,6 +167,7 @@
setRealm(realm);
this.policyContextID = policyContextID;
+ this.loginDomainName = loginDomainName;
this.securityConfig = securityConfig;
this.securityRoles = securityRoles;
@@ -203,7 +200,7 @@
roleDesignates.put(roleName, subject);
}
- public void registerServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, Map webRoleRefPermissions) throws PolicyContextException {
+ public void registerServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, Map webRoleRefPermissions) throws Exception {
super.registerServletHolder(servletHolder, servletName, servletMappings, webRoleRefPermissions);
policyConfiguration = factory.getPolicyConfiguration(policyContextID, false);
@@ -605,131 +602,6 @@
throw new GeronimoSecurityException(e);
}
}
- /**
- * This method dumps the intermediate security information into the JACC
- * PolicyConfiguration.
- *
-// * @param configuration the JACC PolicyConfiguration
- */
-// public void configure(PolicyConfiguration configuration) throws GeronimoSecurityException {
-//
-// Set allSet = new HashSet(excludedPatterns.values());
-// allSet.addAll(rolesPatterns.values());
-// allSet.addAll(uncheckedPatterns.values());
-// try {
-// Iterator iter = excludedPatterns.keySet().iterator();
-// while (iter.hasNext()) {
-// URLPattern pattern = (URLPattern) excludedPatterns.get(iter.next());
-// String name = pattern.getQualifiedPattern(allSet);
-// String actions = pattern.getMethods();
-//
-// configuration.addToExcludedPolicy(new WebResourcePermission(name, actions));
-// configuration.addToExcludedPolicy(new WebUserDataPermission(name, actions));
-// }
-//
-// iter = rolesPatterns.keySet().iterator();
-// while (iter.hasNext()) {
-// URLPattern pattern = (URLPattern) rolesPatterns.get(iter.next());
-// String name = pattern.getQualifiedPattern(allSet);
-// String actions = pattern.getMethods();
-// WebResourcePermission permission = new WebResourcePermission(name, actions);
-//
-// Iterator names = pattern.getRoles().iterator();
-// while (names.hasNext()) {
-// configuration. addToRole((String) names.next(), permission);
-// }
-// }
-//
-// iter = uncheckedPatterns.keySet().iterator();
-// while (iter.hasNext()) {
-// URLPattern pattern = (URLPattern) uncheckedPatterns.get(iter.next());
-// String name = pattern.getQualifiedPattern(allSet);
-// String actions = pattern.getMethods();
-//
-// configuration.addToUncheckedPolicy(new WebResourcePermission(name, actions));
-// }
-//
-// iter = rolesPatterns.keySet().iterator();
-// while (iter.hasNext()) {
-// URLPattern pattern = (URLPattern) rolesPatterns.get(iter.next());
-// String name = pattern.getQualifiedPattern(allSet);
-// String actions = pattern.getMethodsWithTransport();
-//
-// configuration.addToUncheckedPolicy(new WebUserDataPermission(name, actions));
-// }
-//
-// iter = uncheckedPatterns.keySet().iterator();
-// while (iter.hasNext()) {
-// URLPattern pattern = (URLPattern) uncheckedPatterns.get(iter.next());
-// String name = pattern.getQualifiedPattern(allSet);
-// String actions = pattern.getMethodsWithTransport();
-//
-// configuration.addToUncheckedPolicy(new WebUserDataPermission(name, actions));
-// }
-//
-// /**
-// * A <code>WebResourcePermission</code> and a <code>WebUserDataPermission</code> must be instantiated for
-// * each <tt>url-pattern</tt> in the deployment descriptor and the default pattern "/", that is not combined
-// * by the <tt>web-resource-collection</tt> elements of the deployment descriptor with ever HTTP method
-// * value. The permission objects must be contructed using the qualified pattern as their name and with
-// * actions defined by the subset of the HTTP methods that do not occur in combination with the pattern.
-// * The resulting permissions that must be added to the unchecked policy statements by calling the
-// * <code>addToUncheckedPolcy</code> method on the <code>PolicyConfiguration</code> object.
-// */
-// iter = allSet.iterator();
-// while (iter.hasNext()) {
-// URLPattern pattern = (URLPattern) iter.next();
-// String name = pattern.getQualifiedPattern(allSet);
-// String actions = pattern.getComplementedMethods();
-//
-// if (actions.length() == 0) {
-// continue;
-// }
-//
-// configuration.addToUncheckedPolicy(new WebResourcePermission(name, actions));
-// configuration.addToUncheckedPolicy(new WebUserDataPermission(name, actions));
-// }
-//
-// URLPattern pattern = new URLPattern("/");
-// if (!allSet.contains(pattern)) {
-// String name = pattern.getQualifiedPattern(allSet);
-// String actions = pattern.getComplementedMethods();
-//
-// configuration.addToUncheckedPolicy(new WebResourcePermission(name, actions));
-// configuration.addToUncheckedPolicy(new WebUserDataPermission(name, actions));
-// }
-//
-//
-//// Iterator keys = roleRefs.keySet().iterator();
-//// while (keys.hasNext()) {
-//// String roleLink = (String) keys.next();
-//// iter = ((Set) roleRefs.get(roleLink)).iterator();
-////
-//// while (iter.hasNext()) {
-//// configuration.addToRole(roleLink, (WebRoleRefPermission) iter.next());
-//// }
-//// }
-////
-//// keys = servletRoles.keySet().iterator();
-//// while (keys.hasNext()) {
-//// String servletName = (String) keys.next();
-//// Set roles = new HashSet(securityRoles);
-////
-//// roles.removeAll((Set) servletRoles.get(servletName));
-////
-//// iter = roles.iterator();
-//// while (iter.hasNext()) {
-//// String roleName = (String) iter.next();
-//// configuration.addToRole(roleName, new WebRoleRefPermission(servletName, roleName));
-//// }
-//// }
-//
-// } catch (ClassCastException cce) {
-// throw new GeronimoSecurityException("Policy configuration object does not implement RoleMappingConfiguration", cce.getCause());
-// } catch (PolicyContextException e) {
-// throw new GeronimoSecurityException(e);
-// }
-// }
protected void addRoleMappings(RoleMappingConfiguration roleMapper, Security security) throws PolicyContextException, GeronimoSecurityException {
@@ -751,8 +623,7 @@
while (principals.hasNext()) {
org.apache.geronimo.security.deploy.Principal principal = (org.apache.geronimo.security.deploy.Principal) principals.next();
- //todo: The next line must use a login domain name, which I guess means that neds to go in the geronimo-jetty.xml
- RealmPrincipal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal, realm.getRealmName(), realm.getRealmName());
+ RealmPrincipal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal, loginDomainName, realm.getRealmName());
if (realmPrincipal == null) throw new GeronimoSecurityException("Unable to create realm principal");
principalSet.add(realmPrincipal);
Added: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/BeforeAfter.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/BeforeAfter.java?view=auto&rev=109779
==============================================================================
--- (empty file)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/BeforeAfter.java Fri Dec 3 22:10:14 2004
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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.jetty.interceptor;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public interface BeforeAfter {
+
+ void before(Object[] context);
+
+ void after(Object[] context);
+
+}
Added: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java?view=auto&rev=109779
==============================================================================
--- (empty file)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java Fri Dec 3 22:10:14 2004
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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.jetty.interceptor;
+
+import org.apache.geronimo.naming.java.ReadOnlyContext;
+import org.apache.geronimo.naming.java.RootContext;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class ComponentContextBeforeAfter implements BeforeAfter {
+
+ private final BeforeAfter next;
+ private final int index;
+ private final ReadOnlyContext readOnlyContext;
+
+ public ComponentContextBeforeAfter(BeforeAfter next, int index, ReadOnlyContext readOnlyContext) {
+ this.next = next;
+ this.index = index;
+ this.readOnlyContext = readOnlyContext;
+ }
+
+ public void before(Object[] context) {
+ context[index] = RootContext.getComponentContext();
+ RootContext.setComponentContext(readOnlyContext);
+ if (next != null) {
+ next.before(context);
+ }
+ }
+
+ public void after(Object[] context) {
+ if (next != null) {
+ next.after(context);
+ }
+ RootContext.setComponentContext((ReadOnlyContext) context[index]);
+ }
+
+}
Added: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java?view=auto&rev=109779
==============================================================================
--- (empty file)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java Fri Dec 3 22:10:14 2004
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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.jetty.interceptor;
+
+import java.util.Set;
+import javax.resource.ResourceException;
+
+import org.apache.geronimo.transaction.DefaultInstanceContext;
+import org.apache.geronimo.transaction.InstanceContext;
+import org.apache.geronimo.transaction.TrackedConnectionAssociator;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class InstanceContextBeforeAfter implements BeforeAfter {
+
+ private final BeforeAfter next;
+ private final int index;
+ private final Set unshareableResources;
+ private final Set applicationManagedSecurityResources;
+ private final TrackedConnectionAssociator trackedConnectionAssociator;
+
+ public InstanceContextBeforeAfter(BeforeAfter next, int index, Set unshareableResources, Set applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator) {
+ this.next = next;
+ this.index = index;
+ this.unshareableResources = unshareableResources;
+ this.applicationManagedSecurityResources = applicationManagedSecurityResources;
+ this.trackedConnectionAssociator = trackedConnectionAssociator;
+ }
+
+ public void before(Object[] context) {
+ try {
+ context[index] = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources));
+ } catch (ResourceException e) {
+ throw new RuntimeException(e);
+ }
+ if (next != null) {
+ next.before(context);
+ }
+ }
+
+ public void after(Object[] context) {
+ if (next != null) {
+ next.after(context);
+ }
+ try {
+ trackedConnectionAssociator.exit((InstanceContext) context[index]);
+ } catch (ResourceException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java?view=auto&rev=109779
==============================================================================
--- (empty file)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/SecurityContextBeforeAfter.java Fri Dec 3 22:10:14 2004
@@ -0,0 +1,65 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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.jetty.interceptor;
+
+import javax.security.jacc.PolicyContext;
+
+import org.apache.geronimo.naming.java.ReadOnlyContext;
+import org.apache.geronimo.naming.java.RootContext;
+import org.apache.geronimo.jetty.JettyWebAppJACCContext;
+import org.apache.geronimo.jetty.JettyServer;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class SecurityContextBeforeAfter implements BeforeAfter {
+
+ private final BeforeAfter next;
+ private final int policyContextIDIndex;
+ private final int webAppContextIndex;
+ private final String policyContextID;
+ private final JettyWebAppJACCContext webAppContext;
+
+ public SecurityContextBeforeAfter(BeforeAfter next, int policyContextIDIndex, int webAppContextIndex, String policyContextID, JettyWebAppJACCContext webAppContext) {
+ this.next = next;
+ this.policyContextIDIndex = policyContextIDIndex;
+ this.webAppContextIndex = webAppContextIndex;
+ this.policyContextID = policyContextID;
+ this.webAppContext = webAppContext;
+ }
+
+ public void before(Object[] context) {
+ context[policyContextIDIndex] = PolicyContext.getContextID();
+ context[webAppContextIndex] = JettyServer.getCurrentWebAppContext();
+
+ PolicyContext.setContextID(policyContextID);
+ JettyServer.setCurrentWebAppContext(webAppContext);
+
+ if (next != null) {
+ next.before(context);
+ }
+ }
+
+ public void after(Object[] context) {
+ if (next != null) {
+ next.after(context);
+ }
+ JettyServer.setCurrentWebAppContext((JettyWebAppJACCContext) context[webAppContextIndex]);
+ PolicyContext.setContextID((String) context[policyContextIDIndex]);
+ }
+
+}
Added: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ThreadClassloaderBeforeAfter.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ThreadClassloaderBeforeAfter.java?view=auto&rev=109779
==============================================================================
--- (empty file)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ThreadClassloaderBeforeAfter.java Fri Dec 3 22:10:14 2004
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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.jetty.interceptor;
+
+
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class ThreadClassloaderBeforeAfter implements BeforeAfter {
+
+ private final BeforeAfter next;
+ private final int threadIndex;
+ private final int classLoaderIndex;
+ private final ClassLoader classLoader;
+
+ public ThreadClassloaderBeforeAfter(BeforeAfter next, int threadIndex, int classLoaderIndex, ClassLoader classLoader) {
+ this.next = next;
+ this.threadIndex = threadIndex;
+ this.classLoaderIndex = classLoaderIndex;
+ this.classLoader = classLoader;
+ }
+
+ public void before(Object[] context) {
+ Thread thread = Thread.currentThread();
+ context[threadIndex] = thread;
+ context[classLoaderIndex] = thread.getContextClassLoader();
+ thread.setContextClassLoader(classLoader);
+ if (next != null) {
+ next.before(context);
+ }
+ }
+
+ public void after(Object[] context) {
+ if (next != null) {
+ next.after(context);
+ }
+ ((Thread)context[threadIndex]).setContextClassLoader((ClassLoader)context[classLoaderIndex]);
+ }
+
+}
Added: geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java?view=auto&rev=109779
==============================================================================
--- (empty file)
+++ geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java Fri Dec 3 22:10:14 2004
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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.jetty.interceptor;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.apache.geronimo.transaction.context.InheritableTransactionContext;
+import org.apache.geronimo.transaction.context.TransactionContext;
+import org.apache.geronimo.transaction.context.TransactionContextManager;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class TransactionContextBeforeAfter implements BeforeAfter {
+
+ private final BeforeAfter next;
+ private final int oldTxIndex;
+ private final int newTxIndex;
+ private final TransactionContextManager transactionContextManager;
+
+ public TransactionContextBeforeAfter(BeforeAfter next, int oldTxIndex, int newTxIndex, TransactionContextManager transactionContextManager) {
+ this.next = next;
+ this.oldTxIndex = oldTxIndex;
+ this.newTxIndex = newTxIndex;
+ this.transactionContextManager = transactionContextManager;
+ }
+
+ public void before(Object[] context) {
+ TransactionContext oldTransactionContext = transactionContextManager.getContext();
+ TransactionContext newTransactionContext = null;
+ if (oldTransactionContext == null || !(oldTransactionContext instanceof InheritableTransactionContext)) {
+ newTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();
+ }
+ context[oldTxIndex] = oldTransactionContext;
+ context[newTxIndex] = newTransactionContext;
+
+ if (next != null) {
+ next.before(context);
+ }
+ }
+
+ public void after(Object[] context) {
+ if (next != null) {
+ next.after(context);
+ }
+ TransactionContext oldTransactionContext = (TransactionContext) context[oldTxIndex];
+ TransactionContext newTransactionContext = (TransactionContext) context[newTxIndex];
+ try {
+ if (newTransactionContext != null) {
+ if (newTransactionContext != transactionContextManager.getContext()) {
+ transactionContextManager.getContext().rollback();
+ newTransactionContext.rollback();
+ throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
+ }
+ newTransactionContext.commit();
+
+ } else {
+ if (oldTransactionContext != transactionContextManager.getContext()) {
+ if (transactionContextManager.getContext() != null) {
+ transactionContextManager.getContext().rollback();
+ }
+ throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
+ }
+ }
+ } catch (SystemException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } catch (HeuristicMixedException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } catch (HeuristicRollbackException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } catch (RollbackException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } finally {
+ //this is redundant when we enter with an inheritable context and nothing goes wrong.
+ transactionContextManager.setContext(oldTransactionContext);
+ }
+ }
+
+}
Deleted: /geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/BaseSecurityTest.java
Url: http://svn.apache.org/viewcvs/geronimo/branches/djencks/jetty-deployer1/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/BaseSecurityTest.java?view=auto&rev=109778
==============================================================================