Author: julien(a)jboss.com
Date: 2008-02-19 13:03:31 -0500 (Tue, 19 Feb 2008)
New Revision: 10031
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java
modules/web/trunk/web/src/test/build.xml
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/WebAppRegistry.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java
modules/web/trunk/web/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml
Log:
JBPORTAL-1903 : The web application containing the integration SPI does not participate in
the life cycle of the web SPI
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java
===================================================================
---
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java 2008-02-19
14:07:50 UTC (rev 10030)
+++
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java 2008-02-19
18:03:31 UTC (rev 10031)
@@ -36,6 +36,7 @@
import org.jboss.portal.web.command.CommandDispatcher;
import org.jboss.portal.web.impl.DefaultServletContainerFactory;
import org.jboss.portal.web.spi.ServletContainerContext;
+import org.apache.catalina.core.StandardContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -59,10 +60,10 @@
private final CommandDispatcher dispatcher = new CommandDispatcher();
/** The monitored hosts. */
- private final Set monitoredHosts = new HashSet();
+ private final Set<String> monitoredHosts = new HashSet<String>();
/** The monitored contexts. */
- private final Set monitoredContexts = new HashSet();
+ private final Set<String> monitoredContexts = new HashSet<String>();
/** . */
private final Engine engine;
@@ -111,9 +112,9 @@
unregisterHost(host);
}
}
- else if (event.getData() instanceof Context)
+ else if (event.getData() instanceof StandardContext)
{
- Context context = (Context)event.getData();
+ StandardContext context = (StandardContext)event.getData();
//
if (Container.ADD_CHILD_EVENT.equals(event.getType()))
@@ -151,9 +152,8 @@
//
Container[] childrenContainers = engine.findChildren();
- for (int i = 0; i < childrenContainers.length; i++)
+ for (Container childContainer : childrenContainers)
{
- Container childContainer = childrenContainers[i];
if (childContainer instanceof Host)
{
Host host = (Host)childContainer;
@@ -171,9 +171,8 @@
//
Container[] childrenContainers = engine.findChildren();
- for (int i = 0; i < childrenContainers.length; i++)
+ for (Container childContainer : childrenContainers)
{
- Container childContainer = childrenContainers[i];
if (childContainer instanceof Host)
{
Host host = (Host)childContainer;
@@ -197,12 +196,11 @@
if (!monitoredHosts.contains(host.getName()))
{
Container[] childrenContainers = host.findChildren();
- for (int i = 0; i < childrenContainers.length; i++)
+ for (Container childContainer : childrenContainers)
{
- Container childContainer = childrenContainers[i];
- if (childContainer instanceof Context)
+ if (childContainer instanceof StandardContext)
{
- Context context = (Context)childContainer;
+ StandardContext context = (StandardContext)childContainer;
registerContext(context);
}
}
@@ -226,29 +224,25 @@
//
Container[] childrenContainers = host.findChildren();
- for (int i = 0; i < childrenContainers.length; i++)
+ for (Container childContainer : childrenContainers)
{
- Container childContainer = childrenContainers[i];
if (childContainer instanceof Context)
{
- Context context = (Context)childContainer;
+ StandardContext context = (StandardContext)childContainer;
unregisterContext(context);
}
}
}
}
- private void registerContext(Context context)
+ private void registerContext(StandardContext context)
{
if (!monitoredContexts.contains(context.getName()))
{
- if (context instanceof Lifecycle)
- {
- ((Lifecycle)context).addLifecycleListener(this);
- }
+ context.addLifecycleListener(this);
//
- if (context.getAvailable())
+ if (context.getState() == 1)
{
start(context);
}
@@ -258,7 +252,7 @@
}
}
- private void unregisterContext(Context context)
+ private void unregisterContext(StandardContext context)
{
if (monitoredContexts.contains(context.getName()))
{
@@ -271,10 +265,7 @@
}
//
- if (context instanceof Lifecycle)
- {
- ((Lifecycle)context).removeLifecycleListener(this);
- }
+ context.removeLifecycleListener(this);
}
}
Modified: modules/web/trunk/web/src/test/build.xml
===================================================================
--- modules/web/trunk/web/src/test/build.xml 2008-02-19 14:07:50 UTC (rev 10030)
+++ modules/web/trunk/web/src/test/build.xml 2008-02-19 18:03:31 UTC (rev 10031)
@@ -572,21 +572,21 @@
<param name="test.id"
value="Tomcat-6_0-spi-container-servlet"/>
<param name="test.tomcat-6.name"
value="RemoteTomcat_6_0"/>
<param name="test.tomcat-6.home"
value="${TOMCAT_6_0_HOME}"/>
- <param name="test.tomcat-6.home.variable-name"
value="OMCAT_6_0_HOME"/>
+ <param name="test.tomcat-6.home.variable-name"
value="TOMCAT_6_0_HOME"/>
<param name="test.archive.path"
value="${test.temp.lib}/tomcat-6.0-container-servlet/test-spi-server.war"/>
</antcall>
<antcall target="tests.tomcat-6.generic">
<param name="test.id"
value="Tomcat-6_0-spi-generic"/>
<param name="test.tomcat-6.name"
value="RemoteTomcat_6_0"/>
<param name="test.tomcat-6.home"
value="${TOMCAT_6_0_HOME}"/>
- <param name="test.tomcat-6.home.variable-name"
value="OMCAT_6_0_HOME"/>
+ <param name="test.tomcat-6.home.variable-name"
value="TOMCAT_6_0_HOME"/>
<param name="test.archive.path"
value="${test.temp.lib}/tomcat-6.0-generic/test-spi-server.war"/>
</antcall>
<antcall target="tests.tomcat-6.container-servlet">
<param name="test.id"
value="Tomcat-6_0-request-container-servlet"/>
<param name="test.tomcat-6.name"
value="RemoteTomcat_6_0"/>
<param name="test.tomcat-6.home"
value="${TOMCAT_6_0_HOME}"/>
- <param name="test.tomcat-6.home.variable-name"
value="OMCAT_6_0_HOME"/>
+ <param name="test.tomcat-6.home.variable-name"
value="TOMCAT_6_0_HOME"/>
<param name="test.archive.path"
value="${test.temp.lib}/tomcat-6.0-container-servlet/test-request-server.war"/>
</antcall>
</target>
Modified:
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/WebAppRegistry.java
===================================================================
---
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/WebAppRegistry.java 2008-02-19
14:07:50 UTC (rev 10030)
+++
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/WebAppRegistry.java 2008-02-19
18:03:31 UTC (rev 10031)
@@ -39,7 +39,7 @@
{
/** . */
- final Map map = new HashMap();
+ final Map<String, WebApp> map = new HashMap<String, WebApp>();
public void onEvent(WebAppEvent event)
{
@@ -64,10 +64,10 @@
{
throw new IllegalArgumentException();
}
- return (WebApp)map.get(key);
+ return map.get(key);
}
- public Set getKeys()
+ public Set<String> getKeys()
{
return map.keySet();
}
Modified:
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java
===================================================================
---
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java 2008-02-19
14:07:50 UTC (rev 10030)
+++
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java 2008-02-19
18:03:31 UTC (rev 10031)
@@ -48,7 +48,6 @@
import java.io.IOException;
import java.util.Set;
import java.util.HashSet;
-import java.util.Collection;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -70,6 +69,13 @@
{
if (getRequestCount() == 1)
{
+ // Check that this web app is here
+ String key = req.getContextPath();
+ if (!keys.contains(key))
+ {
+ fail("The current test web app with key " + key + " is not
seen as deployed among " + keys);
+ }
+
// Should try
ServletContext appContext =
testServlet.getServletContext().getContext("/test-spi-app");
@@ -147,7 +153,7 @@
// Register and save the deployed web apps
registry = new WebAppRegistry();
container.addWebAppListener(registry);
- keys = new HashSet<String>((Collection<? extends
String>)registry.getKeys());
+ keys = new HashSet<String>(registry.getKeys());
// Deploy the application web app
return new DeployResponse("test-spi-app.war");
@@ -155,7 +161,7 @@
else if (getRequestCount() == 0)
{
// Compute the difference with the previous deployed web apps
- Set diff = new HashSet<String>((Collection<? extends
String>)registry.getKeys());
+ Set diff = new HashSet<String>(registry.getKeys());
diff.removeAll(keys);
// It should be 1
Modified:
modules/web/trunk/web/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml
===================================================================
---
modules/web/trunk/web/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml 2008-02-19
14:07:50 UTC (rev 10030)
+++
modules/web/trunk/web/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml 2008-02-19
18:03:31 UTC (rev 10031)
@@ -42,8 +42,17 @@
<servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
+ <servlet>
+ <servlet-name>BootstrapServlet</servlet-name>
+
<servlet-class>org.jboss.portal.web.impl.generic.PortletContainerBootstrapServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>BootstrapServlet</servlet-name>
+ <url-pattern>/jbossportlet</url-pattern>
+ </servlet-mapping>
</web-app>
Modified:
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml
===================================================================
---
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml 2008-02-19
14:07:50 UTC (rev 10030)
+++
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml 2008-02-19
18:03:31 UTC (rev 10031)
@@ -42,8 +42,17 @@
<servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
+ <servlet>
+ <servlet-name>BootstrapServlet</servlet-name>
+
<servlet-class>org.jboss.portal.web.impl.generic.PortletContainerBootstrapServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>BootstrapServlet</servlet-name>
+ <url-pattern>/jbossportlet</url-pattern>
+ </servlet-mapping>
</web-app>
Show replies by date