Author: julien_viet
Date: 2009-08-30 18:14:11 -0400 (Sun, 30 Aug 2009)
New Revision: 136
Added:
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/BootstrapServlet.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericServletContainerContext.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericWebAppContext.java
Removed:
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/generic/
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/command/CommandServlet.java
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/tomcat/TC6WebAppContext.java
components/wci/trunk/wci/src/test/resources/spi/generic/app-war/WEB-INF/web.xml
components/wci/trunk/wci/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml
components/wci/trunk/wci/src/test/resources/support/jboss-5.0-generic/server-war/WEB-INF/web.xml
components/wci/trunk/wci/src/test/resources/support/jetty-6.1-generic/server-war/WEB-INF/web.xml
components/wci/trunk/wci/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml
Log:
GTNWCI-2 : Provide public api bootstrap servlet
Added: components/wci/trunk/wci/src/main/java/org/gatein/wci/api/BootstrapServlet.java
===================================================================
--- components/wci/trunk/wci/src/main/java/org/gatein/wci/api/BootstrapServlet.java
(rev 0)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/BootstrapServlet.java 2009-08-30
22:14:11 UTC (rev 136)
@@ -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.gatein.wci.api;
+
+import org.gatein.wci.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 BootstrapServlet 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.instance.register(webAppContext);
+ this.contextPath = contextPath;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void destroy()
+ {
+ if (contextPath != null)
+ {
+ GenericServletContainerContext.instance.unregister(contextPath);
+ }
+ }
+}
\ No newline at end of file
Added:
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericServletContainerContext.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericServletContainerContext.java
(rev 0)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericServletContainerContext.java 2009-08-30
22:14:11 UTC (rev 136)
@@ -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.gatein.wci.api;
+
+import org.gatein.wci.RequestDispatchCallback;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.gatein.wci.spi.ServletContainerContext;
+import org.gatein.wci.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 $
+ */
+class GenericServletContainerContext implements ServletContainerContext
+{
+
+ /** . */
+ static final GenericServletContainerContext instance = new
GenericServletContainerContext();
+
+ /** . */
+ private Registration registration;
+
+ static
+ {
+ DefaultServletContainerFactory.registerContext(instance);
+ }
+
+ void register(GenericWebAppContext webAppContext)
+ {
+ if (registration != null)
+ {
+ registration.registerWebApp(webAppContext);
+ }
+ }
+
+ void unregister(String webAppId)
+ {
+ if (registration != null)
+ {
+ 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;
+ }
+}
\ No newline at end of file
Added:
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericWebAppContext.java
===================================================================
--- components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericWebAppContext.java
(rev 0)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/api/GenericWebAppContext.java 2009-08-30
22:14:11 UTC (rev 136)
@@ -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.gatein.wci.api;
+
+import org.gatein.wci.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 $
+ */
+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;
+ }
+}
\ No newline at end of file
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/command/CommandServlet.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/command/CommandServlet.java 2009-08-30
22:01:59 UTC (rev 135)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/command/CommandServlet.java 2009-08-30
22:14:11 UTC (rev 136)
@@ -75,7 +75,7 @@
try
{
localCmd.set(callback);
- RequestDispatcher switcher =
targetContext.getRequestDispatcher("/jbossportlet");
+ RequestDispatcher switcher =
targetContext.getRequestDispatcher("/gateinservlet");
switcher.include(request, response);
//
Modified:
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/tomcat/TC6WebAppContext.java
===================================================================
---
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/tomcat/TC6WebAppContext.java 2009-08-30
22:01:59 UTC (rev 135)
+++
components/wci/trunk/wci/src/main/java/org/gatein/wci/impl/tomcat/TC6WebAppContext.java 2009-08-30
22:14:11 UTC (rev 136)
@@ -75,11 +75,11 @@
try
{
commandServlet = context.createWrapper();
- commandServlet.setName("JBossServlet");
+ commandServlet.setName("GateInServlet");
commandServlet.setLoadOnStartup(0);
commandServlet.setServletClass(CommandServlet.class.getName());
context.addChild(commandServlet);
- context.addServletMapping("/jbossportlet", "JBossServlet");
+ context.addServletMapping("/gateinservlet",
"GateInServlet");
}
catch (Exception e)
{
@@ -99,7 +99,7 @@
{
try
{
- context.removeServletMapping("jbossportlet");
+ context.removeServletMapping("gateinservlet");
context.removeChild(commandServlet);
}
catch (Exception e)
Modified: components/wci/trunk/wci/src/test/resources/spi/generic/app-war/WEB-INF/web.xml
===================================================================
---
components/wci/trunk/wci/src/test/resources/spi/generic/app-war/WEB-INF/web.xml 2009-08-30
22:01:59 UTC (rev 135)
+++
components/wci/trunk/wci/src/test/resources/spi/generic/app-war/WEB-INF/web.xml 2009-08-30
22:14:11 UTC (rev 136)
@@ -28,11 +28,11 @@
<web-app>
<servlet>
<servlet-name>BootstrapServlet</servlet-name>
-
<servlet-class>org.gatein.wci.impl.generic.GenericBootstrapServlet</servlet-class>
+ <servlet-class>org.gatein.wci.api.BootstrapServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>BootstrapServlet</servlet-name>
- <url-pattern>/jbossportlet</url-pattern>
+ <url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
</web-app>
Modified:
components/wci/trunk/wci/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml
===================================================================
---
components/wci/trunk/wci/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml 2009-08-30
22:01:59 UTC (rev 135)
+++
components/wci/trunk/wci/src/test/resources/support/jboss-4.2-generic/server-war/WEB-INF/web.xml 2009-08-30
22:14:11 UTC (rev 136)
@@ -44,7 +44,7 @@
</servlet>
<servlet>
<servlet-name>BootstrapServlet</servlet-name>
-
<servlet-class>org.gatein.wci.impl.generic.GenericBootstrapServlet</servlet-class>
+ <servlet-class>org.gatein.wci.api.BootstrapServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
@@ -53,6 +53,6 @@
</servlet-mapping>
<servlet-mapping>
<servlet-name>BootstrapServlet</servlet-name>
- <url-pattern>/jbossportlet</url-pattern>
+ <url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
</web-app>
Modified:
components/wci/trunk/wci/src/test/resources/support/jboss-5.0-generic/server-war/WEB-INF/web.xml
===================================================================
---
components/wci/trunk/wci/src/test/resources/support/jboss-5.0-generic/server-war/WEB-INF/web.xml 2009-08-30
22:01:59 UTC (rev 135)
+++
components/wci/trunk/wci/src/test/resources/support/jboss-5.0-generic/server-war/WEB-INF/web.xml 2009-08-30
22:14:11 UTC (rev 136)
@@ -44,7 +44,7 @@
</servlet>
<servlet>
<servlet-name>BootstrapServlet</servlet-name>
-
<servlet-class>org.gatein.wci.impl.generic.PortletContainerBootstrapServlet</servlet-class>
+ <servlet-class>org.gatein.wci.api.BootstrapServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
@@ -53,6 +53,6 @@
</servlet-mapping>
<servlet-mapping>
<servlet-name>BootstrapServlet</servlet-name>
- <url-pattern>/jbossportlet</url-pattern>
+ <url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
</web-app>
Modified:
components/wci/trunk/wci/src/test/resources/support/jetty-6.1-generic/server-war/WEB-INF/web.xml
===================================================================
---
components/wci/trunk/wci/src/test/resources/support/jetty-6.1-generic/server-war/WEB-INF/web.xml 2009-08-30
22:01:59 UTC (rev 135)
+++
components/wci/trunk/wci/src/test/resources/support/jetty-6.1-generic/server-war/WEB-INF/web.xml 2009-08-30
22:14:11 UTC (rev 136)
@@ -44,7 +44,7 @@
</servlet>
<servlet>
<servlet-name>BootstrapServlet</servlet-name>
-
<servlet-class>org.gatein.wci.impl.generic.PortletContainerBootstrapServlet</servlet-class>
+ <servlet-class>org.gatein.wci.api.BootstrapServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
@@ -53,6 +53,6 @@
</servlet-mapping>
<servlet-mapping>
<servlet-name>BootstrapServlet</servlet-name>
- <url-pattern>/jbossportlet</url-pattern>
+ <url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
</web-app>
Modified:
components/wci/trunk/wci/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml
===================================================================
---
components/wci/trunk/wci/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml 2009-08-30
22:01:59 UTC (rev 135)
+++
components/wci/trunk/wci/src/test/resources/support/tomcat-6.0-generic/server-war/WEB-INF/web.xml 2009-08-30
22:14:11 UTC (rev 136)
@@ -44,7 +44,7 @@
</servlet>
<servlet>
<servlet-name>BootstrapServlet</servlet-name>
-
<servlet-class>org.gatein.wci.impl.generic.GenericBootstrapServlet</servlet-class>
+ <servlet-class>org.gatein.wci.api.BootstrapServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
@@ -53,6 +53,6 @@
</servlet-mapping>
<servlet-mapping>
<servlet-name>BootstrapServlet</servlet-name>
- <url-pattern>/jbossportlet</url-pattern>
+ <url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
</web-app>