Author: julien(a)jboss.com
Date: 2007-09-10 19:06:44 -0400 (Mon, 10 Sep 2007)
New Revision: 8208
Added:
modules/web/trunk/web/src/main/org/jboss/portal/test/
modules/web/trunk/web/src/main/org/jboss/portal/test/web/
modules/web/trunk/web/src/main/org/jboss/portal/test/web/WebAppRegistry.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerContextImpl.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerTestCase.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/WebAppContextImpl.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestCase.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestConfig.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestServlet.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/AbstractCallback.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/ExceptionCallback.java
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/NormalCallback.java
modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainerFactory.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/DefaultServletContainerFactory.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericServletContainerContext.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericWebAppContext.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/PortletContainerBootstrapServlet.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ContainerServlet.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6LifecycleListener.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppContext.java
modules/web/trunk/web/src/resources/portal-web-test-jar/
modules/web/trunk/web/src/resources/portal-web-test-jar/org/
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/client-beans.xml
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/server-beans.xml
modules/web/trunk/web/src/resources/test/
modules/web/trunk/web/src/resources/test/config/
modules/web/trunk/web/src/resources/test/config/servers.xml
modules/web/trunk/web/src/resources/test/spi/
modules/web/trunk/web/src/resources/test/spi/app-war/
modules/web/trunk/web/src/resources/test/spi/app-war/WEB-INF/
modules/web/trunk/web/src/resources/test/spi/app-war/WEB-INF/web.xml
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/context.xml
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/web.xml
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/META-INF/
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/META-INF/context.xml
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/log4j.properties
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/logging.properties
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/web.xml
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/log4j.properties
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/logging.properties
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/web.xml
Removed:
modules/web/trunk/web/src/main/org/jboss/portal/web/command/ServletCommand.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebApp.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppIdFactory.java
Modified:
modules/web/trunk/build/build-thirdparty.xml
modules/web/trunk/build/ide/intellij/idea60/modules/web/web.iml
modules/web/trunk/tools/etc/buildfragments/buildmagic.ent
modules/web/trunk/web/build.xml
modules/web/trunk/web/src/main/org/jboss/portal/web/RequestDispatchCallback.java
modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainer.java
modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContextDispatcher.java
modules/web/trunk/web/src/main/org/jboss/portal/web/WebApp.java
modules/web/trunk/web/src/main/org/jboss/portal/web/WebAppLifeCycleEvent.java
modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandDispatcher.java
modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandServlet.java
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java
modules/web/trunk/web/src/main/org/jboss/portal/web/spi/ServletContainerContext.java
Log:
improve the web module SPI + add test SPI testing
Modified: modules/web/trunk/build/build-thirdparty.xml
===================================================================
--- modules/web/trunk/build/build-thirdparty.xml 2007-09-10 23:03:20 UTC (rev 8207)
+++ modules/web/trunk/build/build-thirdparty.xml 2007-09-10 23:06:44 UTC (rev 8208)
@@ -48,10 +48,42 @@
-->
<componentref name="jboss-portal/modules/common"
version="1.0.0-SNAPSHOT"/>
- <componentref name="apache-log4j" version="1.2.8"/>
- <componentref name="junit" version="3.8.1"/>
+ <componentref name="jboss-portal/modules/test"
version="1.0.0-SNAPSHOT"/>
<componentref name="sun-servlet" version="2.4"/>
<componentref name="apache-tomcat" version="5.0.30"/>
+
+ <componentref name="jboss/remoting"
version="2.2.0.SP4"/>
+
+ <componentref name="apache-httpclient" version="3.0.1"/>
+ <componentref name="apache-logging"
version="1.0.5.SP1-jboss"/>
+ <componentref name="apache-codec" version="1.3.0"/>
+
+ <componentref name="jboss/common"
version="1.2.0.GA-brew"/>
+ <componentref name="jboss/microcontainer"
version="1.0.2"/>
+ <componentref name="apache-log4j" version="1.2.14"/>
+ <componentref name="oswego-concurrent" version="1.3.4"/>
+ <componentref name="jboss/jbossxb"
version="1.0.0.GA-brew"/>
+ <componentref name="junit" version="3.8.1"/>
+
+ <!-- Based on
http://anonsvn.jboss.org/repos/jbossas/tags/EMBEDDED_JBOSS_BETA_2/build/b...
-->
+<!--
+ <componentref name="jboss/microcontainer"
version="2.0.0.Beta3"/>
+ <componentref name="jboss/aop" version="2.0.0.alpha4"/>
+ <componentref name="jboss/jbossxb" version="2.0.0.CR2"/>
+ <componentref name="jboss/jboss-vfs"
version="2.0.0.Beta4"/>
+ <componentref name="jboss/common-core"
version="2.0.4.Alpha"/>
+ <componentref name="jboss/common-logging-log4j"
version="2.0.2.GA"/>
+ <componentref name="jboss/common-logging-jdk"
version="2.0.2.GA"/>
+ <componentref name="jboss/common-logging-spi"
version="2.0.2.GA"/>
+ <componentref name="javassist" version="3.5.0.CR1"/>
+ <componentref name="apache-log4j" version="1.2.14"/>
+ <componentref name="apache-xerces" version="2.7.1"/>
+ <componentref name="sun-jaf" version="1.1"/>
+ <componentref name="junit" version="3.8.1"/>
+ <componentref name="wutka-dtdparser" version="1.2.1"/>
+ <componentref name="trove" version="1.0.2"/>
+-->
+
</build>
<synchronizeinfo/>
Modified: modules/web/trunk/build/ide/intellij/idea60/modules/web/web.iml
===================================================================
--- modules/web/trunk/build/ide/intellij/idea60/modules/web/web.iml 2007-09-10 23:03:20
UTC (rev 8207)
+++ modules/web/trunk/build/ide/intellij/idea60/modules/web/web.iml 2007-09-10 23:06:44
UTC (rev 8208)
@@ -44,6 +44,51 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/junit/lib/junit.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/oswego-concurrent/lib/concurrent.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/jboss-portal/modules/test/lib/portal-test-lib.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/jboss-portal/modules/common/lib/portal-common-mc-lib.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/jboss/common/lib/jboss-common.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: modules/web/trunk/tools/etc/buildfragments/buildmagic.ent
===================================================================
--- modules/web/trunk/tools/etc/buildfragments/buildmagic.ent 2007-09-10 23:03:20 UTC (rev
8207)
+++ modules/web/trunk/tools/etc/buildfragments/buildmagic.ent 2007-09-10 23:06:44 UTC (rev
8208)
@@ -685,7 +685,7 @@
jvm="${junit.jvm}">
<formatter type="plain" usefile="false"/>
<formatter
-
classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+
classname="org.jboss.portal.common.junit.ant.ConfigurableXMLJUnitResultFormatter"
usefile="${junit.formatter.usefile}"
extension="${jboss-junit-configuration}.xml"/>
<sysproperty key="build.resources"
value="${build.resources}"/>
@@ -696,7 +696,7 @@
<jvmarg value="${junit.jvm.options}"/>
<x-test/>
<classpath>
- <path refid="jboss.test.classpath"/>
+ <path refid="jboss.portal/modules/test.classpath"/>
<pathelement path="${driver.path}"/>
<x-classpath/>
</classpath>
Modified: modules/web/trunk/web/build.xml
===================================================================
--- modules/web/trunk/web/build.xml 2007-09-10 23:03:20 UTC (rev 8207)
+++ modules/web/trunk/web/build.xml 2007-09-10 23:06:44 UTC (rev 8208)
@@ -89,10 +89,13 @@
&libraries;
<path id="library.classpath">
<path refid="jboss.portal/modules/common.classpath"/>
+ <path refid="jboss.portal/modules/test.classpath"/>
<path refid="sun.servlet.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="junit.junit.classpath"/>
<path refid="apache.tomcat.classpath"/>
+ <path refid="jboss.common.classpath"/>
</path>
<!-- Configure modules -->
@@ -184,6 +187,114 @@
<!-- Deployment -->
<!-- ================================================================== -->
- <target name="package-tests"/>
+ <target name="package-tests" depends="init">
+ <!-- portal-web-test-lib.jar -->
+ <jar jarfile="${build.lib}/portal-web-test-lib.jar">
+ <fileset dir="${build.classes}"
includes="org/jboss/portal/test/web/spi/**"/>
+ <fileset dir="${build.resources}/portal-web-test-jar"/>
+ </jar>
+
+ <!-- -->
+ <copy
todir="${build.resources}/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/lib">
+ <fileset dir="${build.lib}"
includes="portal-web-test-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/common.lib}"
includes="portal-common-mc-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/test.lib}"
includes="portal-test-lib.jar,portal-test-generic-lib.jar"/>
+ <fileset dir="${jboss.microcontainer.lib}"
includes="jboss-container.jar,jboss-dependency.jar,jboss-microcontainer.jar"/>
+ <fileset dir="${jboss.common.lib}"
includes="jboss-common.jar"/>
+ <fileset dir="${oswego.concurrent.lib}"
includes="concurrent.jar"/>
+ <fileset dir="${jboss.remoting.lib}"
includes="jboss-remoting.jar"/>
+ <fileset dir="${jboss.jbossxb.lib}"
includes="jboss-xml-binding.jar"/>
+ <fileset dir="${apache.log4j.lib}"
includes="log4j.jar"/>
+ <fileset dir="${apache.xerces.lib}"
includes="xercesImpl.jar"/>
+ </copy>
+ <mkdir dir="${build.lib}/tomcat-container-servlet-6.0"/>
+ <jar
jarfile="${build.lib}/tomcat-container-servlet-6.0/test-spi-server.war">
+ <fileset
dir="${build.resources}/test/spi/tomcat-container-servlet-6.0/server-war"/>
+ </jar>
+
+ <!-- -->
+ <copy
todir="${build.resources}/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/lib">
+ <fileset dir="${build.lib}"
includes="portal-web-lib.jar"/>
+ <fileset dir="${build.lib}"
includes="portal-web-test-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/common.lib}"
includes="portal-common-lib.jar,portal-common-mc-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/test.lib}"
includes="portal-test-generic-lib.jar"/>
+ </copy>
+ <mkdir dir="${build.lib}/jboss-container-servlet-4.2"/>
+ <jar
jarfile="${build.lib}/jboss-container-servlet-4.2/test-spi-server.war">
+ <fileset
dir="${build.resources}/test/spi/jboss-container-servlet-4.2/server-war"/>
+ </jar>
+
+ <!-- -->
+ <copy
todir="${build.resources}/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/lib">
+ <fileset dir="${build.lib}"
includes="portal-web-test-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/common.lib}"
includes="portal-common-mc-lib.jar"/>
+ <fileset dir="${jboss.portal/modules/test.lib}"
includes="portal-test-lib.jar,portal-test-generic-lib.jar"/>
+ </copy>
+ <mkdir dir="${build.lib}/tomcat-lifecycle-listener-6.0"/>
+ <jar
jarfile="${build.lib}/tomcat-lifecycle-listener-6.0/test-spi-server.war">
+ <fileset
dir="${build.resources}/test/spi/tomcat-lifecycle-listener-6.0/server-war"/>
+ </jar>
+
+ <!-- -->
+ <jar jarfile="${build.lib}/test-spi-app.war">
+ <fileset dir="${build.resources}/test/spi/app-war"/>
+ </jar>
+
+ </target>
+
+ <target name="tests" depends="init">
+
+ <!--<property name="ServerName"
value="RemoteJBoss-4.2"/>-->
+ <property name="ServerName" value="RemoteTomcat-6.0"/>
+
+ <execute-tests>
+ <x-test>
+
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.web.container.ServletContainerTestCase"/>-->
+ <zest todir="${test.reports}"
name="org.jboss.portal.test.web.spi.SPITestCase">
+ <!--<parameter name="archive"
value="test-jsr168-dispatcher.war"/>-->
+ <parameter name="serverName"
value="${ServerName}"/>
+ </zest>
+
+ </x-test>
+ <x-sysproperty>
+ <sysproperty key="test.root"
value="${build.lib}"/>
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
+-->
+ </x-sysproperty>
+ <x-classpath>
+ <pathelement location="${build.lib}/portal-web-lib.jar"/>
+ <pathelement
location="${build.lib}/portal-web-test-lib.jar"/>
+ <pathelement location="${build.resources}/test/config"/>
+ <path refid="oswego.concurrent.classpath"/>
+
+ <!--<path
refid="jboss/common.logging.spi.classpath"/>-->
+ <!--<path refid="jboss/common.core.classpath"/>-->
+ <!--<path refid="jboss.aop.classpath"/>-->
+ <!--<path refid="javassist.javassist.classpath"/>-->
+ <!--<path refid="trove.trove.classpath"/>-->
+
+ <path refid="jboss.remoting.classpath"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss.jbossxb.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+
+ <path refid="jboss.common.classpath"/>
+
+ <path refid="apache.httpclient.classpath"/>
+ <path refid="apache.logging.classpath"/>
+ <path refid="apache.codec.classpath"/>
+ <pathelement location="${build.resources}/test"/>
+ <pathelement
location="../tools/lib/cargo-core-uberjar-0.8.jar"/>
+ <pathelement location="${source.java}"/>
+ <pathelement
location="${jboss.portal-portlet.root}/classes"/>
+ <pathelement
location="${jboss.portal/modules/test.lib}/portal-test-generic-lib.jar"/>
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
</project>
Added: modules/web/trunk/web/src/main/org/jboss/portal/test/web/WebAppRegistry.java
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/test/web/WebAppRegistry.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/WebAppRegistry.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web;
+
+import org.jboss.portal.web.WebAppListener;
+import org.jboss.portal.web.WebAppEvent;
+import org.jboss.portal.web.WebAppLifeCycleEvent;
+import org.jboss.portal.web.WebApp;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebAppRegistry implements WebAppListener
+{
+
+ /** . */
+ final Map map = new HashMap();
+
+ public void onEvent(WebAppEvent event)
+ {
+ if (event instanceof WebAppLifeCycleEvent)
+ {
+ WebApp webApp = event.getWebApp();
+ WebAppLifeCycleEvent lfEvent = (WebAppLifeCycleEvent)event;
+ if (lfEvent.getType() == WebAppLifeCycleEvent.ADDED)
+ {
+ map.put(webApp.getContextPath(), webApp);
+ }
+ else
+ {
+ map.remove(webApp.getContextPath());
+ }
+ }
+ }
+
+ public WebApp getWebApp(String key)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return (WebApp)map.get(key);
+ }
+
+ public Set getKeys()
+ {
+ return map.keySet();
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerContextImpl.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerContextImpl.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerContextImpl.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.container;
+
+import org.jboss.portal.web.spi.ServletContainerContext;
+import org.jboss.portal.web.RequestDispatchCallback;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServletContainerContextImpl implements ServletContainerContext
+{
+
+ Registration registration;
+
+ public Object include(
+ ServletContext targetServletContext,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ RequestDispatchCallback callback,
+ Object handback) throws ServletException, IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setCallback(Registration registration)
+ {
+ this.registration = registration;
+ }
+
+ public void unsetCallback(Registration registration)
+ {
+ this.registration = null;
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerTestCase.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerTestCase.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/ServletContainerTestCase.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,276 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.container;
+
+import junit.framework.TestCase;
+import org.jboss.portal.web.ServletContainer;
+import org.jboss.portal.web.WebAppListener;
+import org.jboss.portal.web.WebAppEvent;
+import org.jboss.portal.web.spi.ServletContainerContext;
+import org.jboss.portal.common.util.CollectionBuilder;
+import org.jboss.portal.test.web.WebAppRegistry;
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServletContainerTestCase extends TestCase
+{
+
+ public void testContextRegistrationLifeCycle()
+ {
+ ServletContainer container = new ServletContainer();
+ ServletContainerContextImpl scc = new ServletContainerContextImpl();
+
+ //
+ container.register(scc);
+
+ // Assert we got registration
+ assertNotNull(scc.registration);
+
+ // Keep a ref on registration
+ ServletContainerContext.Registration registration = scc.registration;
+
+ // Cancel registration
+ scc.registration.cancel();
+
+ // Assert we don't have registration anymore
+ assertNull(scc.registration);
+
+ // Test registration object is invalid
+ try
+ {
+ registration.registerWebApp(new WebAppContextImpl("/foo"));
+ fail("Was expecting an ISE");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ try
+ {
+ registration.unregisterWebApp("/blah");
+ fail("Was expecting an ISE");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ try
+ {
+ registration.cancel();
+ fail("Was expecting an ISE");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testConcurrentContextRegistrations()
+ {
+ ServletContainer container = new ServletContainer();
+ ServletContainerContextImpl scc1 = new ServletContainerContextImpl();
+ ServletContainerContextImpl scc2 = new ServletContainerContextImpl();
+
+ // We register
+ container.register(scc1);
+
+ // Registration was done
+ assertNotNull(scc1.registration);
+
+ // Try register
+ container.register(scc2);
+
+ // Registration failed
+ assertNull(scc2.registration);
+
+ // Cancel
+ scc1.registration.cancel();
+
+ // Try register again
+ container.register(scc2);
+
+ // Registration should have worked now
+ assertNotNull(scc2.registration);
+ }
+
+ public void testContextRegistrationCancellationUnregistersWebApps()
+ {
+ ServletContainer container = new ServletContainer();
+ ServletContainerContextImpl scc = new ServletContainerContextImpl();
+ WebAppRegistry registry = new WebAppRegistry();
+
+ //
+ container.register(scc);
+
+ //
+ container.addWebAppListener(registry);
+
+ //
+ scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
+ scc.registration.registerWebApp(new WebAppContextImpl("/bar"));
+ assertEquals(new
CollectionBuilder().add("/foo").add("/bar").toHashSet(),
registry.getKeys());
+
+ //
+ scc.registration.cancel();
+ assertEquals(new CollectionBuilder().toHashSet(), registry.getKeys());
+ }
+
+ public void testListenerDoubleRegistration()
+ {
+ ServletContainer container = new ServletContainer();
+ ServletContainerContextImpl scc = new ServletContainerContextImpl();
+ WebAppRegistry registry = new WebAppRegistry();
+
+ //
+ container.addWebAppListener(registry);
+ container.addWebAppListener(registry);
+
+ //
+ container.register(scc);
+ scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
+ assertEquals(new CollectionBuilder().add("/foo").toHashSet(),
registry.getKeys());
+
+ //
+ container.addWebAppListener(registry);
+ assertEquals(new CollectionBuilder().add("/foo").toHashSet(),
registry.getKeys());
+
+ //
+ container.removeWebAppListener(registry);
+ assertEquals(new CollectionBuilder().toHashSet(), registry.getKeys());
+
+ //
+ container.removeWebAppListener(registry);
+ assertEquals(new CollectionBuilder().toHashSet(), registry.getKeys());
+ }
+
+ public void testListenerIsNotified()
+ {
+ ServletContainer container = new ServletContainer();
+ ServletContainerContextImpl scc = new ServletContainerContextImpl();
+ WebAppRegistry registry = new WebAppRegistry();
+
+ //
+ container.register(scc);
+
+ // Add 2 web apps
+ scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
+ scc.registration.registerWebApp(new WebAppContextImpl("/bar"));
+
+ // Add listener
+ container.addWebAppListener(registry);
+
+ // Assert we received events during the registration
+ assertEquals(new
CollectionBuilder().add("/foo").add("/bar").toHashSet(),
registry.getKeys());
+
+ // Add a new web app
+ scc.registration.registerWebApp(new WebAppContextImpl("/juu"));
+
+ // Assert we now have 3 web apps
+ assertEquals(new
CollectionBuilder().add("/foo").add("/bar").add("/juu").toHashSet(),
registry.getKeys());
+
+ // Remove one web app
+ scc.registration.unregisterWebApp("/foo");
+
+ // Assert we have 2 web apps
+ assertEquals(new
CollectionBuilder().add("/bar").add("/juu").toHashSet(),
registry.getKeys());
+
+ // Remove registration
+ container.removeWebAppListener(registry);
+
+ // Assert we receveived events during removal
+ assertEquals(new CollectionBuilder().toHashSet(), registry.getKeys());
+
+ // W Add a new web app
+ scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
+
+ // hen unregistered, a new web app registration does not send event
+ assertEquals(new CollectionBuilder().toHashSet(), registry.getKeys());
+ }
+
+ public void testServletContainerThrowsIAE()
+ {
+ ServletContainer container = new ServletContainer();
+ try
+ {
+ container.register(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ container.addWebAppListener(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ container.removeWebAppListener(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testServletContainerThrowsISE() throws Exception
+ {
+ ServletContainer container = new ServletContainer();
+ try
+ {
+ container.include(null, null, null, null, null);
+ fail("Was expecting an ISE");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+
+ public void testListenerFailure()
+ {
+ ServletContainer container = new ServletContainer();
+ ServletContainerContextImpl scc = new ServletContainerContextImpl();
+ WebAppRegistry registry = new WebAppRegistry();
+
+ //
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ container.register(scc);
+ container.addWebAppListener(registry);
+ container.addWebAppListener(new WebAppListener()
+ {
+ public void onEvent(WebAppEvent event)
+ {
+ called.set(true);
+ throw new RuntimeException("Expected : don't freak out");
+ }
+ });
+
+ //
+ scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
+ assertTrue(called.get());
+ assertEquals(new CollectionBuilder().add("/foo").toHashSet(),
registry.getKeys());
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/WebAppContextImpl.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/WebAppContextImpl.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/container/WebAppContextImpl.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.container;
+
+import org.jboss.portal.web.spi.WebAppContext;
+
+import javax.servlet.ServletContext;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebAppContextImpl implements WebAppContext
+{
+
+ /** . */
+ private final String contextPath;
+
+ /** . */
+ boolean started;
+
+ public WebAppContextImpl(String contextPath)
+ {
+ this.contextPath = contextPath;
+ this.started = false;
+ }
+
+ public void start() throws Exception
+ {
+ this.started = true;
+ }
+
+ public void stop()
+ {
+ this.started = false;
+ }
+
+ public ServletContext getServletContext()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ public boolean importFile(String parentDirRelativePath, String name, InputStream
source, boolean overwrite) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestCase.java
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestCase.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestCase.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,145 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.spi;
+
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import org.jboss.portal.test.framework.mc.TestRuntimeContext;
+import org.jboss.portal.test.framework.deployment.Deployer;
+import org.jboss.portal.test.framework.server.NodeManager;
+import org.jboss.portal.test.framework.driver.TestDriver;
+import org.jboss.portal.test.framework.junit.JUnitAdapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SPITestCase extends TestCase
+{
+
+ /** The deployer. */
+ private Deployer deployer;
+
+ /** The node manager. */
+ private NodeManager nodeManager;
+
+ /** . */
+ private TestRuntimeContext runtimeContext;
+
+ /** . */
+ private TestDriver testDriver;
+
+ /** . */
+ private JUnitAdapter adapter;
+
+ public Deployer getDeployer()
+ {
+ return deployer;
+ }
+
+ public void setDeployer(Deployer deployer)
+ {
+ this.deployer = deployer;
+ }
+
+ public NodeManager getNodeManager()
+ {
+ return nodeManager;
+ }
+
+ public void setNodeManager(NodeManager nodeManager)
+ {
+ this.nodeManager = nodeManager;
+ }
+
+ public TestDriver getTestDriver()
+ {
+ return testDriver;
+ }
+
+ public void setTestDriver(TestDriver testDriver)
+ {
+ this.testDriver = testDriver;
+ }
+
+ public JUnitAdapter getAdapter()
+ {
+ return adapter;
+ }
+
+ public void setAdapter(JUnitAdapter adapter)
+ {
+ this.adapter = adapter;
+ }
+
+ public void run(TestResult testResult)
+ {
+ try
+ {
+ runtimeContext = new
TestRuntimeContext("org/jboss/portal/test/web/spi/client-beans.xml");
+ runtimeContext.addBean("This", this);
+ runtimeContext.addBean("Config", new SPITestConfig());
+ runtimeContext.start();
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ this.e = e;
+
+ //
+ super.run(testResult);
+ }
+ catch (Exception e1)
+ {
+ this.e = null;
+ }
+
+ //
+ return;
+ }
+
+ //
+ try
+ {
+ adapter.run(testResult);
+ }
+ finally
+ {
+ runtimeContext.stop();
+ }
+ }
+
+ /** . */
+ private Exception e;
+
+ public void runBare() throws Throwable
+ {
+ throw e;
+ }
+
+ public void testDummy()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestConfig.java
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestConfig.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestConfig.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.spi;
+
+import org.jboss.portal.test.framework.TestParametrization;
+import org.jboss.portal.test.framework.TestParameterValue;
+import org.jboss.portal.test.framework.junit.JUnitAdapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SPITestConfig
+{
+
+ public String getArchivePath()
+ {
+ return System.getProperty("test.root");
+ }
+
+ /**
+ * Returns the server name from the test parametrization. If no value is found then
it
+ * returns the litteral string <i>RemoteTomcat-6.0</i>.
+ *
+ * @return the server name
+ */
+ public String getServerName()
+ {
+ TestParametrization parametrization = JUnitAdapter.getParametrization();
+ TestParameterValue archive =
parametrization.getParameterValue("serverName");
+
+ //
+ if (archive != null)
+ {
+ return (String)archive.get();
+ }
+ else
+ {
+ return "RemoteTomcat-6.0";
+ }
+ }
+}
Added: modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestServlet.java
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestServlet.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/SPITestServlet.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,235 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.spi;
+
+import org.jboss.portal.test.framework.driver.TestDriverContainer;
+import org.jboss.portal.test.framework.driver.DriverResponse;
+import org.jboss.portal.test.framework.driver.DriverCommand;
+import org.jboss.portal.test.framework.driver.TestDriverException;
+import org.jboss.portal.test.framework.driver.http.response.InvokeGetResponse;
+import org.jboss.portal.test.framework.driver.remote.RemoteTestDriver;
+import org.jboss.portal.test.framework.driver.remote.TestContext;
+import org.jboss.portal.test.framework.driver.remote.response.DeployResponse;
+import org.jboss.portal.test.framework.driver.remote.response.UndeployResponse;
+import org.jboss.portal.test.framework.driver.response.EndTestResponse;
+import org.jboss.portal.test.framework.driver.response.FailureResponse;
+import org.jboss.portal.test.framework.info.TestItemInfo;
+import org.jboss.portal.test.framework.info.TestInfo;
+import org.jboss.portal.test.web.WebAppRegistry;
+import org.jboss.portal.test.web.spi.callbacks.NormalCallback;
+import org.jboss.portal.test.web.spi.callbacks.ExceptionCallback;
+import org.jboss.portal.web.ServletContainer;
+import org.jboss.portal.web.WebApp;
+import org.jboss.portal.web.ServletContextDispatcher;
+import org.jboss.portal.web.impl.DefaultServletContainerFactory;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SPITestServlet extends HttpServlet implements RemoteTestDriver
+{
+
+ /** . */
+ private TestInfo info = new TestInfo("Main");
+
+ /** . */
+ private WebAppRegistry registry;
+
+ /** . */
+ private Set keys;
+
+ /** . */
+ private ServletContainer container;
+
+ public void init() throws ServletException
+ {
+ TestDriverContainer driver =
(TestDriverContainer)getServletContext().getAttribute("TestDriverServer");
+ driver.addDriver(this);
+ }
+
+ private TestContext testContext;
+
+ public void pushContext(String testId, TestContext testContext)
+ {
+ this.testContext = testContext;
+ }
+
+ public TestContext popContext(String string)
+ {
+ return testContext;
+ }
+
+ public void destroy()
+ {
+ TestDriverContainer driver =
(TestDriverContainer)getServletContext().getAttribute("TestDriverServer");
+ driver.removeDriver(this);
+ }
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ DriverResponse response = service2(req, resp);
+ testContext.setResponse(response);
+ resp.setStatus(200);
+ }
+
+ private DriverResponse service2(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
+ {
+
+ //
+ if (testContext.isRequestCount(1))
+ {
+ // Should try
+ ServletContext appContext =
getServletContext().getContext("/test-spi-app");
+
+ //
+ if (appContext == null)
+ {
+ return new FailureResponse("Cannot get access to the /test-spi-app
servlet context");
+ }
+
+ //
+ WebApp webApp = registry.getWebApp("/test-spi-app");
+ NormalCallback cb1 = new NormalCallback(appContext, webApp.getClassLoader());
+ Exception ex = new Exception();
+ ExceptionCallback cb2 = new ExceptionCallback(appContext, ex, ex);
+ Error err = new Error();
+ ExceptionCallback cb3 = new ExceptionCallback(appContext, err, err);
+ RuntimeException rex = new RuntimeException();
+ ExceptionCallback cb4 = new ExceptionCallback(appContext, rex, rex);
+ IOException ioe = new IOException();
+ ExceptionCallback cb5 = new ExceptionCallback(appContext, ioe, ioe);
+
+ //
+ ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp,
container);
+ DriverResponse response = cb1.test(null, dispatcher);
+ response = cb2.test(response, dispatcher);
+ response = cb3.test(response, dispatcher);
+ response = cb4.test(response, dispatcher);
+ response = cb5.test(response, dispatcher);
+
+ //
+ if (response != null)
+ {
+ return response;
+ }
+
+ // Now we undeploy
+ return new UndeployResponse("test-spi-app.war");
+ }
+ else if (testContext.isRequestCount(2))
+ {
+ if (!keys.equals(registry.getKeys()))
+ {
+ return new FailureResponse("The set of deployed web applications "
+ registry.getKeys() + " is not equals to the expected set " +
+ keys);
+ }
+
+ // Remove registration
+ container.removeWebAppListener(registry);
+
+ //
+ if (registry.getKeys().size() > 0)
+ {
+ return new FailureResponse("The set of deployed web application should
be empty instead of " + registry.getKeys());
+ }
+ else
+ {
+ return new EndTestResponse();
+ }
+ }
+
+ //
+ return new FailureResponse();
+ }
+
+ public TestItemInfo getInfo()
+ {
+ return info;
+ }
+
+ public DriverResponse invoke(String string, DriverCommand driverCommand) throws
TestDriverException
+ {
+ if (testContext.isRequestCount(-1))
+ {
+ container = DefaultServletContainerFactory.getInstance().getServletContainer();
+ if (container == null)
+ {
+ return new FailureResponse("No servlet container present");
+ }
+
+ // Register and save the deployed web apps
+ registry = new WebAppRegistry();
+ container.addWebAppListener(registry);
+ keys = new HashSet(registry.getKeys());
+
+ // Deploy the application web app
+ return new DeployResponse("test-spi-app.war");
+ }
+ else if (testContext.isRequestCount(0))
+ {
+ // Compute the difference with the previous deployed web apps
+ Set diff = new HashSet(registry.getKeys());
+ diff.removeAll(keys);
+
+ // It should be 1
+ if (diff.size() != 1)
+ {
+ return new FailureResponse("The size of the new web application deployed
should be 1, it is " + diff.size() + " instead." +
+ "The previous set was " + keys + " and the new set is " +
registry.getKeys());
+ }
+ String key = (String)diff.iterator().next();
+ if (!"/test-spi-app".equals(key))
+ {
+ return new FailureResponse("The newly deployed web application should be
/test-spi-war and it is " + key);
+ }
+
+ //
+ WebApp webApp = registry.getWebApp("/test-spi-app");
+ if (webApp == null)
+ {
+ return new FailureResponse("The web app /test-spi-app was not
found");
+ }
+ if (!"/test-spi-app".equals(webApp.getContextPath()))
+ {
+ return new FailureResponse("The web app context is not equals to the
expected value but has the value " + webApp.getContextPath());
+ }
+
+ //
+ return new InvokeGetResponse("/test-spi-server");
+ }
+ else
+ {
+ return new FailureResponse();
+ }
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/AbstractCallback.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/AbstractCallback.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/AbstractCallback.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.spi.callbacks;
+
+import org.jboss.portal.test.framework.driver.DriverResponse;
+import org.jboss.portal.web.RequestDispatchCallback;
+import org.jboss.portal.web.ServletContextDispatcher;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractCallback implements RequestDispatchCallback
+{
+
+ public DriverResponse test(DriverResponse response, ServletContextDispatcher
dispatcher)
+ {
+ if (response != null)
+ {
+ return response;
+ }
+
+ //
+ return test(dispatcher);
+ }
+
+ protected abstract DriverResponse test(ServletContextDispatcher dispatcher);
+
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/ExceptionCallback.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/ExceptionCallback.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/ExceptionCallback.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.spi.callbacks;
+
+import org.jboss.portal.test.framework.driver.DriverResponse;
+import org.jboss.portal.test.framework.driver.response.FailureResponse;
+import org.jboss.portal.web.ServletContextDispatcher;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExceptionCallback extends AbstractCallback
+{
+
+ /** . */
+ private final ServletContext target;
+
+ /** . */
+ private final Throwable expectedThrowable;
+
+ /** . */
+ private final Throwable throwable;
+
+ public ExceptionCallback(ServletContext target, Throwable expectedThrowable, Throwable
throwable)
+ {
+ this.target = target;
+ this.expectedThrowable = expectedThrowable;
+ this.throwable = throwable;
+ }
+
+ protected DriverResponse test(ServletContextDispatcher dispatcher)
+ {
+ try
+ {
+ dispatcher.include(target, this, null);
+
+ //
+ return new FailureResponse("Got no throwable thrown was expecting " +
expectedThrowable);
+ }
+ catch (Throwable throwable)
+ {
+ if (throwable instanceof ServletException)
+ {
+ throwable = throwable.getCause();
+ }
+ if (expectedThrowable != throwable)
+ {
+ return new FailureResponse("Got throwable " + throwable + "
instead of throwable " + expectedThrowable);
+ }
+ }
+
+ //
+ return null;
+ }
+
+ public Object doCallback(ServletContext dispatchedServletContext, HttpServletRequest
dispatchedRequest, HttpServletResponse dispatchedResponse, Object handback) throws
ServletException, IOException
+ {
+ if (throwable instanceof IOException)
+ {
+ throw (IOException)throwable;
+ }
+ if (throwable instanceof Exception)
+ {
+ throw new ServletException(throwable);
+ }
+ else if (throwable instanceof Error)
+ {
+ throw (Error)throwable;
+ }
+ return null;
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/NormalCallback.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/NormalCallback.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/test/web/spi/callbacks/NormalCallback.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,117 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.spi.callbacks;
+
+import org.jboss.portal.web.ServletContextDispatcher;
+import org.jboss.portal.test.framework.driver.DriverResponse;
+import org.jboss.portal.test.framework.driver.response.FailureResponse;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NormalCallback extends AbstractCallback
+{
+
+ /** . */
+ private final ServletContext expectedContext;
+
+ /** . */
+ private final ClassLoader expectedThreadContextClassLoader;
+
+ /** . */
+ private final Object expectedHandback;
+
+ /** . */
+ private final Object expectedReturnedValue;
+
+ /** . */
+ private Object handback;
+
+ /** . */
+ private ClassLoader threadContextClassLoader;
+
+ /** . */
+ private boolean invoked;
+
+ public NormalCallback(ServletContext expectedContext, ClassLoader
expectedThreadContextClassLoader)
+ {
+ this.expectedContext = expectedContext;
+ this.expectedThreadContextClassLoader = expectedThreadContextClassLoader;
+ this.expectedHandback = new Object();
+ this.expectedReturnedValue = new Object();
+
+ //
+ this.invoked = false;
+ this.handback = null;
+ }
+
+ public Object doCallback(ServletContext dispatchedServletContext, HttpServletRequest
dispatchedRequest, HttpServletResponse dispatchedResponse, Object handback) throws
ServletException, IOException
+ {
+ this.invoked = true;
+ this.threadContextClassLoader = Thread.currentThread().getContextClassLoader();
+ this.handback = handback;
+
+ //
+ return expectedReturnedValue;
+ }
+
+ protected DriverResponse test(ServletContextDispatcher dispatcher)
+ {
+ try
+ {
+ Object returnedValue = dispatcher.include(expectedContext, this,
expectedHandback);
+
+ //
+ if (!invoked)
+ {
+ return new FailureResponse("The callback was not invoked");
+ }
+ if (expectedHandback != handback)
+ {
+ return new FailureResponse("The provided handback is not the same than
the expected handback");
+ }
+ if (expectedReturnedValue != returnedValue)
+ {
+ return new FailureResponse("The returned value is not the same than the
expected one");
+ }
+ if (expectedThreadContextClassLoader != threadContextClassLoader)
+ {
+ return new FailureResponse("The thread context class loader is not the
same than the expected one");
+ }
+ }
+ catch (Exception e)
+ {
+ return new FailureResponse(e);
+ }
+
+ //
+ return null;
+ }
+}
Modified:
modules/web/trunk/web/src/main/org/jboss/portal/web/RequestDispatchCallback.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/RequestDispatchCallback.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/RequestDispatchCallback.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -25,6 +25,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import java.io.IOException;
/**
* Callback contract.
@@ -35,17 +37,18 @@
public interface RequestDispatchCallback
{
/**
- * Called by the runtime context when request dispatching has been done.
+ * Performs the request dispatch logic.
*
* @param dispatchedServletContext the dispatched servlet context
* @param dispatchedRequest the dispatched request
* @param dispatchedResponse the dispatched response
* @param handback the handback object provided to the dispatched @return any object
- * @throws Exception any exception
+ * @throws ServletException if an exception occurs that interferes with the normal
operation
+ * @throws IOException if an input or output exception occurs
*/
Object doCallback(
ServletContext dispatchedServletContext,
HttpServletRequest dispatchedRequest,
HttpServletResponse dispatchedResponse,
- Object handback) throws Exception;
+ Object handback) throws ServletException, IOException;
}
Modified: modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainer.java
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainer.java 2007-09-10
23:03:20 UTC (rev 8207)
+++ modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainer.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -23,7 +23,19 @@
package org.jboss.portal.web;
import org.jboss.portal.web.spi.ServletContainerContext;
+import org.jboss.portal.web.spi.WebAppContext;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.InputStream;
+import java.io.IOException;
+
/**
* A static registry for the servlet container context.
*
@@ -34,40 +46,303 @@
{
/** . */
- private static ServletContainerContext _context;
+ private final Object lock = new Object();
+ /** The event listeners. */
+ private final ArrayList listeners = new ArrayList();
+
+ /** The web applications. */
+ private final Map webAppMap = new HashMap();
+
+ /** The callback. */
+ private RegistrationImpl registration;
+
/**
* Register a servlet container context. The registration is considered as successful
if no existing context
* is already registered.
*
* @param context the servlet container context to register
- * @return true if the registration is successful
* @throws IllegalArgumentException if the context is null
*/
- public synchronized static boolean registerContext(ServletContainerContext context)
throws IllegalArgumentException
+ public void register(ServletContainerContext context)
{
- if (context == null)
+ synchronized(lock)
{
- throw new IllegalArgumentException("No null context accepted");
+ if (context == null)
+ {
+ throw new IllegalArgumentException("No null context accepted");
+ }
+
+ //
+ if (registration == null)
+ {
+
+ registration = new RegistrationImpl(this, context);
+
+ // Installs the call back
+ context.setCallback(registration);
+ }
}
- if (_context == null)
+ }
+
+ public boolean addWebAppListener(WebAppListener listener)
+ {
+ synchronized(lock)
{
- _context = context;
+ if (listener == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (listeners.contains(listener))
+ {
+ return false;
+ }
+ listeners.add(listener);
+ for (Iterator i = webAppMap.values().iterator(); i.hasNext();)
+ {
+ WebApp webApp = (WebApp)i.next();
+ WebAppLifeCycleEvent event = new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.ADDED);
+ safeFireEvent(listener, event);
+ }
return true;
}
- else
+ }
+
+ public boolean removeWebAppListener(WebAppListener listener)
+ {
+ synchronized(lock)
{
- return false;
+ if (listener == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (listeners.remove(listener))
+ {
+ for (Iterator i = webAppMap.values().iterator(); i.hasNext();)
+ {
+ WebApp webApp = (WebApp)i.next();
+ WebAppLifeCycleEvent event = new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED);
+ safeFireEvent(listener, event);
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
}
+ private void safeFireEvent(WebAppListener listener, WebAppEvent event)
+ {
+ try
+ {
+ listener.onEvent(event);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void fireEvent(WebAppEvent event)
+ {
+ for (Iterator i = listeners.iterator();i.hasNext();)
+ {
+ safeFireEvent((WebAppListener)i.next(), event);
+ }
+ }
+
/**
- * Returns the existing servlet container context or null if none is registered.
+ * Generic detyped request dispatch to a servlet context using the include mechanism.
*
- * @return the registered servlet container context
+ * @param targetServletContext the target servlet context to dispatch to
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ * @param callback the callback to perform after the dispatch operation
+ * @param handback the handback object to provide
+ * @return any object
+ * @throws Exception any exception
*/
- public synchronized static ServletContainerContext getContext()
+ public Object include(
+ ServletContext targetServletContext, HttpServletRequest request,
+ HttpServletResponse response,
+ RequestDispatchCallback callback,
+ Object handback) throws ServletException, IOException
{
- return _context;
+ RegistrationImpl registration = this.registration;
+
+ //
+ if (registration == null)
+ {
+ throw new IllegalStateException("No SPI installed");
+ }
+
+ //
+ return registration.context.include(targetServletContext, request, response,
callback, handback);
}
+
+ private static class RegistrationImpl implements ServletContainerContext.Registration
+ {
+
+ /** . */
+ private boolean disposed;
+
+ /** . */
+ private ServletContainer container;
+
+ /** . */
+ private ServletContainerContext context;
+
+ public RegistrationImpl(ServletContainer container, ServletContainerContext
context)
+ {
+ this.disposed = false;
+ this.container = container;
+ this.context = context;
+ }
+
+ public boolean registerWebApp(WebAppContext webAppContext)
+ {
+ if (disposed)
+ {
+ throw new IllegalStateException("Disposed registration");
+ }
+ synchronized(container.lock)
+ {
+ if (webAppContext == null)
+ {
+ throw new IllegalArgumentException("No null web app context
accepted");
+ }
+
+ //
+ String key = webAppContext.getContextPath();
+
+ //
+ if (container.webAppMap.containsKey(key))
+ {
+ System.out.println("Web application " + key + " is already
registered");
+ return false;
+ }
+ else
+ {
+ try
+ {
+ System.out.println("Web application " + key + "
registration");
+ webAppContext.start();
+ WebAppImpl webApp = new WebAppImpl(webAppContext);
+ container.webAppMap.put(key, webApp);
+ container.fireEvent(new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.ADDED));
+ return true;
+ }
+ catch (Exception e)
+ {
+ System.out.println("Was not able to start web app context "+
key);
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }
+ }
+
+ public boolean unregisterWebApp(String webAppId)
+ {
+ if (disposed)
+ {
+ throw new IllegalStateException("Disposed registration");
+ }
+ synchronized(container.lock)
+ {
+ if (webAppId == null)
+ {
+ throw new IllegalArgumentException("No null web app id
accepted");
+ }
+
+ //
+ WebAppImpl webApp = (WebAppImpl)container.webAppMap.remove(webAppId);
+ if (webApp != null)
+ {
+ System.out.println("Web application " + webAppId + "
cleanup");
+ container.fireEvent(new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED));
+ webApp.context.stop();
+ return true;
+ }
+ else
+ {
+ System.out.println("Web application " + webAppId + " was
not registered");
+ return false;
+ }
+ }
+ }
+
+ public void cancel()
+ {
+ if (disposed)
+ {
+ throw new IllegalStateException("Disposed registration");
+ }
+ synchronized(container.lock)
+ {
+ // Unregister all web apps
+ for (Iterator i = container.webAppMap.values().iterator(); i.hasNext();)
+ {
+ WebApp webApp = (WebApp)i.next();
+ WebAppLifeCycleEvent event = new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED);
+ container.fireEvent(event);
+ }
+
+ //
+ container.webAppMap.clear();
+
+ // Uninstall the call back
+ try
+ {
+ context.unsetCallback(this);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ // Update state
+ context = null;
+ disposed = true;
+ container.registration = null;
+ }
+ }
+ }
+
+ /**
+ * Implementation of the <code>WebApp</code> interface.
+ */
+ private static class WebAppImpl implements WebApp
+ {
+
+ /** . */
+ final WebAppContext context;
+
+ public WebAppImpl(WebAppContext context)
+ {
+ this.context = context;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return context.getServletContext();
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return context.getClassLoader();
+ }
+
+ public String getContextPath()
+ {
+ return context.getContextPath();
+ }
+
+ public boolean importFile(String parentDirRelativePath, String name, InputStream
source, boolean overwrite) throws IOException
+ {
+ return context.importFile(parentDirRelativePath, name, source, overwrite);
+ }
+ }
}
Added: modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainerFactory.java
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainerFactory.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContainerFactory.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web;
+
+/**
+ * It's rather a provider rather than a real factory. But I prefer the factory name
than the provider name.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ServletContainerFactory
+{
+
+ /**
+ * Returns the servlet container.
+ *
+ * @return
+ */
+ ServletContainer getServletContainer();
+
+}
Modified:
modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContextDispatcher.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContextDispatcher.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/ServletContextDispatcher.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -22,14 +22,14 @@
******************************************************************************/
package org.jboss.portal.web;
-import org.jboss.portal.web.spi.ServletContainerContext;
-
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
/**
- * Encapsulate dispatching functionnality into a single class so it is easy to
+ * Encapsulate dispatch functionnality into a single class so it is easy to
* pass it as an argment to a framework that neeeds a dispatcher to just a
* servlet context and does not care about the underlying spi or request/response.
*
@@ -46,13 +46,13 @@
private final HttpServletResponse response;
/** . */
- private final ServletContainerContext containerContext;
+ private final ServletContainer servletContainer;
- public ServletContextDispatcher(HttpServletRequest request, HttpServletResponse
response, ServletContainerContext containerContext)
+ public ServletContextDispatcher(HttpServletRequest request, HttpServletResponse
response, ServletContainer servletContainer)
{
this.request = request;
this.response = response;
- this.containerContext = containerContext;
+ this.servletContainer = servletContainer;
}
public HttpServletRequest getRequest()
@@ -68,9 +68,9 @@
public Object include(
ServletContext targetServletContext,
RequestDispatchCallback callback,
- Object handback) throws Exception
+ Object handback) throws ServletException, IOException
{
- return containerContext.include(targetServletContext, request, response, callback,
handback);
+ return servletContainer.include(targetServletContext, request, response, callback,
handback);
}
}
Modified: modules/web/trunk/web/src/main/org/jboss/portal/web/WebApp.java
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/web/WebApp.java 2007-09-10 23:03:20
UTC (rev 8207)
+++ modules/web/trunk/web/src/main/org/jboss/portal/web/WebApp.java 2007-09-10 23:06:44
UTC (rev 8208)
@@ -44,13 +44,6 @@
ServletContext getServletContext();
/**
- * Returns an identifier for the web application valid in the scope of all the web
applications deployed.
- *
- * @return the web application identifier
- */
- String getId();
-
- /**
* Returns the class loader of the web application.
*
* @return the web application class loader
Modified: modules/web/trunk/web/src/main/org/jboss/portal/web/WebAppLifeCycleEvent.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/WebAppLifeCycleEvent.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/WebAppLifeCycleEvent.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -23,6 +23,8 @@
package org.jboss.portal.web;
/**
+ * Web application life cycle event.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
Modified:
modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandDispatcher.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandDispatcher.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandDispatcher.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -37,72 +37,20 @@
public class CommandDispatcher
{
- /** . */
- private static final ThreadLocal localResponse = new ThreadLocal();
-
public Object include(
ServletContext targetServletContext,
HttpServletRequest req,
HttpServletResponse resp,
RequestDispatchCallback callback,
- Object handback) throws Exception
+ Object handback) throws ServletException, IOException
{
- try
- {
- //
- ServletCommand cmd = new InvokeNextCommand(targetServletContext, callback,
handback);
+ CallbackCommand cmd = new CallbackCommand(targetServletContext, callback,
handback);
- //
- CommandServlet.include(req, resp, cmd, targetServletContext);
-
- // Rethrow any InvocationException
- Object response = localResponse.get();
-
- //
- if (response instanceof Exception)
- {
- throw (Exception)response;
- }
- else
- {
- return response;
- }
- }
- catch (IOException e)
- {
- throw e;
- }
- catch (ServletException e)
- {
- // Unwrap underlying exception if any
- Throwable t = e.getRootCause();
-
- //
- if (t instanceof Error)
- {
- // Rethrow any error
- throw(Error)t;
- }
- else if (t instanceof RuntimeException)
- {
- throw (RuntimeException)t;
- }
- else if (t instanceof Exception)
- {
- throw (Exception)t;
- }
- else
- {
- throw e;
- }
- }
- finally
- {
- localResponse.set(null);
- }
+ //
+ return CommandServlet.include(req, resp, cmd, targetServletContext);
}
- public static class InvokeNextCommand implements ServletCommand
+ public static class CallbackCommand
{
/** . */
@@ -114,26 +62,16 @@
/** . */
private final Object handback;
- public InvokeNextCommand(ServletContext servletContext, RequestDispatchCallback
invocation, Object handback)
+ public CallbackCommand(ServletContext servletContext, RequestDispatchCallback
invocation, Object handback)
{
this.servletContext = servletContext;
this.invocation = invocation;
this.handback = handback;
}
- public void execute(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ public Object execute(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
{
- try
- {
- Object response = invocation.doCallback(servletContext, req, resp,
handback);
-
- //
- localResponse.set(response);
- }
- catch (Exception e)
- {
- localResponse.set(e);
- }
+ return invocation.doCallback(servletContext, req, resp, handback);
}
}
}
Modified: modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandServlet.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandServlet.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/command/CommandServlet.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -34,8 +34,7 @@
/**
* This servlet is used to execute command coming from another context through a
dispatching request.
- * <p/>
- * The command invocation is detyped to allow it working on redeploy and avoid class cast
exception.
+ * The invocation is detyped in order to allow redeployment and avoid class cast
exception.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -44,40 +43,80 @@
{
/** . */
-// private static final Logger log = Logger.getLogger(CommandServlet.class);
+ private static final ThreadLocal localCmd = new ThreadLocal();
/** . */
- private static final ThreadLocal localCmd = new ThreadLocal();
+ private static final ThreadLocal localResponse = new ThreadLocal();
+ /** . */
+ private static final ThreadLocal localThrowable = new ThreadLocal();
+
/**
- * Execute a command after having performed a request dispatch in the target servlet
context.
+ * <p>Execute a command after having performed a request dispatch in the target
servlet context.</p>
*
- * @param cmd the command to execute after the inclusion is done
- * @param ctx the target servlet context
- * @throws IOException
- * @throws ServletException
+ * <p>The provided callback argment must expose a public non static and non
abstract method
+ * with the signature
<code>execute(HttpServletRequest,HttpServletResponse)</code>.
+ * This method must return an object and can declare any exception. This method will
be invoked
+ * after the request dispatch operation is done.</p>
+ *
+ * <p>Any throwable thrown by the callback invocation will be wrapped in a
<code>ServletException</code>
+ * and rethrown, unless it is an instance of <code>ServletException</code>
or <code>IOException</code>.</p>
+ *
+ * @param callback the callback to invoke after the inclusion is done
+ * @param targetContext the target servlet context
+ * @throws IOException likely thrown by the request dispatch operation
+ * @throws ServletException wraps any exception thrown by the callback
*/
- public static void include(
- HttpServletRequest req,
- HttpServletResponse resp,
- ServletCommand cmd,
- ServletContext ctx) throws IOException, ServletException
+ public static Object include(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ Object callback,
+ ServletContext targetContext) throws ServletException, IOException
{
try
{
- localCmd.set(cmd);
- RequestDispatcher switcher =
ctx.getRequestDispatcher("/jbossportlet");
- switcher.include(req, resp);
+ localCmd.set(callback);
+ RequestDispatcher switcher =
targetContext.getRequestDispatcher("/jbossportlet");
+ switcher.include(request, response);
+
+ //
+ Throwable throwable = (Throwable)localThrowable.get();
+
+ //
+ if (throwable != null)
+ {
+ if (throwable instanceof IOException)
+ {
+ throw (IOException)throwable;
+ }
+ else if (throwable instanceof ServletException)
+ {
+ throw (ServletException)throwable;
+ }
+ else
+ {
+ ServletException se = new ServletException();
+ se.initCause(throwable);
+ throw se;
+ }
+ }
+
+ //
+ return localResponse.get();
}
finally
{
localCmd.set(null);
+ localResponse.set(null);
+ localThrowable.set(null);
}
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
{
Object cmd = localCmd.get();
+
+ //
if (cmd != null)
{
try
@@ -87,58 +126,34 @@
new Class[]{
HttpServletRequest.class,
HttpServletResponse.class});
- methods.invoke(cmd, new Object[]{req, resp});
+
+ //
+ Object response = methods.invoke(cmd, new Object[]{req, resp});
+
+ //
+ localResponse.set(response);
}
catch (NoSuchMethodException e)
{
- throw new ServletException("No execute method found on the
command", e);
+ throw new Error("No execute method found on the command", e);
}
catch (InvocationTargetException e)
{
// Log the wrappee
Throwable wrappee = e.getTargetException();
- // log.error("Exception in command invocation", wrappee);
- // Rethrow the checked ServletException
- if (wrappee instanceof ServletException)
- {
- ServletException se = (ServletException)wrappee;
- if (se.getCause() == null && se.getRootCause() != null)
- {
- se.initCause(se.getRootCause());
- }
- throw(ServletException)wrappee;
- }
- // Rethrow the checked IOException
- if (wrappee instanceof IOException)
- {
- throw(IOException)wrappee;
- }
- // Rethrow RuntimeException
- if (wrappee instanceof RuntimeException)
- {
- throw(RuntimeException)wrappee;
- }
- // Rethrow Error
- if (wrappee instanceof Error)
- {
- throw(Error)wrappee;
- }
// Here we wrap it and rethrow
- ServletException se = new ServletException("The invoked command threw an
exception", wrappee);
- se.initCause(wrappee);
- throw se;
+ localThrowable.set(wrappee);
}
catch (IllegalAccessException e)
{
- ServletException se = new ServletException("Unexpected
IllegalAccessException during command invocation", e);
- se.initCause(e);
- throw se;
+ throw new Error("Unexpected IllegalAccessException during command
invocation", e);
}
}
else
{
- throw new ServletException("No command found");
+ // That should not happen
+ throw new Error("No command found");
}
}
Deleted: modules/web/trunk/web/src/main/org/jboss/portal/web/command/ServletCommand.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/command/ServletCommand.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/command/ServletCommand.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -1,39 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.web.command;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
-import java.io.IOException;
-
-/**
- * Command to be executed in the command servlet.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ServletCommand
-{
- void execute(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException;
-}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/DefaultServletContainerFactory.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/DefaultServletContainerFactory.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/DefaultServletContainerFactory.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl;
+
+import org.jboss.portal.web.ServletContainer;
+import org.jboss.portal.web.ServletContainerFactory;
+import org.jboss.portal.web.spi.ServletContainerContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultServletContainerFactory implements ServletContainerFactory
+{
+
+ /** . */
+ public static final DefaultServletContainerFactory instance = new
DefaultServletContainerFactory();
+
+ public static ServletContainerFactory getInstance()
+ {
+ return instance;
+ }
+
+ /** . */
+ private final ServletContainer container = new ServletContainer();
+
+ /**
+ * Returns the singleton instance.
+ *
+ * @return the singleton instance
+ */
+ public ServletContainer getServletContainer()
+ {
+ return container;
+ }
+
+ /**
+ * Register the context argument on the singleton instance.
+ */
+ public static void registerContext(ServletContainerContext context) throws
IllegalArgumentException
+ {
+ instance.container.register(context);
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericServletContainerContext.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericServletContainerContext.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericServletContainerContext.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl.generic;
+
+import org.jboss.portal.web.RequestDispatchCallback;
+import org.jboss.portal.web.impl.DefaultServletContainerFactory;
+import org.jboss.portal.web.spi.ServletContainerContext;
+import org.jboss.portal.web.command.CommandDispatcher;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericServletContainerContext implements ServletContainerContext
+{
+
+ /** . */
+ private static final GenericServletContainerContext instance = new
GenericServletContainerContext();
+
+ /** . */
+ private Registration registration;
+
+ static
+ {
+ DefaultServletContainerFactory.registerContext(instance);
+ }
+
+ static void register(GenericWebAppContext webAppContext)
+ {
+ if (instance.registration != null)
+ {
+ instance.registration.registerWebApp(webAppContext);
+ }
+ }
+
+ static void unregister(String webAppId)
+ {
+ if (instance.registration != null)
+ {
+ instance.registration.unregisterWebApp(webAppId);
+ }
+ }
+
+ /** . */
+ private final CommandDispatcher dispatcher = new CommandDispatcher();
+
+ public Object include(
+ ServletContext targetServletContext,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ RequestDispatchCallback callback,
+ Object handback) throws ServletException, IOException
+ {
+ return dispatcher.include(targetServletContext, request, response, callback,
handback);
+ }
+
+ public void setCallback(Registration registration)
+ {
+ this.registration = registration;
+ }
+
+ public void unsetCallback(Registration registration)
+ {
+ this.registration = null;
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericWebAppContext.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericWebAppContext.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/GenericWebAppContext.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl.generic;
+
+import org.jboss.portal.web.spi.WebAppContext;
+
+import javax.servlet.ServletContext;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericWebAppContext implements WebAppContext
+{
+
+ /** . */
+ private final ServletContext servletContext;
+
+ /** . */
+ private final String contextPath;
+
+ /** . */
+ private final ClassLoader classLoader;
+
+ public GenericWebAppContext(ServletContext servletContext, String contextPath,
ClassLoader classLoader)
+ {
+ this.servletContext = servletContext;
+ this.contextPath = contextPath;
+ this.classLoader = classLoader;
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ public boolean importFile(String parentDirRelativePath, String name, InputStream
source, boolean overwrite) throws IOException
+ {
+ return false;
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/PortletContainerBootstrapServlet.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/PortletContainerBootstrapServlet.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/generic/PortletContainerBootstrapServlet.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl.generic;
+
+import org.jboss.portal.web.command.CommandServlet;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletContext;
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletContainerBootstrapServlet extends CommandServlet
+{
+
+ /** . */
+ private String contextPath;
+
+ public void init() throws ServletException
+ {
+ try
+ {
+ Method m = ServletContext.class.getMethod("getContextPath", new
Class[0]);
+ ServletContext servletContext = getServletContext();
+
+ //
+ String contextPath = (String)m.invoke(servletContext, new Object[0]);
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ GenericWebAppContext webAppContext = new GenericWebAppContext(servletContext,
contextPath, classLoader);
+
+ //
+ GenericServletContainerContext.register(webAppContext);
+ this.contextPath = contextPath;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void destroy()
+ {
+ if (contextPath != null)
+ {
+ GenericServletContainerContext.unregister(contextPath);
+ }
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ContainerServlet.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ContainerServlet.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ContainerServlet.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,127 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl.tomcat;
+
+import org.apache.catalina.ContainerServlet;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.Container;
+import org.apache.catalina.Engine;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.ServletException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TC6ContainerServlet extends HttpServlet implements ContainerServlet
+{
+
+ /** . */
+ private Wrapper wrapper;
+
+ /** . */
+ private TC6ServletContainerContext containerContext;
+
+ /** . */
+ private boolean started;
+
+ public Wrapper getWrapper()
+ {
+ return wrapper;
+ }
+
+ public void setWrapper(Wrapper wrapper)
+ {
+ this.wrapper = wrapper;
+
+ //
+ if (wrapper != null)
+ {
+ attemptStart();
+ }
+ else
+ {
+ attemptStop();
+ }
+ }
+
+ public void init() throws ServletException
+ {
+ started = true;
+
+ //
+ attemptStart();
+ }
+
+ public void destroy()
+ {
+ started = false;
+
+ //
+ attemptStop();
+ }
+
+ private void attemptStart()
+ {
+ if (started && wrapper != null)
+ {
+ start();
+ }
+ }
+
+ private void attemptStop()
+ {
+ if (!started || wrapper == null)
+ {
+ stop();
+ }
+ }
+
+ private void start()
+ {
+ Container container = wrapper;
+ while (container.getParent() != null)
+ {
+ container = container.getParent();
+ if (container instanceof Engine)
+ {
+ Engine engine = (Engine)container;
+ containerContext = new TC6ServletContainerContext(engine);
+ containerContext.start();
+ break;
+ }
+ }
+ }
+
+ private void stop()
+ {
+ if (containerContext != null)
+ {
+ containerContext.stop();
+
+ //
+ containerContext = null;
+ }
+ }
+}
Added:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6LifecycleListener.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6LifecycleListener.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6LifecycleListener.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl.tomcat;
+
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
+import org.apache.catalina.Container;
+import org.apache.catalina.Engine;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TC6LifecycleListener implements LifecycleListener
+{
+
+ /** . */
+ private TC6ServletContainerContext containerContext;
+
+ public synchronized void lifecycleEvent(LifecycleEvent event)
+ {
+ Lifecycle lifecycle = event.getLifecycle();
+
+ //
+ if (lifecycle instanceof Server)
+ {
+ Server server = (Server)lifecycle;
+
+ //
+ Engine engine = getEngine(server);
+
+ //
+ if (engine != null)
+ {
+ if (Lifecycle.START_EVENT.equals(event.getType()))
+ {
+ containerContext = new TC6ServletContainerContext(engine);
+ containerContext.start();
+ }
+ else if (Lifecycle.STOP_EVENT.equals(event.getType()))
+ {
+ if (containerContext != null)
+ {
+ containerContext.stop();
+ }
+ }
+ }
+ }
+ }
+
+ private Engine getEngine(Server server)
+ {
+ Service[] services = server.findServices();
+ for (int i = 0; i < services.length; i++)
+ {
+ Service service = services[i];
+ Engine engine = getEngine(service.getContainer());
+ if (engine != null)
+ {
+ return engine;
+ }
+ }
+ return null;
+ }
+
+ private Engine getEngine(Container container)
+ {
+ if (container instanceof Engine)
+ {
+ return (Engine)container;
+ }
+ return null;
+ }
+}
Modified:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -22,34 +22,27 @@
******************************************************************************/
package org.jboss.portal.web.impl.tomcat;
-import org.jboss.portal.web.WebAppListener;
import org.jboss.portal.web.RequestDispatchCallback;
-import org.jboss.portal.web.WebAppEvent;
-import org.jboss.portal.web.WebAppLifeCycleEvent;
-import org.jboss.portal.web.ServletContainer;
+import org.jboss.portal.web.impl.DefaultServletContainerFactory;
import org.jboss.portal.web.command.CommandDispatcher;
import org.jboss.portal.web.spi.ServletContainerContext;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.ContainerListener;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
import org.apache.catalina.Container;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.ContainerEvent;
import org.apache.catalina.Context;
+import org.apache.catalina.ContainerListener;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleEvent;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.Set;
import java.util.HashSet;
+import java.io.IOException;
/**
* An implementation of the <code>ServletContainerContext</code> for Tomcat.
@@ -57,24 +50,27 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class TC6ServletContainerContext implements ServletContainerContext,
LifecycleListener, ContainerListener
+public class TC6ServletContainerContext implements ServletContainerContext,
ContainerListener, LifecycleListener
{
+ /** . */
+ private final CommandDispatcher dispatcher = new CommandDispatcher();
+
/** The monitored hosts. */
private final Set monitoredHosts = new HashSet();
- /** The event listeners. */
- private final ArrayList listeners = new ArrayList();
+ /** The monitored contexts. */
+ private final Set monitoredContexts = new HashSet();
- /** The web applications. */
- private final Map webAppMap = new HashMap();
+ /** . */
+ private final Engine engine;
/** . */
- private final CommandDispatcher dispatcher = new CommandDispatcher();
+ private Registration registration;
- public TC6ServletContainerContext()
+ public TC6ServletContainerContext(Engine engine)
{
- ServletContainer.registerContext(this);
+ this.engine = engine;
}
public Object include(
@@ -82,166 +78,217 @@
HttpServletRequest request,
HttpServletResponse response,
RequestDispatchCallback callback,
- Object handback) throws Exception
+ Object handback) throws ServletException, IOException
{
return dispatcher.include(targetServletContext, request, response, callback,
handback);
}
- public synchronized boolean addWebAppListener(WebAppListener listener)
+ public void setCallback(Registration registration)
{
- if (listener == null)
+ this.registration = registration;
+ }
+
+ public void unsetCallback(Registration registration)
+ {
+ this.registration = null;
+ }
+
+ public synchronized void containerEvent(ContainerEvent event)
+ {
+ if (event.getData() instanceof Host)
{
- throw new IllegalArgumentException();
+ Host host = (Host)event.getData();
+
+ //
+ if (Container.ADD_CHILD_EVENT.equals(event.getType()))
+ {
+ registerHost(host);
+ }
+ else if (Container.REMOVE_CHILD_EVENT.equals(event.getType()))
+ {
+ unregisterHost(host);
+ }
}
- if (listeners.contains(listener))
+ else if (event.getData() instanceof Context)
{
- return false;
+ Context context = (Context)event.getData();
+
+ //
+ if (Container.ADD_CHILD_EVENT.equals(event.getType()))
+ {
+ registerContext(context);
+ }
+ else if (Container.REMOVE_CHILD_EVENT.equals(event.getType()))
+ {
+ unregisterContext(context);
+ }
}
- listeners.add(listener);
- for (Iterator i = webAppMap.values().iterator(); i.hasNext();)
+ }
+
+ public void lifecycleEvent(LifecycleEvent event)
+ {
+ if (event.getSource() instanceof Context)
{
- TC6WebApp webApp = (TC6WebApp)i.next();
- WebAppLifeCycleEvent event = new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.ADDED);
- fireEvent(listener, event);
+ Context context = (Context)event.getSource();
+
+ //
+ if (Lifecycle.AFTER_START_EVENT.equals(event.getType()))
+ {
+ start(context);
+ }
+ else if (Lifecycle.BEFORE_STOP_EVENT.equals(event.getType()))
+ {
+ stop(context);
+ }
}
- return true;
}
- public synchronized boolean removeWebAppListener(WebAppListener listener)
+ void start()
{
- if (listener == null)
+ DefaultServletContainerFactory.registerContext(this);
+
+ //
+ Container[] childrenContainers = engine.findChildren();
+ for (int i = 0; i < childrenContainers.length; i++)
{
- throw new IllegalArgumentException();
- }
- if (listeners.remove(listener))
- {
- for (Iterator i = webAppMap.values().iterator(); i.hasNext();)
+ Container childContainer = childrenContainers[i];
+ if (childContainer instanceof Host)
{
- TC6WebApp webApp = (TC6WebApp)i.next();
- WebAppLifeCycleEvent event = new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED);
- fireEvent(listener, event);
+ Host host = (Host)childContainer;
+ registerHost(host);
}
- return true;
}
- else
- {
- return false;
- }
+
+ //
+ engine.addContainerListener(this);
}
- public synchronized void lifecycleEvent(LifecycleEvent lifecycleEvent)
+ void stop()
{
- Lifecycle lifecycle = lifecycleEvent.getLifecycle();
- System.out.println("lifecycle = " + lifecycle);
- if (lifecycle instanceof Server)
+ engine.removeContainerListener(this);
+
+ //
+ Container[] childrenContainers = engine.findChildren();
+ for (int i = 0; i < childrenContainers.length; i++)
{
- Server server = (Server)lifecycle;
- Service[] services = server.findServices();
- for (int i = 0; i < services.length; i++)
+ Container childContainer = childrenContainers[i];
+ if (childContainer instanceof Host)
{
- Service service = services[i];
- handleContainer(service.getContainer());
+ Host host = (Host)childContainer;
+ unregisterHost(host);
}
}
+
+ //
+ registration.cancel();
+ registration = null;
}
- public synchronized void containerEvent(ContainerEvent containerEvent)
+ /**
+ * Register an host for registration which means that we fire events for all the
contexts it
+ * contains and we subscribe for its life cycle events. If the host is already
monitored
+ * nothing is done.
+ *
+ * @param host the host to register for monitoring
+ */
+ private void registerHost(Host host)
{
- if (containerEvent.getData() instanceof Context)
+ if (!monitoredHosts.contains(host.getName()))
{
- Context context = (Context)containerEvent.getData();
- String webAppId = TC6WebAppIdFactory.createId(context);
-
- if ("addChild".equals(containerEvent.getType()))
+ Container[] childrenContainers = host.findChildren();
+ for (int i = 0; i < childrenContainers.length; i++)
{
- System.out.println("Context added " + context.getPath());
- try
+ Container childContainer = childrenContainers[i];
+ if (childContainer instanceof Context)
{
- if (webAppMap.containsKey(webAppId))
- {
- System.out.println("Web application " + webAppId + " is
already registered");
- }
- else
- {
- TC6WebApp webApp = new TC6WebApp(context);
- System.out.println("Web application " + webAppId + "
registration");
- webApp.instrument();
- webAppMap.put(webApp.getId(), webApp);
- fireEvent(new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.ADDED));
- }
+ Context context = (Context)childContainer;
+ registerContext(context);
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
}
- else if ("removeChild".equals(containerEvent.getType()))
+
+ //
+ host.addContainerListener(this);
+
+ //
+ monitoredHosts.add(host.getName());
+ }
+ }
+
+ private void unregisterHost(Host host)
+ {
+ if (monitoredHosts.contains(host.getName()))
+ {
+ monitoredHosts.remove(host.getName());
+
+ //
+ host.removeContainerListener(this);
+
+ //
+ Container[] childrenContainers = host.findChildren();
+ for (int i = 0; i < childrenContainers.length; i++)
{
- try
+ Container childContainer = childrenContainers[i];
+ if (childContainer instanceof Context)
{
- TC6WebApp webApp = (TC6WebApp)webAppMap.remove(webAppId);
- if (webApp != null)
- {
- System.out.println("Web application " + webAppId + "
cleanup");
- fireEvent(new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED));
- webApp.cleanup();
- }
- else
- {
- System.out.println("Web application " + webAppId + " is
already registered");
- }
+ Context context = (Context)childContainer;
+ unregisterContext(context);
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
}
}
}
-// synchronized(webAppMap)
-// {
-// for (Iterator i = webAppMap.values().iterator();i.hasNext();)
-// {
-// TC6WebApp webApp = (TC6WebApp)i.next();
-// System.out.println("Web application " + webApp.getId() + "
unregistration");
-// webApp.cleanup();
-// i.remove();
-// }
-// }
-
- private void handleContainer(Container container)
+ private void registerContext(Context context)
{
- if (container instanceof Engine)
+ if (!monitoredContexts.contains(context.getName()))
{
- Engine engine = (Engine)container;
- Container[] childrenContainers = engine.findChildren();
- for (int i = 0; i < childrenContainers.length; i++)
+ if (context instanceof Lifecycle)
{
- Container childContainer = childrenContainers[i];
- handleContainer(childContainer);
+ ((Lifecycle)context).addLifecycleListener(this);
}
+
+ //
+ if (context.getAvailable())
+ {
+ start(context);
+ }
+
+ //
+ monitoredContexts.add(context.getName());
}
- else if (container instanceof Host)
+ }
+
+ private void unregisterContext(Context context)
+ {
+ if (monitoredContexts.contains(context.getName()))
{
- Host host = (Host)container;
- if (!monitoredHosts.contains(host.getName()))
+ monitoredContexts.remove(context.getName());
+
+ //
+ if (context.getAvailable())
{
- host.addContainerListener(this);
- monitoredHosts.add(host.getName());
+ stop(context);
}
+
+ //
+ if (context instanceof Lifecycle)
+ {
+ ((Lifecycle)context).removeLifecycleListener(this);
+ }
}
- else
- {
- System.out.println("Container not handled " + container);
- }
}
- private void fireEvent(WebAppListener listener, WebAppEvent event)
+ private void start(Context context)
{
try
{
- listener.onEvent(event);
+ System.out.println("Context added " + context.getPath());
+ TC6WebAppContext webAppContext = new TC6WebAppContext(context);
+
+ //
+ if (registration != null)
+ {
+ registration.registerWebApp(webAppContext);
+ }
}
catch (Exception e)
{
@@ -249,11 +296,18 @@
}
}
- private void fireEvent(WebAppEvent event)
+ private void stop(Context context)
{
- for (Iterator i = listeners.iterator();i.hasNext();)
+ try
{
- fireEvent((WebAppListener)i.next(), event);
+ if (registration != null)
+ {
+ registration.unregisterWebApp(context.getPath());
+ }
}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
}
Deleted: modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebApp.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebApp.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebApp.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -1,135 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.web.impl.tomcat;
-
-import org.w3c.dom.Document;
-import org.apache.catalina.Context;
-import org.apache.catalina.Wrapper;
-import org.jboss.portal.web.command.CommandServlet;
-import org.jboss.portal.web.WebApp;
-
-import javax.servlet.ServletContext;
-import java.net.URL;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TC6WebApp implements WebApp
-{
-
- /** The logger. */
-// protected final Logger log = Logger.getLogger(getClass());
-
- /** . */
- private Document descriptor;
-
- /** . */
- private ServletContext servletContext;
-
- /** . */
- private ClassLoader loader;
-
- /** . */
- private String id;
-
- /** . */
- private String contextPath;
-
- /** . */
- private final Context context;
-
- /** . */
- private Wrapper commandServlet;
-
- TC6WebApp(Context context) throws Exception
- {
- this.context = context;
-
- //
- servletContext = context.getServletContext();
- loader = context.getLoader().getClassLoader();
- id = context.getPath();
- contextPath = context.getPath();
- }
-
- void instrument() throws Exception
- {
- try
- {
- commandServlet = context.createWrapper();
- commandServlet.setName("JBossServlet");
- commandServlet.setLoadOnStartup(0);
- commandServlet.setServletClass(CommandServlet.class.getName());
- context.addChild(commandServlet);
- context.addServletMapping("/jbossportlet", "JBossServlet");
- }
- catch (Exception e)
- {
- cleanup();
- throw e;
- }
- }
-
- void cleanup()
- {
- if (commandServlet != null)
- {
- try
- {
- context.removeServletMapping("jbossportlet");
- context.removeChild(commandServlet);
- }
- catch (Exception e)
- {
- }
- }
- }
-
- public ServletContext getServletContext()
- {
- return servletContext;
- }
-
- public String getId()
- {
- return id;
- }
-
- public ClassLoader getClassLoader()
- {
- return loader;
- }
-
- public String getContextPath()
- {
- return contextPath;
- }
-
- public boolean importFile(String parentDirRelativePath, String name, InputStream
source, boolean overwrite) throws IOException
- {
- return false;
- }
-}
Copied:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppContext.java
(from rev 8005,
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebApp.java)
===================================================================
--- modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppContext.java
(rev 0)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppContext.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl.tomcat;
+
+import org.w3c.dom.Document;
+import org.apache.catalina.Context;
+import org.apache.catalina.Wrapper;
+import org.jboss.portal.web.command.CommandServlet;
+import org.jboss.portal.web.spi.WebAppContext;
+
+import javax.servlet.ServletContext;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TC6WebAppContext implements WebAppContext
+{
+
+ /** The logger. */
+// protected final Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private Document descriptor;
+
+ /** . */
+ private ServletContext servletContext;
+
+ /** . */
+ private ClassLoader loader;
+
+ /** . */
+ private String contextPath;
+
+ /** . */
+ private final Context context;
+
+ /** . */
+ private Wrapper commandServlet;
+
+ TC6WebAppContext(Context context) throws Exception
+ {
+ this.context = context;
+
+ //
+ servletContext = context.getServletContext();
+ loader = context.getLoader().getClassLoader();
+ contextPath = context.getPath();
+ }
+
+ public void start() throws Exception
+ {
+ try
+ {
+ commandServlet = context.createWrapper();
+ commandServlet.setName("JBossServlet");
+ commandServlet.setLoadOnStartup(0);
+ commandServlet.setServletClass(CommandServlet.class.getName());
+ context.addChild(commandServlet);
+ context.addServletMapping("/jbossportlet", "JBossServlet");
+ }
+ catch (Exception e)
+ {
+ cleanup();
+ throw e;
+ }
+ }
+
+ public void stop()
+ {
+ cleanup();
+ }
+
+ private void cleanup()
+ {
+ if (commandServlet != null)
+ {
+ try
+ {
+ context.removeServletMapping("jbossportlet");
+ context.removeChild(commandServlet);
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return loader;
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ public boolean importFile(String parentDirRelativePath, String name, InputStream
source, boolean overwrite) throws IOException
+ {
+ return false;
+ }
+}
Deleted:
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppIdFactory.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppIdFactory.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/impl/tomcat/TC6WebAppIdFactory.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -1,37 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.web.impl.tomcat;
-
-import org.apache.catalina.Context;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TC6WebAppIdFactory
-{
- public static String createId(Context context)
- {
- return context.getPath();
- }
-}
Modified:
modules/web/trunk/web/src/main/org/jboss/portal/web/spi/ServletContainerContext.java
===================================================================
---
modules/web/trunk/web/src/main/org/jboss/portal/web/spi/ServletContainerContext.java 2007-09-10
23:03:20 UTC (rev 8207)
+++
modules/web/trunk/web/src/main/org/jboss/portal/web/spi/ServletContainerContext.java 2007-09-10
23:06:44 UTC (rev 8208)
@@ -23,16 +23,19 @@
package org.jboss.portal.web.spi;
import org.jboss.portal.web.RequestDispatchCallback;
-import org.jboss.portal.web.WebAppListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import java.io.IOException;
/**
* Defines the service provider interface for a servlet container. It is an attempt to
abstract the non
* portable services required by a portal with respect to the web container layer.
*
+ * @todo add session invalidation mechanism
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
@@ -53,31 +56,55 @@
ServletContext targetServletContext, HttpServletRequest request,
HttpServletResponse response,
RequestDispatchCallback callback,
- Object handback) throws Exception;
+ Object handback) throws ServletException, IOException;
/**
- * Try to add a web application listener on the servlet container context. If the
listener is already registered then it
- * has no effect and the method call returns false, otherwise it adds the listener and
returns true. When a listener
- * is added it will receive add notifications for all web applications already
registered. When a new web application
- * is added in the context, all listeners will receive a notification.
+ * Install the call back object.
*
- * @param listener the listener
- * @return true if the listener has been added
- * @throws IllegalArgumentException if the listener argument is null
+ * @param registration the call back
*/
- boolean addWebAppListener(WebAppListener listener) throws IllegalArgumentException;
+ void setCallback(Registration registration);
/**
- * Try to remove a web application listener on the servlet container context. If the
listener is not registered then
- * it has no effect and the method call returns false, otherwise it removes the
listener and returns true. When a
- * listener is removed it will receive remove notifications for all the web
applications that are still registered.
- * When a registered web application is removes from the context, all listeners will
receive a notification.
+ * Uninstall the call back object.
*
- * @param listener
- * @return
- * @throws IllegalArgumentException
+ * @param registration the call back
*/
- boolean removeWebAppListener(WebAppListener listener) throws
IllegalArgumentException;
+ void unsetCallback(Registration registration);
+ /**
+ * The callback interface that a servlet container context can obtain from its
registration against
+ * the <code>org.jboss.portal.web.ServletContainer</code> singleton.
+ */
+ interface Registration
+ {
+ /**
+ * Registers a web application.
+ *
+ * @param webAppContext the web application context
+ * @return true if the registration was done
+ * @throws IllegalArgumentException if the argument is null
+ * @throws IllegalStateException if the registration is cancelled
+ */
+ boolean registerWebApp(WebAppContext webAppContext) throws IllegalStateException,
IllegalArgumentException;
+
+ /**
+ * Unregister a web application.
+ *
+ * @param contextPath the web application id
+ * @return true if the unregistration was done
+ * @throws IllegalArgumentException if the argument is null
+ * @throws IllegalStateException if the registration is cancelled
+ */
+ boolean unregisterWebApp(String contextPath) throws IllegalStateException,
IllegalArgumentException;
+
+ /**
+ * Cancel the registration against the servlet container.
+ *
+ * @throws IllegalStateException if the registration is cancelled
+ */
+ void cancel() throws IllegalStateException;
+ }
+
}
Added:
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/client-beans.xml
===================================================================
---
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/client-beans.xml
(rev 0)
+++
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/client-beans.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="Config"
class="org.jboss.portal.test.web.spi.SPITestConfig">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>Config</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="NodeFactory"
class="org.jboss.portal.test.framework.impl.generic.server.GenericNodeFactory">
+ <constructor>
+ <parameter>servers.xml</parameter>
+ <parameter><inject bean="Config"
property="serverName"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="Node0"
class="org.jboss.portal.test.framework.impl.generic.server.GenericNode">
+ <constructor factoryMethod="getNode">
+ <factory bean="NodeFactory" />
+ <parameter>default</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="NodeManager"
class="org.jboss.portal.test.framework.server.NodeManager">
+ <constructor>
+ <parameter>
+ <list>
+ <inject bean="Node0"/>
+ </list>
+ </parameter>
+ </constructor>
+ </bean>
+
+ <bean name="Deployer"
class="org.jboss.portal.test.framework.deployment.Deployer">
+ </bean>
+
+ <bean name="TestDriverClient"
class="org.jboss.portal.test.framework.driver.remote.RemoteTestDriverClient">
+ <property name="initialNodeId"><inject bean="Node0"
property="id"/></property>
+ <property name="archivePath"><inject bean="Config"
property="archivePath"/></property>
+ <property name="nodeManager"><inject
bean="NodeManager"/></property>
+ <property name="deployer"><inject
bean="Deployer"/></property>
+ </bean>
+
+ <bean name="JUnitAdapter"
class="org.jboss.portal.test.framework.junit.JUnitAdapter">
+ <constructor>
+ <parameter><inject
bean="TestDriverClient"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="This"
class="org.jboss.portal.test.web.spi.SPITestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>This</parameter>
+ </constructor>
+ <property name="testDriver"><inject
bean="TestDriverClient"/></property>
+ <property name="deployer"><inject
bean="Deployer"/></property>
+ <property name="nodeManager"><inject
bean="NodeManager"/></property>
+ <property name="adapter"><inject
bean="JUnitAdapter"/></property>
+ </bean>
+
+</deployment>
Added:
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/server-beans.xml
===================================================================
---
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/server-beans.xml
(rev 0)
+++
modules/web/trunk/web/src/resources/portal-web-test-jar/org/jboss/portal/test/web/spi/server-beans.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="TestDriverServer"
class="org.jboss.portal.test.framework.driver.remote.RemoteTestDriverServer">
+ </bean>
+
+ <bean name="TestDriverServerExporter"
class="org.jboss.portal.test.framework.impl.generic.server.GenericServiceExporter">
+ <constructor>
+ <parameter>socket://localhost:5400</parameter>
+ <parameter><inject
bean="TestDriverServer"/></parameter>
+
<parameter>org.jboss.portal.test.framework.driver.remote.RemoteTestDriver</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="ServletContainer"
class="org.jboss.portal.web.ServletContainer">
+ <constructor factoryClass="org.jboss.portal.web.ServletContainer"
factoryMethod="getInstance"/>
+ </bean>
+
+</deployment>
Added: modules/web/trunk/web/src/resources/test/config/servers.xml
===================================================================
--- modules/web/trunk/web/src/resources/test/config/servers.xml
(rev 0)
+++ modules/web/trunk/web/src/resources/test/config/servers.xml 2007-09-10 23:06:44 UTC
(rev 8208)
@@ -0,0 +1,42 @@
+<servers>
+ <server>
+ <server-name>RemoteTomcat-6.0</server-name>
+ <node>
+ <node-id>default</node-id>
+ <service>
+ <service-name>TestDriverServer</service-name>
+
<interface>org.jboss.portal.test.framework.driver.remote.RemoteTestDriver</interface>
+ <uri>socket://localhost:5400</uri>
+ </service>
+ <deployer>
+ <remote>
+ <name>tomcat5x</name>
+ <host>localhost</host>
+ <port>8080</port>
+ </remote>
+ <authentication>
+ <username>admin</username>
+ <password>admin</password>
+ </authentication>
+ </deployer>
+ </node>
+ </server>
+ <server>
+ <server-name>RemoteJBoss-4.2</server-name>
+ <node>
+ <node-id>default</node-id>
+ <service>
+ <service-name>TestDriverServer</service-name>
+
<interface>org.jboss.portal.test.framework.driver.remote.RemoteTestDriver</interface>
+ <uri>socket://localhost:5400</uri>
+ </service>
+ <deployer>
+ <remote>
+ <name>jboss4x</name>
+ <host>localhost</host>
+ <port>8080</port>
+ </remote>
+ </deployer>
+ </node>
+ </server>
+</servers>
Added: modules/web/trunk/web/src/resources/test/spi/app-war/WEB-INF/web.xml
===================================================================
--- modules/web/trunk/web/src/resources/test/spi/app-war/WEB-INF/web.xml
(rev 0)
+++ modules/web/trunk/web/src/resources/test/spi/app-war/WEB-INF/web.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+</web-app>
Added:
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/context.xml
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/context.xml
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/context.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,2 @@
+<Context privileged="true" crossContext="true">
+</Context>
\ No newline at end of file
Added:
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/web.xml
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/web.xml
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/jboss-container-servlet-4.2/server-war/WEB-INF/web.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+
<param-value>org/jboss/portal/test/web/spi/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+
<listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>ContainerServlet</servlet-name>
+
<servlet-class>org.jboss.portal.web.impl.tomcat.TC6ContainerServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>SPITestServlet</servlet-name>
+
<servlet-class>org.jboss.portal.test.web.spi.SPITestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>SPITestServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+</web-app>
Added:
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/META-INF/context.xml
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/META-INF/context.xml
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/META-INF/context.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,2 @@
+<Context privileged="true" crossContext="true">
+</Context>
\ No newline at end of file
Added:
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/log4j.properties
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/log4j.properties
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/log4j.properties 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,13 @@
+### ====================================================================== ###
+## ##
+## JBoss Bootstrap Log4j Configuration ##
+## ##
+### ====================================================================== ###
+
+log4j.rootCategory=ALL, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
Added:
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/logging.properties
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/logging.properties
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/classes/logging.properties 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,13 @@
+handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+org.apache.juli.FileHandler.level = FINE
+org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+org.apache.juli.FileHandler.prefix = test-spi.
+
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
Added:
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/web.xml
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/web.xml
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/tomcat-container-servlet-6.0/server-war/WEB-INF/web.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+
<param-value>org/jboss/portal/test/web/spi/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+
<listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>ContainerServlet</servlet-name>
+
<servlet-class>org.jboss.portal.web.impl.tomcat.TC6ContainerServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>SPITestServlet</servlet-name>
+
<servlet-class>org.jboss.portal.test.web.spi.SPITestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>SPITestServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+</web-app>
Added:
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/log4j.properties
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/log4j.properties
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/log4j.properties 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,13 @@
+### ====================================================================== ###
+## ##
+## JBoss Bootstrap Log4j Configuration ##
+## ##
+### ====================================================================== ###
+
+log4j.rootCategory=ALL, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
Added:
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/logging.properties
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/logging.properties
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/classes/logging.properties 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,13 @@
+handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+org.apache.juli.FileHandler.level = FINE
+org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+org.apache.juli.FileHandler.prefix = test-spi.
+
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
Added:
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/web.xml
===================================================================
---
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/web.xml
(rev 0)
+++
modules/web/trunk/web/src/resources/test/spi/tomcat-lifecycle-listener-6.0/server-war/WEB-INF/web.xml 2007-09-10
23:06:44 UTC (rev 8208)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+
<param-value>org/jboss/portal/test/web/spi/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+
<listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>SPITestServlet</servlet-name>
+
<servlet-class>org.jboss.portal.test.web.spi.SPITestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>SPITestServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+</web-app>