openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1615884 - in /openwebbeans/trunk: ./ samples/tomcat-sample/src/main/webapp/META-INF/ samples/tomcat7-sample/ samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/ samples/tomcat7-sample/src/main/tomcat/ samples/tomcat7-s...
Date Tue, 05 Aug 2014 08:14:41 GMT
Author: struberg
Date: Tue Aug  5 08:14:40 2014
New Revision: 1615884

URL: http://svn.apache.org/r1615884
Log:
OWB-983 fix tomcat7 integration

* implement Principal mechanism as Filter instead of a listener
* heavily simplify the Lifecycle and InstanceManager registration

Added:
    openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/
    openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/context.xml
    openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/tomcat-users.xml
    openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/index.jsp   (with props)
    openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/openwebbeans/
    openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/openwebbeans/openwebbeans.properties
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/
      - copied from r1613878, openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat/
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityFilter.java
      - copied, changed from r1613878, openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat/TomcatSecurityListener.java
    openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/openwebbeans/
    openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
    openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/web-fragment.xml
    openwebbeans/trunk/webbeans-tomcat7/src/test/java/org/apache/webbeans/web/tomcat7/
      - copied from r1613878, openwebbeans/trunk/webbeans-tomcat7/src/test/java/org/apache/webbeans/web/tomcat/
Removed:
    openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/WEB-INF/lib/
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat/
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityListener.java
    openwebbeans/trunk/webbeans-tomcat7/src/test/java/org/apache/webbeans/web/tomcat/
Modified:
    openwebbeans/trunk/pom.xml
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml
    openwebbeans/trunk/samples/tomcat7-sample/pom.xml
    openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java
    openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/WEB-INF/web.xml
    openwebbeans/trunk/webbeans-tomcat6/pom.xml
    openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/META-INF/context.xml
    openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin
    openwebbeans/trunk/webbeans-tomcat7/pom.xml
    openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/pom.xml
    openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/src/main/webapp/META-INF/context.xml
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/ContextLifecycleListener.java
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityService.java
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatUtil.java
    openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java
    openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin

Modified: openwebbeans/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/pom.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/pom.xml (original)
+++ openwebbeans/trunk/pom.xml Tue Aug  5 08:14:40 2014
@@ -77,6 +77,8 @@
         <geronimo_atinject.version>1.0</geronimo_atinject.version>
         <geronimo_interceptor.version>1.0-SNAPSHOT</geronimo_interceptor.version>
         <geronimo_validation.version>1.1</geronimo_validation.version>
+        <tomcat6.version>6.0.35</tomcat6.version>
+        <tomcat7.version>7.0.54</tomcat7.version>
         <openejb.version>3.1.4</openejb.version>
         <myfaces.version>2.0.7</myfaces.version>
         <xbean.version>3.17</xbean.version>

Modified: openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml (original)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml Tue Aug  5 08:14:40 2014
@@ -15,5 +15,5 @@
     License.
 -->
 <Context>
-    <Listener className="org.apache.webbeans.web.tomcat.ContextLifecycleListener" />
+    <Listener className="org.apache.webbeans.web.tomcat7.ContextLifecycleListener" />
 </Context>

Modified: openwebbeans/trunk/samples/tomcat7-sample/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat7-sample/pom.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/samples/tomcat7-sample/pom.xml (original)
+++ openwebbeans/trunk/samples/tomcat7-sample/pom.xml Tue Aug  5 08:14:40 2014
@@ -20,8 +20,8 @@ under the License.
     <modelVersion>4.0.0</modelVersion>
     <description>Sample Tomcat7 Application</description>
     <parent>
-        <artifactId>samples</artifactId>
         <groupId>org.apache.openwebbeans</groupId>
+        <artifactId>samples</artifactId>
         <version>2.0.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
@@ -38,28 +38,12 @@ under the License.
     <dependencies>
 
         <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-impl</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-web</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-servlet_3.0_spec</artifactId>
             <version>1.0</version>
             <scope>provided</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-ee-common</artifactId>
-            <version>${project.version}</version>
-        </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
@@ -72,32 +56,146 @@ under the License.
             <artifactId>geronimo-atinject_1.0_spec</artifactId>
             <scope>provided</scope>
         </dependency>
-
-        <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-spi</artifactId>
-            <version>${project.version}</version>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-resource</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
     </dependencies>
 
     <build>
         <finalName>tomcat-sample</finalName>
         <plugins>
             <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>tomcat-maven-plugin</artifactId>
