Author: struberg
Date: Tue Sep 25 17:23:29 2012
New Revision: 1390004
URL: http://svn.apache.org/viewvc?rev=1390004&view=rev
Log:
OWB-705 more unit tests and start fixing the sample
Added:
openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml
openwebbeans/trunk/webbeans-tomcat6/src/it/
- copied from r1389801, openwebbeans/trunk/webbeans-tomcat7/src/it/
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestBean.java
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestServlet.java
Removed:
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat7/
Modified:
openwebbeans/trunk/samples/tomcat-sample/pom.xml
openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml
openwebbeans/trunk/webbeans-tomcat6/pom.xml
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/pom.xml
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/WEB-INF/web.xml
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/test/java/org/apache/webbeans/web/tomcat7/test/OwbTomcatPluginIT.java
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/ContextLifecycleListener.java
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/TomcatUtil.java
Modified: openwebbeans/trunk/samples/tomcat-sample/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/pom.xml?rev=1390004&r1=1390003&r2=1390004&view=diff
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/pom.xml (original)
+++ openwebbeans/trunk/samples/tomcat-sample/pom.xml Tue Sep 25 17:23:29 2012
@@ -68,22 +68,25 @@ under the License.
</dependency>
<dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-tomcat6</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<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>
@@ -103,7 +106,65 @@ under the License.
<version>1.1</version>
<configuration>
<url>http://localhost:8080/manager</url>
+ <addContextWarDependencies>true</addContextWarDependencies>
</configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <version>${geronimo_interceptor.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-ee-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-tomcat6</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_1.0_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.openwebbeans</groupId>
+ <artifactId>openwebbeans-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-el10</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
</plugin>
</plugins>
</build>
Added:
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=1390004&view=auto
==============================================================================
---
openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml
(added)
+++
openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/context.xml
Tue Sep 25 17:23:29 2012
@@ -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.
+-->
+<Context>
+ <Listener
className="org.apache.webbeans.web.tomcat.ContextLifecycleListener" />
+</Context>
Modified:
openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml?rev=1390004&r1=1390003&r2=1390004&view=diff
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml
(original)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml
Tue Sep 25 17:23:29 2012
@@ -34,6 +34,7 @@
<servlet-name>injector</servlet-name>
<url-pattern>/injector</url-pattern>
</servlet-mapping>
+<!--
<security-constraint>
<display-name>injector</display-name>
<web-resource-collection>
@@ -51,4 +52,5 @@
<security-role>
<role-name>manager</role-name>
</security-role>
+-->
</web-app>
Modified: openwebbeans/trunk/webbeans-tomcat6/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/pom.xml?rev=1390004&r1=1390003&r2=1390004&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat6/pom.xml (original)
+++ openwebbeans/trunk/webbeans-tomcat6/pom.xml Tue Sep 25 17:23:29 2012
@@ -31,9 +31,21 @@
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
- <version>6.0.26</version>
+ <version>6.0.35</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
@@ -50,16 +62,44 @@
<artifactId>openwebbeans-web</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jcdi_1.0_spec</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-atinject_1.0_spec</artifactId>
- <scope>provided</scope>
- </dependency>
+
</dependencies>
-
+
+ <profiles>
+ <profile>
+ <id>run-its</id>
+ <build>
+ <plugins>
+ <!-- invoke the integration tests under src/it -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <debug>true</debug>
+ <projectsDirectory>src/it</projectsDirectory>
+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <goals>
+ <goal>install</goal>
+ </goals>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
Modified: openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/pom.xml?rev=1390004&r1=1389801&r2=1390004&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/pom.xml
(original)
+++ openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/pom.xml Tue Sep
25 17:23:29 2012
@@ -25,14 +25,14 @@
</parent>
<groupId>org.apache.openwebbeans.it</groupId>
- <artifactId>openwebbeans-tomcat7-it-servletinjection</artifactId>
+ <artifactId>openwebbeans-tomcat6-it-servletinjection</artifactId>
<version>@project.version@</version>
<packaging>war</packaging>
- <name>Tomcat 7 plugin IT</name>
+ <name>Tomcat 6 plugin IT</name>
<properties>
- <tomcat.port.it>9081</tomcat.port.it>
- <tomcat7.version>7.0.30</tomcat7.version>
+ <tomcat.port.it>9086</tomcat.port.it>
+ <tomcat6.version>6.0.35</tomcat6.version>
<jstl.version>1.2</jstl.version>
<projectStage>Development</projectStage>
</properties>
@@ -75,7 +75,7 @@
</dependencies>
<build>
- <finalName>owbtomcat7it</finalName>
+ <finalName>owbtomcat6it</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -85,169 +85,10 @@
<pluginManagement>
<plugins>
<plugin>
- <!-- needed for the tomcat7 integration tests -->
+ <!-- needed for the tomcat6 integration tests -->
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.0-beta-1</version>
- <dependencies>
- <dependency>
- <groupId>jstl</groupId>
- <artifactId>jstl</artifactId>
- <version>${jstl.version}</version>
- </dependency>
-
- <!--
- tomcat7-maven-plugin dependencies
- We need to add those for specifying the 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>
-
- <!-- tomcat i18n too ?? -->
-
- <!-- not sure we need that -->
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-juli</artifactId>
- <version>${tomcat7.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-logging-juli</artifactId>
- <version>${tomcat7.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-logging-log4j</artifactId>
- <version>${tomcat7.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-impl</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.0_spec</artifactId>
- <version>1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-atinject_1.0_spec</artifactId>
- <version>1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
-
<artifactId>geronimo-interceptor_1.1_spec</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
+ <artifactId>tomcat6-maven-plugin</artifactId>
+ <version>2.0</version>
</plugin>
</plugins>
@@ -276,8 +117,8 @@
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.0-beta-1</version>
+ <artifactId>tomcat6-maven-plugin</artifactId>
+ <version>2.0</version>
<configuration>
<path>/${project.build.finalName}</path>
<addContextWarDependencies>true</addContextWarDependencies>
@@ -304,6 +145,43 @@
</goals>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</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-tomcat6</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ </dependencies>
</plugin>
</plugins>
</build>
Added:
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestBean.java?rev=1390004&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestBean.java
(added)
+++
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestBean.java
Tue Sep 25 17:23:29 2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.web.tomcat6.test;
+
+import javax.enterprise.context.ApplicationScoped;
+
+/**
+ * Test bean which gets used in the TestServlet.
+ */
+@ApplicationScoped
+public class TestBean
+{
+ int i = 4711;
+
+ public int getI()
+ {
+ return i;
+ }
+
+ public void setI(int i)
+ {
+ this.i = i;
+ }
+}
Added:
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestServlet.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestServlet.java?rev=1390004&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestServlet.java
(added)
+++
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/java/org/apache/webbeans/web/tomcat6/test/TestServlet.java
Tue Sep 25 17:23:29 2012
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.web.tomcat6.test;
+
+import javax.inject.Inject;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import java.io.IOException;
+
+/**
+ * Dummy Servlet which just checks whether CDI injection works
+ */
+public class TestServlet implements Servlet
+{
+
+ @Inject
+ private TestBean tb;
+
+ public void destroy()
+ {
+ // nothing to do
+ }
+
+ public void init(ServletConfig config) throws ServletException
+ {
+ // nothing to do
+ }
+
+ public ServletConfig getServletConfig()
+ {
+ return null;
+ }
+
+ public void service(ServletRequest req, ServletResponse res) throws
ServletException, IOException
+ {
+ if (tb == null || tb.getI() != 4711)
+ {
+ throw new RuntimeException("CDI Injction doesn not work!");
+ }
+ }
+
+ public String getServletInfo()
+ {
+ return null;
+ }
+}
Modified:
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/WEB-INF/web.xml?rev=1390004&r1=1389801&r2=1390004&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/WEB-INF/web.xml
(original)
+++
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/main/webapp/WEB-INF/web.xml
Tue Sep 25 17:23:29 2012
@@ -23,7 +23,7 @@ under the License.
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>TestServlet</servlet-name>
-
<servlet-class>org.apache.webbeans.web.tomcat7.test.TestServlet</servlet-class>
+
<servlet-class>org.apache.webbeans.web.tomcat6.test.TestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
Modified:
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/test/java/org/apache/webbeans/web/tomcat7/test/OwbTomcatPluginIT.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/test/java/org/apache/webbeans/web/tomcat7/test/OwbTomcatPluginIT.java?rev=1390004&r1=1389801&r2=1390004&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/test/java/org/apache/webbeans/web/tomcat7/test/OwbTomcatPluginIT.java
(original)
+++
openwebbeans/trunk/webbeans-tomcat6/src/it/servletinjection/src/test/java/org/apache/webbeans/web/tomcat7/test/OwbTomcatPluginIT.java
Tue Sep 25 17:23:29 2012
@@ -39,7 +39,7 @@ public class OwbTomcatPluginIT
public void testTomcatRequest() throws Exception
{
DefaultHttpClient httpclient = new DefaultHttpClient();
- HttpGet httpGet = new
HttpGet("http://localhost:9081/owbtomcat7it/test.test");
+ HttpGet httpGet = new
HttpGet("http://localhost:9086/owbtomcat6it/test.test");
HttpResponse response = httpclient.execute(httpGet);
Modified:
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/ContextLifecycleListener.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/ContextLifecycleListener.java?rev=1390004&r1=1390003&r2=1390004&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/ContextLifecycleListener.java
(original)
+++
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/ContextLifecycleListener.java
Tue Sep 25 17:23:29 2012
@@ -32,6 +32,7 @@ import org.apache.catalina.core.Standard
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.core.StandardServer;
import org.apache.naming.ContextAccessController;
+import org.apache.webbeans.servlet.WebBeansConfigurationListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -60,6 +61,7 @@ public class ContextLifecycleListener im
public ContextLifecycleListener()
{
+ System.out.println("MSX TODO REMOVE ContextLifecycleListener invoked");
}
public void lifecycleEvent(LifecycleEvent event)
@@ -89,7 +91,7 @@ public class ContextLifecycleListener im
String[] oldListeners =
context.findApplicationListeners();
LinkedList<String> listeners = new
LinkedList<String>();
-
listeners.addFirst("org.apache.webbeans.servlet.WebBeansConfigurationListener");
+
listeners.addFirst(WebBeansConfigurationListener.class.getName());
for(String listener : oldListeners)
{
listeners.add(listener);
@@ -102,7 +104,7 @@ public class ContextLifecycleListener im
}
context.addApplicationListener(TomcatSecurityListener.class.getName());
-
//context.addInstanceListener(TomcatInstanceListener.class.getName());
+
//context.addInstanceListener(TomcatInstanceListener.class.getName());
}
}
}
@@ -128,7 +130,7 @@ public class ContextLifecycleListener im
ClassLoader loader = context.getLoader().getClassLoader();
Object listener = event.getData();
-
if(listener.getClass().getName().equals("org.apache.webbeans.servlet.WebBeansConfigurationListener"))
+
if(listener.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
{
ContextAccessController.setWritable(context.getNamingContextListener().getName(),
context);
return;
@@ -148,7 +150,7 @@ public class ContextLifecycleListener im
ClassLoader loader = context.getLoader().getClassLoader();
Object listener = event.getData();
-
if(listener.getClass().getName().equals("org.apache.webbeans.servlet.WebBeansConfigurationListener"))
+
if(listener.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
{
AnnotationProcessor processor =
context.getAnnotationProcessor();
AnnotationProcessor custom = new
TomcatAnnotProcessor(context.getLoader().getClassLoader(),processor);
@@ -164,7 +166,7 @@ public class ContextLifecycleListener im
Object[] listeners =
context.getApplicationEventListeners();
for(Object instance : listeners)
{
-
if(!instance.getClass().getName().equals("org.apache.webbeans.servlet.WebBeansConfigurationListener"))
+
if(!instance.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
{
TomcatUtil.inject(instance, loader);
}
@@ -175,7 +177,7 @@ public class ContextLifecycleListener im
else if(event.getType().equals("beforeContextDestroyed"))
{
Object listener = event.getData();
-
if(listener.getClass().getName().equals("org.apache.webbeans.servlet.WebBeansConfigurationListener"))
+
if(listener.getClass().getName().equals(WebBeansConfigurationListener.class.getName()))
{
ContextAccessController.setWritable(context.getNamingContextListener().getName(),context);
}
Modified:
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/TomcatUtil.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/TomcatUtil.java?rev=1390004&r1=1390003&r2=1390004&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/TomcatUtil.java
(original)
+++
openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/TomcatUtil.java
Tue Sep 25 17:23:29 2012
@@ -18,25 +18,67 @@
*/
package org.apache.webbeans.web.tomcat;
-import java.lang.reflect.Method;
+import org.apache.webbeans.component.InjectionTargetWrapper;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.inject.OWBInjector;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
public class TomcatUtil
{
public static Object inject(Object object, ClassLoader loader) throws
Exception
{
- Class<?> injector =
loader.loadClass("org.apache.webbeans.inject.OWBInjector");
- Object injectorInstance = injector.newInstance();
- Method method = injector.getDeclaredMethod("inject", new
Class<?>[]{Object.class});
- injectorInstance = method.invoke(injectorInstance, new
Object[]{object});
-
- return injectorInstance;
+ final ClassLoader oldLoader =
Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(loader);
+ CreationalContext<?> context = null;
+ try
+ {
+ final BeanManager beanManager =
WebBeansContext.currentInstance().getBeanManagerImpl();
+ context = beanManager.createCreationalContext(null);
+ OWBInjector.inject(beanManager, object, context);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldLoader);
+ }
+ return new Instance(object, context);
}
-
+
public static void destroy(Object injectorInstance, ClassLoader loader)
throws Exception
{
- Class<?> injector =
loader.loadClass("org.apache.webbeans.inject.OWBInjector");
- Method method = injector.getDeclaredMethod("destroy", new
Class<?>[]{});
- method.invoke(injectorInstance, new Object[]{});
+ final Instance instance = (TomcatUtil.Instance) injectorInstance;
+ final ClassLoader oldLoader =
Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(loader);
+ try
+ {
+ final BeanManagerImpl beanManager =
WebBeansContext.currentInstance().getBeanManagerImpl();
+ final InjectionTargetWrapper wrapper =
beanManager.getInjectionTargetWrapper(instance.object.getClass());
+ if (wrapper != null)
+ {
+ wrapper.dispose(instance.object);
+ }
+ else if (instance.context != null)
+ {
+ instance.context.release();
+ }
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldLoader);
+ }
}
+ private static class Instance
+ {
+ private Object object;
+ private CreationalContext<?> context;
+
+ private Instance(Object object, CreationalContext<?> context)
+ {
+ this.object = object;
+ this.context = context;
+ }
+ }
}