-                <version>1.1</version>
+                <groupId>org.apache.tomcat.maven</groupId>
+                <artifactId>tomcat7-maven-plugin</artifactId>
                 <configuration>
-                    <url>http://localhost:8080/manager/text</url>
+                    <tomcatUsers>${project.basedir}/src/main/tomcat/tomcat-users.xml</tomcatUsers>
+                    <contextFile>${project.basedir}/src/main/tomcat/context.xml</contextFile>
                 </configuration>
+                <dependencies>
+                    <!-- just to be able to define the tomcat version -->
+                    <dependency>
+                        <groupId>org.apache.tomcat.embed</groupId>
+                        <artifactId>tomcat-embed-core</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-util</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-coyote</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-api</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-jdbc</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-dbcp</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-servlet-api</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-jsp-api</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-jasper</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-jasper-el</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-el-api</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-catalina</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-tribes</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-catalina-ha</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.tomcat</groupId>
+                        <artifactId>tomcat-annotations-api</artifactId>
+                        <version>${tomcat7.version}</version>
+                    </dependency>
+
+                    <!-- OWB deps -->
+                    <dependency>
+                        <groupId>org.apache.openwebbeans</groupId>
+                        <artifactId>openwebbeans-impl</artifactId>
+                        <version>${project.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.openwebbeans</groupId>
+                        <artifactId>openwebbeans-spi</artifactId>
+                        <version>${project.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.openwebbeans</groupId>
+                        <artifactId>openwebbeans-web</artifactId>
+                        <version>${project.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.openwebbeans</groupId>
+                        <artifactId>openwebbeans-tomcat7</artifactId>
+                        <version>${project.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.apache.geronimo.specs</groupId>
+                        <artifactId>geronimo-jcdi_1.1_spec</artifactId>
+                        <version>${geronimo_cdi.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.geronimo.specs</groupId>
+                        <artifactId>geronimo-atinject_1.0_spec</artifactId>
+                        <version>${geronimo_atinject.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.geronimo.specs</groupId>
+                        <artifactId>geronimo-interceptor_1.2_spec</artifactId>
+                        <version>${geronimo_interceptor.version}</version>
+                    </dependency>
+
+                </dependencies>
             </plugin>
         </plugins>
     </build>

Modified: openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java (original)
+++ openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java Tue Aug  5 08:14:40 2014
@@ -19,8 +19,8 @@
 package org.apache.webbeans.samples.tomcat;
 
 import java.io.IOException;
-import java.lang.annotation.Annotation;
 import java.util.Set;
+import java.util.logging.Logger;
 
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -32,29 +32,30 @@ import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.webbeans.annotation.DefaultLiteral;
 
 public class MyFilter implements Filter
 {
+    private static final Logger log = Logger.getLogger(MyFilter.class.getName());
+
     private @Inject BeanManager manager;
 
+
     @Override
     public void destroy()
     {
-        
-        
+
     }
 
     @Override
     @SuppressWarnings("unchecked")
     public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException
     {
-        Set<Bean<?>> beans = manager.getBeans(CurrentDateProvider.class, new Annotation[]{new DefaultLiteral()});
-        System.out.println("Total found beans : " + beans.size());
+        Set<Bean<?>> beans = manager.getBeans(CurrentDateProvider.class);
+        log.info("Total found beans : " + beans.size());
         Bean<CurrentDateProvider> provider = (Bean<CurrentDateProvider>)beans.iterator().next();
         CurrentDateProvider instance = (CurrentDateProvider) manager.getReference(provider, CurrentDateProvider.class, manager.createCreationalContext(provider));
         
-        System.out.println("Current time is : " + instance.getCurrentDate());
+        log.info("Current time is : " + instance.getCurrentDate());
         
         arg2.doFilter(arg0, arg1);
         

Added: openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/context.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/context.xml?rev=1615884&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/context.xml (added)
+++ openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/context.xml Tue Aug  5 08:14:40 2014
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+<Context>
+    <Listener className="org.apache.webbeans.web.tomcat7.ContextLifecycleListener" />
+</Context>

Added: openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/tomcat-users.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/tomcat-users.xml?rev=1615884&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/tomcat-users.xml (added)
+++ openwebbeans/trunk/samples/tomcat7-sample/src/main/tomcat/tomcat-users.xml Tue Aug  5 08:14:40 2014
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+  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.
+-->
+<tomcat-users>
+      <role rolename="manager-script"/>
+      <user username="manager" password="manager" roles="manager-script"/>
+</tomcat-users>
\ No newline at end of file

Modified: openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/WEB-INF/web.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/WEB-INF/web.xml (original)
+++ openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/WEB-INF/web.xml Tue Aug  5 08:14:40 2014
@@ -16,39 +16,44 @@
     License.
 -->
 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
- <filter>
-  <filter-name>injectorfilter</filter-name>
-  <filter-class>org.apache.webbeans.samples.tomcat.MyFilter</filter-class>
- </filter>
- <filter-mapping>
-  <filter-name>injectorfilter</filter-name>
-  <servlet-name>injector</servlet-name>
-  <dispatcher>REQUEST</dispatcher>
- </filter-mapping>
- <servlet>
-  <servlet-name>injector</servlet-name>
-  <servlet-class>org.apache.webbeans.samples.tomcat.InjectorServlet</servlet-class>
- </servlet>
- <servlet-mapping>
-  <servlet-name>injector</servlet-name>
-  <url-pattern>/injector</url-pattern>
- </servlet-mapping>
- <security-constraint>
-  <display-name>injector</display-name>
-  <web-resource-collection>
-   <web-resource-name>injector</web-resource-name>
-   <url-pattern>/injector/*</url-pattern>
-  </web-resource-collection>
-  <auth-constraint>
-   <role-name>manager-script</role-name>
-  </auth-constraint>
- </security-constraint>
- <login-config>
-  <auth-method>BASIC</auth-method>
-  <realm-name>sample</realm-name>
- </login-config>
- <security-role>
-  <role-name>manager-script</role-name>
- </security-role>
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+    <filter>
+        <filter-name>injectorfilter</filter-name>
+        <filter-class>org.apache.webbeans.samples.tomcat.MyFilter</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>injectorfilter</filter-name>
+        <servlet-name>injector</servlet-name>
+        <dispatcher>REQUEST</dispatcher>
+    </filter-mapping>
+    <servlet>
+        <servlet-name>injector</servlet-name>
+        <servlet-class>org.apache.webbeans.samples.tomcat.InjectorServlet</servlet-class>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>injector</servlet-name>
+        <url-pattern>/injector</url-pattern>
+    </servlet-mapping>
+
+
+    <security-constraint>
+        <display-name>injector</display-name>
+        <web-resource-collection>
+            <web-resource-name>injector</web-resource-name>
+            <url-pattern>/injector/*</url-pattern>
+        </web-resource-collection>
+        <auth-constraint>
+            <role-name>manager-script</role-name>
+        </auth-constraint>
+    </security-constraint>
+
+    <login-config>
+        <auth-method>BASIC</auth-method>
+        <realm-name>sample</realm-name>
+    </login-config>
+
+    <security-role>
+        <role-name>manager-script</role-name>
+    </security-role>
+
 </web-app>

Added: openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/index.jsp?rev=1615884&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/index.jsp (added)
+++ openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/index.jsp Tue Aug  5 08:14:40 2014
@@ -0,0 +1,19 @@
+<!--
+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.
+-->
+<meta http-equiv="refresh" content="0;url=/tomcat7-sample/injector"/>

Propchange: openwebbeans/trunk/samples/tomcat7-sample/src/main/webapp/index.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-tomcat6/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/pom.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat6/pom.xml (original)
+++ openwebbeans/trunk/webbeans-tomcat6/pom.xml Tue Aug  5 08:14:40 2014
@@ -31,7 +31,7 @@
         <dependency>
             <groupId>org.apache.tomcat</groupId>
             <artifactId>catalina</artifactId>
-            <version>6.0.35</version>
+            <version>${tomcat6.version}</version>
             <scope>provided</scope>
         </dependency>
 

Modified: openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/META-INF/context.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/META-INF/context.xml (original)
+++ openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/META-INF/context.xml Tue Aug  5 08:14:40 2014
@@ -15,5 +15,5 @@
     License.
 -->
 <Context>
-  <Listener className="org.apache.webbeans.web.tomcat.ContextLifecycleListener" />
+  <Listener className="org.apache.webbeans.web.tomcat7.ContextLifecycleListener" />
 </Context>

Added: openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/openwebbeans/openwebbeans.properties?rev=1615884&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/openwebbeans/openwebbeans.properties (added)
+++ openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/openwebbeans/openwebbeans.properties Tue Aug  5 08:14:40 2014
@@ -0,0 +1,24 @@
+#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.
+#---------------------------------------------------------------
+# The configuration for Tomcat6
+#
+#---------------------------------------------------------------
+
+
+# use a special securityService for Principal injection
+org.apache.webbeans.spi.SecurityService=org.apache.webbeans.web.tomcat7.TomcatSecurityService
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin (original)
+++ openwebbeans/trunk/webbeans-tomcat6/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin Tue Aug  5 08:14:40 2014
@@ -14,4 +14,4 @@
 #KIND, either express or implied.  See the License for the
 #specific language governing permissions and limitations
 #under the License.
-org.apache.webbeans.web.tomcat.TomcatWebPlugin
\ No newline at end of file
+tomcat7.TomcatWebPlugin
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-tomcat7/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/pom.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/pom.xml (original)
+++ openwebbeans/trunk/webbeans-tomcat7/pom.xml Tue Aug  5 08:14:40 2014
@@ -31,7 +31,7 @@
         <dependency>
             <groupId>org.apache.tomcat</groupId>
             <artifactId>tomcat-catalina</artifactId>
-            <version>7.0.54</version>
+            <version>${tomcat7.version}</version>
             <scope>provided</scope>
         </dependency>
 

Modified: openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/pom.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/pom.xml (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/pom.xml Tue Aug  5 08:14:40 2014
@@ -32,7 +32,6 @@
 
     <properties>
         <tomcat.port.it>9081</tomcat.port.it>
-        <tomcat7.version>7.0.54</tomcat7.version>
         <jstl.version>1.2</jstl.version>
         <projectStage>Development</projectStage>
     </properties>

Modified: openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/src/main/webapp/META-INF/context.xml?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/src/main/webapp/META-INF/context.xml (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/it/servletinjection/src/main/webapp/META-INF/context.xml Tue Aug  5 08:14:40 2014
@@ -16,5 +16,5 @@
     License.
 -->
 <Context>
-  <Listener className="org.apache.webbeans.web.tomcat.ContextLifecycleListener" />
+  <Listener className="org.apache.webbeans.web.tomcat7.ContextLifecycleListener" />
 </Context>

Modified: openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/ContextLifecycleListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/ContextLifecycleListener.java?rev=1615884&r1=1613878&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/ContextLifecycleListener.java (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/ContextLifecycleListener.java Tue Aug  5 08:14:40 2014
@@ -16,21 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.web.tomcat;
+package org.apache.webbeans.web.tomcat7;
 
-import org.apache.catalina.Container;
-import org.apache.catalina.ContainerEvent;
-import org.apache.catalina.ContainerListener;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Service;
-import org.apache.catalina.core.ContainerBase;
 import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardEngine;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.core.StandardServer;
-import org.apache.naming.ContextAccessController;
 import org.apache.tomcat.InstanceManager;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.servlet.WebBeansConfigurationListener;
@@ -38,17 +29,10 @@ import org.apache.webbeans.servlet.WebBe
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextAttributeEvent;
 import javax.servlet.ServletContextAttributeListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.HashMap;
 import java.util.LinkedList;
-import java.util.Map;
 
 
 /**
@@ -58,11 +42,8 @@ import java.util.Map;
  * @version $Rev$ $Date$
  *
  */
-public class ContextLifecycleListener implements PropertyChangeListener, LifecycleListener, ContainerListener, ServletContextAttributeListener
+public class ContextLifecycleListener implements LifecycleListener, ServletContextAttributeListener
 {
-
-    private StandardServer standardServer;
-
     public ContextLifecycleListener()
     {
     }
@@ -72,15 +53,7 @@ public class ContextLifecycleListener im
     {
         try
         {
-            if (event.getSource() instanceof StandardServer)
-            {
-                if (event.getType().equals(Lifecycle.START_EVENT))
-                {
-                    this.standardServer = (StandardServer) event.getSource();
-                    start();
-                }
-            }
-            else if (event.getSource() instanceof StandardContext)
+            if (event.getSource() instanceof StandardContext)
             {
                 StandardContext context = (StandardContext) event.getSource();
 
@@ -93,25 +66,11 @@ public class ContextLifecycleListener im
                         //Registering ELResolver with JSP container
                         System.setProperty("org.apache.webbeans.application.jsp", "true");
 
-                        String[] oldListeners = context.findApplicationListeners();
-                        LinkedList<String> listeners = new LinkedList<String>();
-
-                        listeners.addFirst(WebBeansConfigurationListener.class.getName());
+                        addOwbListeners(context);
+                        addOwbFilters(context);
 
-                        for(String listener : oldListeners)
-                        {
-                            listeners.add(listener);
-                            context.removeApplicationListener(listener);
-                        }
-                        
-                        for(String listener : listeners)
-                        {
-                            context.addApplicationListener(listener);
-                        }                        
-                        
-                        context.addApplicationListener(TomcatSecurityListener.class.getName());
+                        context.addApplicationListener(TomcatSecurityFilter.class.getName());
                         context.addApplicationEventListener(this);
-                        //context.addInstanceListener(TomcatInstanceListener.class.getName());             
                     }
                 }
             }
@@ -122,243 +81,54 @@ public class ContextLifecycleListener im
         }        
     }
 
-    private URL getBeansXml(ServletContext scontext) throws MalformedURLException
-    {
-        URL url = scontext.getResource("/WEB-INF/beans.xml");
-        if (url == null)
-        {
-            url = scontext.getResource("/WEB-INF/classes/META-INF/beans.xml");
-        }
-        return url;
-    }
 
-    @Override
-    public void containerEvent(ContainerEvent event)
+    private void addOwbListeners(StandardContext context)
     {
-        StandardContext context;
-        try
-        {
-            if(event.getSource() instanceof StandardContext)
-            {               
-                context = (StandardContext)event.getSource();
+        String[] oldListeners = context.findApplicationListeners();
+        LinkedList<String> listeners = new LinkedList<String>();
 
-                if(event.getType().equals("beforeContextInitialized"))
-                {
-                    ClassLoader loader = context.getLoader().getClassLoader();
-                    Object listener = event.getData();
-                    
-                    if(listener.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
-                    {
-                       ContextAccessController.setWritable(context.getNamingContextListener().getName(), context);                       
-                       return;
-                    }
-                    else
-                    {
-                        URL url = getBeansXml(context.getServletContext());
-                        if(url != null)
-                        {
-                            TomcatUtil.inject(listener, loader);   
-                        }
-                    }
-                }
-                else if(event.getType().equals("afterContextInitialized"))
-                {
-                    ClassLoader loader = context.getLoader().getClassLoader();
-                    Object listener = event.getData();
-                    if(listener.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
-                    {
-                        setInstanceManager(context);
-                        
-                        ContextAccessController.setReadOnly(context.getNamingContextListener().getName());
-
-                        URL url = getBeansXml(context.getServletContext());
-                        if(url != null)
-                        {
-                            Object[] listeners = context.getApplicationEventListeners();
-                            for(Object instance : listeners)
-                            {
-                                if(!instance.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
-                                {                                
-                                    TomcatUtil.inject(instance, loader);   
-                                }
-                            }                                                                                    
-                        }                        
-                    }                                
-                }
-                else if(event.getType().equals("beforeContextDestroyed"))
-                {
-                    Object listener = event.getData();
-                    if(listener.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
-                    {
-                        ContextAccessController.setWritable(context.getNamingContextListener().getName(),context);   
-                    }
-                }
-            }
-        }
-        catch(Exception e)
-        {
-            throw new RuntimeException(e);
-        }
-    }
+        listeners.addFirst(WebBeansConfigurationListener.class.getName());
 
-    private void setInstanceManager(final StandardContext context)
-    {
-        if (context.getInstanceManager() instanceof TomcatInstanceManager)
+        for(String listener : oldListeners)
         {
-            return;
+            listeners.add(listener);
+            context.removeApplicationListener(listener);
         }
 
-        InstanceManager processor = context.getInstanceManager();
-        InstanceManager custom = new TomcatInstanceManager(context.getLoader().getClassLoader(), processor);
-        context.setInstanceManager(custom);
-
-        context.getServletContext().setAttribute(InstanceManager.class.getName(), custom);
-    }
-
-    public void start()
-    {
-        // hook the hosts so we get notified before contexts are started
-        standardServer.addPropertyChangeListener(this);
-        standardServer.addLifecycleListener(this);
-        for (Service service : standardServer.findServices())
+        for(String listener : listeners)
         {
-            serviceAdded(service);
+            context.addApplicationListener(listener);
         }
     }
 
-    public void stop()
+    private void addOwbFilters(StandardContext context)
     {
-        standardServer.removePropertyChangeListener(this);
+        // we currently add all filters via web-fragment.xml
     }
 
-    private void serviceAdded(Service service)
-    {
-        Container container = service.getContainer();
-        if (container instanceof StandardEngine)
-        {
-            StandardEngine engine = (StandardEngine) container;
-            engineAdded(engine);
-        }
-    }
-
-    private void engineAdded(StandardEngine engine)
-    {
-        addContextListener(engine);
-        for (Container child : engine.findChildren())
-        {
-            if (child instanceof StandardHost)
-            {
-                StandardHost host = (StandardHost) child;
-                hostAdded(host);
-            }
-        }
-    }
-
-    private void hostAdded(StandardHost host)
+    private URL getBeansXml(ServletContext scontext) throws MalformedURLException
     {
-        addContextListener(host);
-        host.addLifecycleListener(this);
-        for (Container child : host.findChildren())
+        URL url = scontext.getResource("/WEB-INF/beans.xml");
+        if (url == null)
         {
-            if (child instanceof StandardContext)
-            {
-                StandardContext context = (StandardContext) child;
-                contextAdded(context);
-            }
+            url = scontext.getResource("/WEB-INF/classes/META-INF/beans.xml");
         }
+        return url;
     }
 
-    private void contextAdded(StandardContext context)
-    {
-        // put this class as the first listener so we can process the
-        // application before any classes are loaded
-        forceFirstLifecycleListener(context);
-    }
 
-    private void forceFirstLifecycleListener(StandardContext context)
+    private void wrapInstanceManager(final StandardContext context)
     {
-        LifecycleListener[] listeners = context.findLifecycleListeners();
-
-        // if we are already first return
-        if (listeners.length > 0 && listeners[0] == this)
+        if (context.getInstanceManager() instanceof TomcatInstanceManager)
         {
             return;
         }
 
-        // remove all of the current listeners
-        for (LifecycleListener listener : listeners)
-        {
-            context.removeLifecycleListener(listener);
-        }
-
-        // add this class (as first)
-        context.addLifecycleListener(this);
-        context.addContainerListener(this);
-
-        // add back all listeners
-        for (LifecycleListener listener : listeners)
-        {
-            if (listener != this)
-            {
-                context.addLifecycleListener(listener);
-            }
-        }
-    }
-
-    @Override
-    public void propertyChange(PropertyChangeEvent event)
-    {
-        if ("service".equals(event.getPropertyName()))
-        {
-            Object oldValue = event.getOldValue();
-            Object newValue = event.getNewValue();
-            if (oldValue == null && newValue instanceof Service)
-            {
-                serviceAdded((Service) newValue);
-            }
-        }
-        if ("children".equals(event.getPropertyName()))
-        {
-            Object source = event.getSource();
-            Object oldValue = event.getOldValue();
-            Object newValue = event.getNewValue();
-            if (source instanceof StandardEngine)
-            {
-                if (oldValue == null && newValue instanceof StandardHost)
-                {
-                    hostAdded((StandardHost) newValue);
-                }
-            }
-            if (source instanceof StandardHost)
-            {
-                if (oldValue == null && newValue instanceof StandardContext)
-                {
-                    contextAdded((StandardContext) newValue);
-                }
-            }
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void addContextListener(ContainerBase containerBase)
-    {
-        try
-        {
-            Field field = (Field)AccessController.doPrivileged(new PrivilegedActionForClass(ContainerBase.class, "children"));
-            AccessController.doPrivileged(new PrivilegedActionForAccessibleObject(field, true));
-            Map<Object,Object> children = (Map<Object,Object>) field.get(containerBase);
-            if (children instanceof ContextLifecycleListener.MoniterableHashMap)
-            {
-                return;
-            }
-            children = new ContextLifecycleListener.MoniterableHashMap(children, containerBase, "children", this);
-            field.set(containerBase, children);
-        }
-        catch (Exception e)
-        {
-            throw new RuntimeException(e);
-        }
+        InstanceManager processor = context.getInstanceManager();
+        InstanceManager custom = new TomcatInstanceManager(context.getLoader().getClassLoader(), processor);
+        context.setInstanceManager(custom);
 
+        context.getServletContext().setAttribute(InstanceManager.class.getName(), custom);
     }
 
     @Override
@@ -368,9 +138,8 @@ public class ContextLifecycleListener im
         { // used as a hook to know we can override eagerly the InstanceManager
             try
             {
-                final StandardContext context = (StandardContext) getContext(
-                                            getContext(servletContextAttributeEvent.getServletContext()));
-                setInstanceManager(context);
+                final StandardContext context = (StandardContext) getContext(servletContextAttributeEvent.getServletContext());
+                wrapInstanceManager(context);
             }
             catch (NoSuchFieldException e)
             {
@@ -390,7 +159,12 @@ public class ContextLifecycleListener im
         getContext.setAccessible(true);
         try
         {
-            return getContext.get(o);
+            Object retVal =  getContext.get(o);
+            if (! (retVal instanceof StandardContext))
+            {
+                retVal = getContext(retVal);
+            }
+            return retVal;
         }
         finally
         {
@@ -401,97 +175,12 @@ public class ContextLifecycleListener im
     @Override
     public void attributeRemoved(ServletContextAttributeEvent servletContextAttributeEvent)
     {
-        // no-op
+        // nothing to do
     }
 
     @Override
     public void attributeReplaced(ServletContextAttributeEvent servletContextAttributeEvent)
     {
-        // no-op
+        // nothing to do
     }
-
-    public static class MoniterableHashMap extends HashMap<Object,Object>
-    {
-        private static final long serialVersionUID = 1L;
-
-        private final Object source;
-        private final String propertyName;
-        private final PropertyChangeListener listener;
-
-        public MoniterableHashMap(Map<Object,Object> m, Object source, String propertyName, PropertyChangeListener listener)
-        {
-            super(m);
-            this.source = source;
-            this.propertyName = propertyName;
-            this.listener = listener;
-        }
-
-        @Override
-        public Object put(Object key, Object value)
-        {
-            Object oldValue = super.put(key, value);
-            PropertyChangeEvent event = new PropertyChangeEvent(source, propertyName, null, value);
-            listener.propertyChange(event);
-            return oldValue;
-        }
-
-        @Override
-        public Object remove(Object key)
-        {
-            Object value = super.remove(key);
-            PropertyChangeEvent event = new PropertyChangeEvent(source, propertyName, value, null);
-            listener.propertyChange(event);
-            return value;
-        }
-    }
-
-    protected static class PrivilegedActionForAccessibleObject implements PrivilegedAction<Object>
-    {
-
-        AccessibleObject object;
-
-        boolean flag;
-
-        protected PrivilegedActionForAccessibleObject(AccessibleObject object, boolean flag)
-        {
-            this.object = object;
-            this.flag = flag;
-        }
-
-        @Override
-        public Object run()
-        {
-            object.setAccessible(flag);
-            return null;
-        }
-    }
-
-    protected static class PrivilegedActionForClass implements PrivilegedAction<Object>
-    {
-        Class<?> clazz;
-
-        Object parameters;
-
-        protected PrivilegedActionForClass(Class<?> clazz, Object parameters)
-        {
-            this.clazz = clazz;
-            this.parameters = parameters;
-        }
-
-        @Override
-        public Object run()
-        {
-            try
-            {
-                return clazz.getDeclaredField((String)parameters);
-            }
-            catch (NoSuchFieldException e)
-            {
-                throw new RuntimeException(e);
-            }
-        }
-
-    }
-
-    
 }

Modified: openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java?rev=1615884&r1=1613878&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java Tue Aug  5 08:14:40 2014
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.web.tomcat;
+package org.apache.webbeans.web.tomcat7;
 
 import java.lang.reflect.InvocationTargetException;
 import java.util.Map;

Copied: openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityFilter.java (from r1613878, openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat/TomcatSecurityListener.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityFilter.java?p2=openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityFilter.java&p1=openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat/TomcatSecurityListener.java&r1=1613878&r2=1615884&rev=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat/TomcatSecurityListener.java (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityFilter.java Tue Aug  5 08:14:40 2014
@@ -16,46 +16,68 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.web.tomcat;
+package org.apache.webbeans.web.tomcat7;
 
+import java.io.IOException;
 import java.security.Principal;
 
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletRequestListener;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 
-public class TomcatSecurityListener implements ServletRequestListener
+
+/**
+ * Filter which sets the UserPrincipal into a ThreadLocal
+ * to make it injectable via a CDI Producer
+ */
+public class TomcatSecurityFilter implements Filter
 {
-    public static ThreadLocal<Principal> principal = new ThreadLocal<Principal>();
+    private static ThreadLocal<Principal> principal = new ThreadLocal<Principal>();
     
-    public TomcatSecurityListener()
+    public static Principal getPrincipal()
     {
-        
+        return principal.get();
     }
-    
+
     @Override
-    public void requestDestroyed(ServletRequestEvent event)
+    public void init(FilterConfig filterConfig) throws ServletException
     {
-        if(principal.get() != null)
-        {
-            principal.remove();   
-        }
+        // nothing to do
     }
 
     @Override
-    public void requestInitialized(ServletRequestEvent event)
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
     {
-        ServletRequest request = event.getServletRequest();
-        if(request instanceof HttpServletRequest)
+        try
+        {
+            if(request instanceof HttpServletRequest)
+            {
+                Principal p = ((HttpServletRequest)request).getUserPrincipal();
+                if(p != null)
+                {
+                    principal.set(p);
+                }
+            }
+
+            // continue with the request
+            chain.doFilter(request, response);
+        }
+        finally
         {
-            Principal p = ((HttpServletRequest)request).getUserPrincipal();
-            if(p != null)
+            if(principal.get() != null)
             {
-                principal.set(p);
+                principal.remove();
             }
         }
-        
     }
 
+    @Override
+    public void destroy()
+    {
+        // nothing to do
+    }
 }

Modified: openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityService.java?rev=1615884&r1=1613878&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityService.java (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityService.java Tue Aug  5 08:14:40 2014
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.web.tomcat;
+package org.apache.webbeans.web.tomcat7;
 
 import java.security.Principal;
 
@@ -29,7 +29,7 @@ public class TomcatSecurityService exten
     @Override
     public Principal getCurrentPrincipal()
     {
-        return TomcatSecurityListener.principal.get();
+        return TomcatSecurityFilter.getPrincipal();
     }
 
 }

Modified: openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatUtil.java?rev=1615884&r1=1613878&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatUtil.java (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatUtil.java Tue Aug  5 08:14:40 2014
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.web.tomcat;
+package org.apache.webbeans.web.tomcat7;
 
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;

Modified: openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java?rev=1615884&r1=1613878&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java Tue Aug  5 08:14:40 2014
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.web.tomcat;
+package org.apache.webbeans.web.tomcat7;
 
 import javax.jws.WebService;
 import javax.servlet.Filter;
@@ -75,16 +75,16 @@ public class TomcatWebPlugin extends Abs
     @Override
     public void isManagedBean(Class<?> clazz)
     {
-        if(Servlet.class.isAssignableFrom(clazz) ||
-                Filter.class.isAssignableFrom(clazz) ||
-                ServletContextListener.class.isAssignableFrom(clazz) ||
-                ServletContextAttributeListener.class.isAssignableFrom(clazz) ||
-                HttpSessionActivationListener.class.isAssignableFrom(clazz) ||
-                HttpSessionAttributeListener.class.isAssignableFrom(clazz) ||
-                HttpSessionBindingListener.class.isAssignableFrom(clazz) ||
-                HttpSessionListener.class.isAssignableFrom(clazz) ||
-                ServletRequestListener.class.isAssignableFrom(clazz) ||
-                ServletRequestAttributeListener.class.isAssignableFrom(clazz) )
+        if (Servlet.class.isAssignableFrom(clazz) ||
+            Filter.class.isAssignableFrom(clazz) ||
+            ServletContextListener.class.isAssignableFrom(clazz) ||
+            ServletContextAttributeListener.class.isAssignableFrom(clazz) ||
+            HttpSessionActivationListener.class.isAssignableFrom(clazz) ||
+            HttpSessionAttributeListener.class.isAssignableFrom(clazz) ||
+            HttpSessionBindingListener.class.isAssignableFrom(clazz) ||
+            HttpSessionListener.class.isAssignableFrom(clazz) ||
+            ServletRequestListener.class.isAssignableFrom(clazz) ||
+            ServletRequestAttributeListener.class.isAssignableFrom(clazz) )
         {
             throw new DefinitionException("Given class  : " + clazz.getName() + " is not managed bean");
         }

Added: openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1615884&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (added)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Tue Aug  5 08:14:40 2014
@@ -0,0 +1,24 @@
+#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.
+#---------------------------------------------------------------
+# The configuration for Tomcat7
+#
+#---------------------------------------------------------------
+
+
+# use a special securityService for Principal injection
+org.apache.webbeans.spi.SecurityService=org.apache.webbeans.web.tomcat7.TomcatSecurityService
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin?rev=1615884&r1=1615883&r2=1615884&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin (original)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/services/org.apache.webbeans.spi.plugins.OpenWebBeansPlugin Tue Aug  5 08:14:40 2014
@@ -14,4 +14,4 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-org.apache.webbeans.web.tomcat.TomcatWebPlugin
\ No newline at end of file
+org.apache.webbeans.web.tomcat7.TomcatWebPlugin
\ No newline at end of file

Added: openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/web-fragment.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/web-fragment.xml?rev=1615884&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/web-fragment.xml (added)
+++ openwebbeans/trunk/webbeans-tomcat7/src/main/resources/META-INF/web-fragment.xml Tue Aug  5 08:14:40 2014
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+<web-fragment metadata-complete="true" version="3.0"
+              xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd">
+    <name>OwbTomcat7</name>
+    <ordering>
+        <before>others</before>
+    </ordering>
+    <filter>
+        <icon/>
+        <filter-name>OwbSecurityFilter</filter-name>
+        <filter-class>org.apache.webbeans.web.tomcat7.TomcatSecurityFilter</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>OwbSecurityFilter</filter-name>
+        <url-pattern>*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+    </filter-mapping>
+</web-fragment>
\ No newline at end of file



Mime
View raw message