JBoss Portal SVN: r10247 - in modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl: tomcat and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-09 12:04:41 -0400 (Sun, 09 Mar 2008)
New Revision: 10247
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java
Log:
make compile
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java 2008-03-09 15:56:34 UTC (rev 10246)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java 2008-03-09 16:04:41 UTC (rev 10247)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.web.impl;
-import org.jboss.logging.Logger;
import org.jboss.portal.web.spi.ServletContainerContext;
import org.jboss.portal.web.spi.WebAppContext;
import org.jboss.portal.web.WebAppListener;
@@ -33,6 +32,7 @@
import org.jboss.portal.web.ServletContainer;
import org.jboss.portal.web.WebExecutor;
import org.jboss.portal.common.NotYetImplemented;
+import org.apache.log4j.Logger;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
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-03-09 15:56:34 UTC (rev 10246)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/tomcat/TC6ServletContainerContext.java 2008-03-09 16:04:41 UTC (rev 10247)
@@ -31,12 +31,12 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
-import org.jboss.logging.Logger;
import org.jboss.portal.web.RequestDispatchCallback;
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 org.apache.log4j.Logger;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
16 years, 3 months
JBoss Portal SVN: r10246 - modules/web/trunk/build.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-09 11:56:34 -0400 (Sun, 09 Mar 2008)
New Revision: 10246
Modified:
modules/web/trunk/build/pom.xml
Log:
update web module to use common 1.2.0 snapshot
Modified: modules/web/trunk/build/pom.xml
===================================================================
--- modules/web/trunk/build/pom.xml 2008-03-09 15:49:26 UTC (rev 10245)
+++ modules/web/trunk/build/pom.xml 2008-03-09 15:56:34 UTC (rev 10246)
@@ -30,7 +30,7 @@
<version.apache.tomcat>5.5.12</version.apache.tomcat>
<version.jboss-logging>2.0.3.GA</version.jboss-logging>
<version.jboss-remoting>2.2.1.GA</version.jboss-remoting>
- <version.jboss.portal.common>1.2.0.Beta2</version.jboss.portal.common>
+ <version.jboss.portal.common>1.2.0-SNAPSHOT</version.jboss.portal.common>
<version.jboss.unit>1.2.0.Beta2</version.jboss.unit>
<version.log4j>1.2.14</version.log4j>
<version.apache.commons-logging>1.1.1</version.apache.commons-logging>
16 years, 3 months
JBoss Portal SVN: r10245 - in modules/common/trunk: common and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-09 11:49:26 -0400 (Sun, 09 Mar 2008)
New Revision: 10245
Modified:
modules/common/trunk/build/pom.xml
modules/common/trunk/common/pom.xml
Log:
remove common core and common system artifact usage
Modified: modules/common/trunk/build/pom.xml
===================================================================
--- modules/common/trunk/build/pom.xml 2008-03-08 22:07:26 UTC (rev 10244)
+++ modules/common/trunk/build/pom.xml 2008-03-09 15:49:26 UTC (rev 10245)
@@ -18,8 +18,6 @@
<version.javax.servlet>2.4</version.javax.servlet>
<version.jboss-j2ee>4.2.0.GA</version.jboss-j2ee>
<version.jboss-jmx>4.2.0.GA</version.jboss-jmx>
- <version.jboss-system>4.2.0.GA</version.jboss-system>
- <version.jboss-common-core>2.2.0.GA</version.jboss-common-core>
<version.log4j>1.2.14</version.log4j>
<version.apache.commons-httpclient>3.0.1</version.apache.commons-httpclient>
<version.jboss.microcontainer>2.0.0.Beta9</version.jboss.microcontainer>
@@ -81,12 +79,6 @@
</dependency>
<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>${version.jboss-common-core}</version>
- </dependency>
-
- <dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>${version.ant}</version>
@@ -99,12 +91,6 @@
</dependency>
<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-system</artifactId>
- <version>${version.jboss-system}</version>
- </dependency>
-
- <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>${version.apache.commons-httpclient}</version>
Modified: modules/common/trunk/common/pom.xml
===================================================================
--- modules/common/trunk/common/pom.xml 2008-03-08 22:07:26 UTC (rev 10244)
+++ modules/common/trunk/common/pom.xml 2008-03-09 15:49:26 UTC (rev 10245)
@@ -29,11 +29,6 @@
</dependency>
<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </dependency>
-
- <dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</dependency>
@@ -44,11 +39,6 @@
</dependency>
<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-system</artifactId>
- </dependency>
-
- <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
16 years, 3 months
JBoss Portal SVN: r10244 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/util.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-08 17:07:26 -0500 (Sat, 08 Mar 2008)
New Revision: 10244
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java
Log:
oups typo
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java 2008-03-08 22:05:47 UTC (rev 10243)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java 2008-03-08 22:07:26 UTC (rev 10244)
@@ -37,7 +37,7 @@
READ_COMMITED,
- READ_REPEATBLE,
+ READ_REPEATABLE,
SERIALIZABLE
16 years, 3 months
JBoss Portal SVN: r10243 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/util.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-08 17:05:47 -0500 (Sat, 08 Mar 2008)
New Revision: 10243
Added:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java
Log:
define a general purpose isolation level constant
Added: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java (rev 0)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/IsolationLevel.java 2008-03-08 22:05:47 UTC (rev 10243)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.common.util;
+
+/**
+ * A general purpose enum to represent an isolation level.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum IsolationLevel
+{
+
+ NONE,
+
+ READ_UNCOMMITED,
+
+ READ_COMMITED,
+
+ READ_REPEATBLE,
+
+ SERIALIZABLE
+
+}
16 years, 3 months
JBoss Portal SVN: r10242 - modules/web/trunk/web/src/main/java/org/jboss/portal/web.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-08 17:02:08 -0500 (Sat, 08 Mar 2008)
New Revision: 10242
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/RequestDispatchCallback.java
Log:
minor javadoc
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/RequestDispatchCallback.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/RequestDispatchCallback.java 2008-03-08 22:00:33 UTC (rev 10241)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/RequestDispatchCallback.java 2008-03-08 22:02:08 UTC (rev 10242)
@@ -43,6 +43,7 @@
* @param dispatchedRequest the dispatched request
* @param dispatchedResponse the dispatched response
* @param handback the handback object provided to the dispatched @return any object
+ * @return any object
* @throws ServletException if an exception occurs that interferes with the normal operation
* @throws IOException if an input or output exception occurs
*/
16 years, 3 months
JBoss Portal SVN: r10241 - in modules/web/trunk/web/src/main/java/org/jboss/portal/web: impl and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-08 17:00:33 -0500 (Sat, 08 Mar 2008)
New Revision: 10241
Added:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebExecutor.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRunnable.java
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java
Log:
- some basics to define an executor service for web requests.
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java 2008-03-08 19:18:46 UTC (rev 10240)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java 2008-03-08 22:00:33 UTC (rev 10241)
@@ -37,11 +37,32 @@
public interface ServletContainer
{
+ /**
+ * Add a web listener.
+ *
+ * @param listener the listener
+ * @return true if the listener has been added
+ */
boolean addWebAppListener(WebAppListener listener);
+ /**
+ * Removes a web listener.
+ *
+ * @param listener the listener
+ * @return true if the listener has been removed
+ */
boolean removeWebAppListener(WebAppListener listener);
/**
+ * Returns an executor that will use the provided request and response.
+ *
+ * @param request the request
+ * @param response the response
+ * @return an executor
+ */
+ WebExecutor getExecutor(HttpServletRequest request, HttpServletResponse response);
+
+ /**
* Generic detyped request dispatch to a servlet context using the include mechanism.
*
* @param targetServletContext the target servlet context to dispatch to
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebExecutor.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebExecutor.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebExecutor.java 2008-03-08 22:00:33 UTC (rev 10241)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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;
+
+/**
+ * An executor for web runnable tasks.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface WebExecutor
+{
+
+ /**
+ * Execute a web runnable.
+ *
+ * @param runnable the web runnable
+ */
+ void execute(WebRunnable runnable);
+}
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRunnable.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRunnable.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRunnable.java 2008-03-08 22:00:33 UTC (rev 10241)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Defines a web runnable.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface WebRunnable
+{
+ /**
+ * Executes the runnable task with the provided request and reponse.
+ *
+ * @param request the request
+ * @param response the response
+ */
+ void run(HttpServletRequest request, HttpServletResponse response);
+}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java 2008-03-08 19:18:46 UTC (rev 10240)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java 2008-03-08 22:00:33 UTC (rev 10241)
@@ -31,6 +31,8 @@
import org.jboss.portal.web.WebAppEvent;
import org.jboss.portal.web.RequestDispatchCallback;
import org.jboss.portal.web.ServletContainer;
+import org.jboss.portal.web.WebExecutor;
+import org.jboss.portal.common.NotYetImplemented;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -92,6 +94,11 @@
}
}
+ public WebExecutor getExecutor(HttpServletRequest request, HttpServletResponse response)
+ {
+ throw new NotYetImplemented();
+ }
+
public boolean addWebAppListener(WebAppListener listener)
{
synchronized (lock)
16 years, 3 months
JBoss Portal SVN: r10240 - in modules/web/trunk/web/src: main/java/org/jboss/portal/web/impl and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-08 14:18:46 -0500 (Sat, 08 Mar 2008)
New Revision: 10240
Added:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContextDispatcher.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainerFactory.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/spi/ServletContainerContext.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/container/ServletContainerTestCase.java
Log:
make ServletContainer an interface
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java 2008-03-07 18:11:53 UTC (rev 10239)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContainer.java 2008-03-08 19:18:46 UTC (rev 10240)
@@ -22,20 +22,11 @@
******************************************************************************/
package org.jboss.portal.web;
-import org.jboss.logging.Logger;
-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.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
/**
* A static registry for the servlet container context.
@@ -43,306 +34,29 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class ServletContainer
+public interface ServletContainer
{
- private final static Logger log = Logger.getLogger(ServletContainer.class);
- /** . */
- private final Object lock = new Object();
+ boolean addWebAppListener(WebAppListener listener);
- /** The event listeners. */
- private final ArrayList listeners = new ArrayList();
+ boolean removeWebAppListener(WebAppListener listener);
- /** 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
- * @throws IllegalArgumentException if the context is null
- */
- public void register(ServletContainerContext context)
- {
- synchronized (lock)
- {
- 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);
- }
- }
- }
-
- public boolean addWebAppListener(WebAppListener listener)
- {
- synchronized (lock)
- {
- 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;
- }
- }
-
- public boolean removeWebAppListener(WebAppListener listener)
- {
- synchronized (lock)
- {
- 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);
- }
- }
-
- /**
* Generic detyped request dispatch to a servlet context using the include mechanism.
*
* @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
+ * @param handback the handback object that will be provided to the callback
+ * @return the object returned by the callback
+ * @throws ServletException any servlet exception
+ * @throws IOException any io exception
*/
public Object include(
- ServletContext targetServletContext, HttpServletRequest request,
+ ServletContext targetServletContext,
+ HttpServletRequest request,
HttpServletResponse response,
RequestDispatchCallback callback,
- Object handback) throws ServletException, IOException
- {
- 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))
- {
- log.debug("Web application " + key + " is already registered");
- return false;
- }
- else
- {
- try
- {
- log.debug("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)
- {
- log.debug("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)
- {
- log.debug("Web application " + webAppId + " cleanup");
- container.fireEvent(new WebAppLifeCycleEvent(webApp, WebAppLifeCycleEvent.REMOVED));
- webApp.context.stop();
- return true;
- }
- else
- {
- log.debug("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);
- }
- }
+ Object handback) throws ServletException, IOException;
}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContextDispatcher.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContextDispatcher.java 2008-03-07 18:11:53 UTC (rev 10239)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/ServletContextDispatcher.java 2008-03-08 19:18:46 UTC (rev 10240)
@@ -30,7 +30,7 @@
/**
* 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
+ * pass it as an argment to a framework that needs a dispatcher to just a
* servlet context and does not care about the underlying spi or request/response.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -50,6 +50,20 @@
public ServletContextDispatcher(HttpServletRequest request, HttpServletResponse response, ServletContainer servletContainer)
{
+ if (request == null)
+ {
+ throw new IllegalArgumentException("No null request allowed");
+ }
+ if (response == null)
+ {
+ throw new IllegalArgumentException("No null response allowed");
+ }
+ if (servletContainer == null)
+ {
+ throw new IllegalArgumentException("No null servlet container allowed");
+ }
+
+ //
this.request = request;
this.response = response;
this.servletContainer = servletContainer;
@@ -72,5 +86,4 @@
{
return servletContainer.include(targetServletContext, request, response, callback, handback);
}
-
}
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainer.java 2008-03-08 19:18:46 UTC (rev 10240)
@@ -0,0 +1,353 @@
+/******************************************************************************
+ * 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.logging.Logger;
+import org.jboss.portal.web.spi.ServletContainerContext;
+import org.jboss.portal.web.spi.WebAppContext;
+import org.jboss.portal.web.WebAppListener;
+import org.jboss.portal.web.WebApp;
+import org.jboss.portal.web.WebAppLifeCycleEvent;
+import org.jboss.portal.web.WebAppEvent;
+import org.jboss.portal.web.RequestDispatchCallback;
+import org.jboss.portal.web.ServletContainer;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A static registry for the servlet container context.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultServletContainer implements ServletContainer
+{
+ private final static Logger log = Logger.getLogger(ServletContainer.class);
+
+ /** . */
+ private final Object lock = new Object();
+
+ /** The event listeners. */
+ private final ArrayList<WebAppListener> listeners = new ArrayList<WebAppListener>();
+
+ /** The web applications. */
+ private final Map<String, WebAppImpl> webAppMap = new HashMap<String, WebAppImpl>();
+
+ /** 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
+ * @throws IllegalArgumentException if the context is null
+ */
+ public void register(ServletContainerContext context)
+ {
+ synchronized (lock)
+ {
+ 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);
+ }
+ }
+ }
+
+ public boolean addWebAppListener(WebAppListener listener)
+ {
+ synchronized (lock)
+ {
+ if (listener == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (listeners.contains(listener))
+ {
+ return false;
+ }
+ listeners.add(listener);
+ for (Object response : webAppMap.values())
+ {
+ WebApp webApp = (WebApp)response;
+ WebAppLifeCycleEvent event = new WebAppLifeCycleEvent(webApp, WebAppLifeCycleEvent.ADDED);
+ safeFireEvent(listener, event);
+ }
+ return true;
+ }
+ }
+
+ public boolean removeWebAppListener(WebAppListener listener)
+ {
+ synchronized (lock)
+ {
+ if (listener == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (listeners.remove(listener))
+ {
+ for (WebApp webApp : webAppMap.values())
+ {
+ 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 (WebAppListener listener : listeners)
+ {
+ safeFireEvent(listener, event);
+ }
+ }
+
+ /**
+ * Generic detyped request dispatch to a servlet context using the include mechanism.
+ *
+ * @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 that will be provided to the callback
+ * @return the object returned by the callback
+ * @throws javax.servlet.ServletException any servlet exception
+ * @throws java.io.IOException any io exception
+ */
+ public Object include(
+ ServletContext targetServletContext,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ RequestDispatchCallback callback,
+ Object handback) throws ServletException, IOException
+ {
+ 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 DefaultServletContainer container;
+
+ /** . */
+ private ServletContainerContext context;
+
+ public RegistrationImpl(DefaultServletContainer 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))
+ {
+ log.debug("Web application " + key + " is already registered");
+ return false;
+ }
+ else
+ {
+ try
+ {
+ log.debug("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)
+ {
+ log.debug("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 = container.webAppMap.remove(webAppId);
+ if (webApp != null)
+ {
+ log.debug("Web application " + webAppId + " cleanup");
+ container.fireEvent(new WebAppLifeCycleEvent(webApp, WebAppLifeCycleEvent.REMOVED));
+ webApp.context.stop();
+ return true;
+ }
+ else
+ {
+ log.debug("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 (WebApp webApp : container.webAppMap.values())
+ {
+ 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);
+ }
+ }
+}
\ No newline at end of file
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainerFactory.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainerFactory.java 2008-03-07 18:11:53 UTC (rev 10239)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/DefaultServletContainerFactory.java 2008-03-08 19:18:46 UTC (rev 10240)
@@ -42,7 +42,7 @@
}
/** . */
- private final ServletContainer container = new ServletContainer();
+ private final DefaultServletContainer container = new DefaultServletContainer();
/**
* Returns the singleton instance.
@@ -55,7 +55,11 @@
}
/**
- * Register the context argument on the singleton instance.
+ * Registers 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
+ * @throws IllegalArgumentException if the context is null
*/
public static void registerContext(ServletContainerContext context) throws IllegalArgumentException
{
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/spi/ServletContainerContext.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/spi/ServletContainerContext.java 2008-03-07 18:11:53 UTC (rev 10239)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/spi/ServletContainerContext.java 2008-03-08 19:18:46 UTC (rev 10240)
@@ -48,9 +48,10 @@
* @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
+ * @param handback the handback object that will be provided to the callback
+ * @return the object returned by the callback
+ * @throws ServletException any servlet exception
+ * @throws IOException any io exception
*/
Object include(
ServletContext targetServletContext, HttpServletRequest request,
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/container/ServletContainerTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/container/ServletContainerTestCase.java 2008-03-07 18:11:53 UTC (rev 10239)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/container/ServletContainerTestCase.java 2008-03-08 19:18:46 UTC (rev 10240)
@@ -22,11 +22,10 @@
******************************************************************************/
package org.jboss.portal.test.web.container;
-import org.jboss.portal.web.ServletContainer;
import org.jboss.portal.web.WebAppListener;
import org.jboss.portal.web.WebAppEvent;
+import org.jboss.portal.web.impl.DefaultServletContainer;
import org.jboss.portal.web.spi.ServletContainerContext;
-import org.jboss.portal.common.util.CollectionBuilder;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.test.web.WebAppRegistry;
import org.jboss.unit.api.pojo.annotations.Test;
@@ -45,7 +44,7 @@
@Test
public void testContextRegistrationLifeCycle()
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
ServletContainerContextImpl scc = new ServletContainerContextImpl();
//
@@ -69,7 +68,7 @@
registration.registerWebApp(new WebAppContextImpl("/foo"));
fail("Was expecting an ISE");
}
- catch (IllegalStateException e)
+ catch (IllegalStateException ignore)
{
}
try
@@ -77,7 +76,7 @@
registration.unregisterWebApp("/blah");
fail("Was expecting an ISE");
}
- catch (IllegalStateException e)
+ catch (IllegalStateException ignore)
{
}
try
@@ -85,7 +84,7 @@
registration.cancel();
fail("Was expecting an ISE");
}
- catch (IllegalStateException e)
+ catch (IllegalStateException ignore)
{
}
}
@@ -93,7 +92,7 @@
@Test
public void testConcurrentContextRegistrations()
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
ServletContainerContextImpl scc1 = new ServletContainerContextImpl();
ServletContainerContextImpl scc2 = new ServletContainerContextImpl();
@@ -122,7 +121,7 @@
@Test
public void testContextRegistrationCancellationUnregistersWebApps()
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
ServletContainerContextImpl scc = new ServletContainerContextImpl();
WebAppRegistry registry = new WebAppRegistry();
@@ -135,17 +134,17 @@
//
scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
scc.registration.registerWebApp(new WebAppContextImpl("/bar"));
- assertEquals(Tools.toSet(new String[]{"/foo", "/bar"}), registry.getKeys());
+ assertEquals(Tools.toSet("/foo", "/bar"), registry.getKeys());
//
scc.registration.cancel();
- assertEquals(Tools.toSet(new String[]{}), registry.getKeys());
+ assertEquals(Tools.toSet(), registry.getKeys());
}
@Test
public void testListenerDoubleRegistration()
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
ServletContainerContextImpl scc = new ServletContainerContextImpl();
WebAppRegistry registry = new WebAppRegistry();
@@ -156,25 +155,25 @@
//
container.register(scc);
scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
- assertEquals(Tools.toSet(new String[]{"/foo"}), registry.getKeys());
+ assertEquals(Tools.toSet("/foo"), registry.getKeys());
//
container.addWebAppListener(registry);
- assertEquals(Tools.toSet(new String[]{"/foo"}), registry.getKeys());
+ assertEquals(Tools.toSet("/foo"), registry.getKeys());
//
container.removeWebAppListener(registry);
- assertEquals(Tools.toSet(new String[]{}), registry.getKeys());
+ assertEquals(Tools.toSet(), registry.getKeys());
//
container.removeWebAppListener(registry);
- assertEquals(Tools.toSet(new String[]{}), registry.getKeys());
+ assertEquals(Tools.toSet(), registry.getKeys());
}
@Test
public void testListenerIsNotified()
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
ServletContainerContextImpl scc = new ServletContainerContextImpl();
WebAppRegistry registry = new WebAppRegistry();
@@ -189,43 +188,43 @@
container.addWebAppListener(registry);
// Assert we received events during the registration
- assertEquals(Tools.toSet(new String[]{"/foo", "/bar"}), registry.getKeys());
+ assertEquals(Tools.toSet("/foo", "/bar"), registry.getKeys());
// Add a new web app
scc.registration.registerWebApp(new WebAppContextImpl("/juu"));
// Assert we now have 3 web apps
- assertEquals(Tools.toSet(new String[]{"/foo", "/bar", "/juu"}), registry.getKeys());
+ assertEquals(Tools.toSet("/foo", "/bar", "/juu"), registry.getKeys());
// Remove one web app
scc.registration.unregisterWebApp("/foo");
// Assert we have 2 web apps
- assertEquals(Tools.toSet(new String[]{"/bar", "/juu"}), registry.getKeys());
+ assertEquals(Tools.toSet("/bar", "/juu"), registry.getKeys());
// Remove registration
container.removeWebAppListener(registry);
// Assert we receveived events during removal
- assertEquals(Tools.toSet(new String[]{}), registry.getKeys());
+ assertEquals(Tools.toSet(), 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(Tools.toSet(new String[]{}), registry.getKeys());
+ assertEquals(Tools.toSet(), registry.getKeys());
}
@Test
public void testServletContainerThrowsIAE()
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
try
{
container.register(null);
fail("Was expecting an IAE");
}
- catch (IllegalArgumentException expected)
+ catch (IllegalArgumentException ignore)
{
}
try
@@ -233,7 +232,7 @@
container.addWebAppListener(null);
fail("Was expecting an IAE");
}
- catch (IllegalArgumentException expected)
+ catch (IllegalArgumentException ignore)
{
}
try
@@ -241,7 +240,7 @@
container.removeWebAppListener(null);
fail("Was expecting an IAE");
}
- catch (IllegalArgumentException expected)
+ catch (IllegalArgumentException ignore)
{
}
}
@@ -249,13 +248,13 @@
@Test
public void testServletContainerThrowsISE() throws Exception
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
try
{
container.include(null, null, null, null, null);
fail("Was expecting an ISE");
}
- catch (IllegalStateException expected)
+ catch (IllegalStateException ignore)
{
}
}
@@ -263,7 +262,7 @@
@Test
public void testListenerFailure()
{
- ServletContainer container = new ServletContainer();
+ DefaultServletContainer container = new DefaultServletContainer();
ServletContainerContextImpl scc = new ServletContainerContextImpl();
WebAppRegistry registry = new WebAppRegistry();
@@ -283,6 +282,6 @@
//
scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
assertTrue(called.get());
- assertEquals(Tools.toSet(new String[]{"/foo"}), registry.getKeys());
+ assertEquals(Tools.toSet("/foo"), registry.getKeys());
}
}
16 years, 3 months
JBoss Portal SVN: r10239 - in modules/portlet/trunk/controller/src: test/java/org/jboss/portal/portlet/controller and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-07 13:11:53 -0500 (Fri, 07 Mar 2008)
New Revision: 10239
Added:
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/WiringEventControllerContext.java
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/EventControllerContextSafeInvoker.java
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java
Log:
no compile fix
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/EventControllerContextSafeInvoker.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/EventControllerContextSafeInvoker.java 2008-03-07 14:32:43 UTC (rev 10238)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/EventControllerContextSafeInvoker.java 2008-03-07 18:11:53 UTC (rev 10239)
@@ -40,11 +40,11 @@
/** . */
private final Logger log = Logger.getLogger(EventControllerContextSafeInvoker.class);
- public boolean eventProduced(EventControllerContext context, EventPhaseContext context, Event sourceEvent, Event producedEvent)
+ public boolean eventProduced(EventControllerContext controllerContext, EventPhaseContext phaseContext, Event sourceEvent, Event producedEvent)
{
try
{
- context.eventProduced(session, sourceEvent, producedEvent);
+ controllerContext.eventProduced(phaseContext, sourceEvent, producedEvent);
//
return true;
@@ -59,11 +59,11 @@
}
}
- public boolean eventConsumed(EventControllerContext context, EventPhaseContext context, Event consumedEvent, PortletInvocationResponse consumerResponse)
+ public boolean eventConsumed(EventControllerContext controllerContext, EventPhaseContext phaseContext, Event consumedEvent, PortletInvocationResponse consumerResponse)
{
try
{
- context.eventConsumed(session, consumedEvent, consumerResponse);
+ controllerContext.eventConsumed(phaseContext, consumedEvent, consumerResponse);
//
return true;
@@ -77,11 +77,11 @@
}
}
- public boolean eventFailed(EventControllerContext context, EventPhaseContext context, Event failedEvent, Throwable throwable)
+ public boolean eventFailed(EventControllerContext controllerContext, EventPhaseContext phaseContext, Event failedEvent, Throwable throwable)
{
try
{
- context.eventFailed(session, failedEvent, throwable);
+ controllerContext.eventFailed(phaseContext, failedEvent, throwable);
//
return true;
@@ -95,11 +95,11 @@
}
}
- public boolean eventDiscarded(EventControllerContext context, EventPhaseContext context, Event discardedEvent, int cause)
+ public boolean eventDiscarded(EventControllerContext controllerContext, EventPhaseContext phaseContext, Event discardedEvent, int cause)
{
try
{
- context.eventDiscarded(session, discardedEvent, cause);
+ controllerContext.eventDiscarded(phaseContext, discardedEvent, cause);
//
return true;
Modified: modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java
===================================================================
--- modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java 2008-03-07 14:32:43 UTC (rev 10238)
+++ modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java 2008-03-07 18:11:53 UTC (rev 10239)
@@ -65,7 +65,7 @@
PortletControllerContextSupport context = new PortletControllerContextSupport();
/** . */
- EventControllerContextSupport eventControllerContext = new EventControllerContextSupport();
+ WiringEventControllerContext eventControllerContext = new WiringEventControllerContext();
/** . */
PortletInvokerSupport invoker = context.getInvoker();
Copied: modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/WiringEventControllerContext.java (from rev 10237, modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/EventControllerContextSupport.java)
===================================================================
--- modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/WiringEventControllerContext.java (rev 0)
+++ modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/WiringEventControllerContext.java 2008-03-07 18:11:53 UTC (rev 10239)
@@ -0,0 +1,208 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.portlet.controller;
+
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.event.Event;
+import org.jboss.portal.portlet.controller.event.EventPhaseContext;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+
+import static org.jboss.unit.api.Assert.*;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class WiringEventControllerContext implements EventControllerContext
+{
+
+ /** . */
+ private final Map<Coordinate, List<Coordinate>> wires = new HashMap<Coordinate, List<Coordinate>>();
+
+ /** . */
+ private final List<EventCallback> callbacks = new LinkedList<EventCallback>();
+
+ public void eventProduced(EventPhaseContext context, Event sourceEvent, Event producedEvent)
+ {
+ List<Coordinate> dsts = wires.get(new Coordinate(producedEvent.getName(), producedEvent.getWindowId()));
+
+ //
+ if (dsts != null)
+ {
+ for (Coordinate dst : dsts)
+ {
+ context.queueEvent(new Event(dst.name, producedEvent.getPayload(), dst.windowId));
+ }
+ }
+ }
+
+ public void eventConsumed(EventPhaseContext context, Event consumedEvent, PortletInvocationResponse consumerResponse)
+ {
+ callbacks.add(new EventCallback(EventCallback.EVENT_CONSUMED, consumedEvent, consumerResponse));
+ }
+
+ public void eventFailed(EventPhaseContext context, Event failedEvent, Throwable throwable)
+ {
+ callbacks.add(new EventCallback(EventCallback.EVENT_FAILED, failedEvent, throwable));
+ }
+
+ public void eventDiscarded(EventPhaseContext context, Event discardedEvent, int cause)
+ {
+ callbacks.add(new EventCallback(EventCallback.EVENT_DISCARDED, discardedEvent, cause));
+ }
+
+ public void createWire(QName srcName, String srcWindowId, QName dstName, String dstWindowId)
+ {
+ Coordinate src = new Coordinate(srcName, srcWindowId);
+
+ //
+ List<Coordinate> dsts = wires.get(src);
+
+ //
+ if (dsts == null)
+ {
+ dsts = new ArrayList<Coordinate>();
+ wires.put(src, dsts);
+ }
+
+ //
+ Coordinate dst = new Coordinate(dstName, dstWindowId);
+
+ if (dsts.contains(dst))
+ {
+ throw new IllegalStateException("Such a wire already exists");
+ }
+
+ //
+ dsts.add(dst);
+ }
+
+ public static class EventCallback
+ {
+
+ /** . */
+ public static final int EVENT_CONSUMED = 0;
+
+ /** . */
+ public static final int EVENT_FAILED = 1;
+
+ /** . */
+ public static final int EVENT_DISCARDED = 2;
+
+ /** . */
+ private final int type;
+
+ /** . */
+ private final Event event;
+
+ /** . */
+ private final Object data;
+
+ private EventCallback(int type, Event event, Object data)
+ {
+ this.type = type;
+ this.event = event;
+ this.data = data;
+ }
+
+ public int getType()
+ {
+ return type;
+ }
+
+ public Event getEvent()
+ {
+ return event;
+ }
+
+ public PortletInvocationResponse assertConsumed()
+ {
+ assertEquals(EVENT_CONSUMED, type);
+ return (PortletInvocationResponse)data;
+ }
+
+ public Throwable assertFailed()
+ {
+ assertEquals(EVENT_FAILED, type);
+ return (Throwable)data;
+ }
+
+ public int assertDiscarded()
+ {
+ assertEquals(EVENT_DISCARDED, type);
+ return (Integer)data;
+ }
+ }
+
+ private static class Coordinate
+ {
+
+ /** . */
+ final QName name;
+
+ /** . */
+ final String windowId;
+
+ private Coordinate(QName name, String windowId)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (windowId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.name = name;
+ this.windowId = windowId;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof Coordinate)
+ {
+ Coordinate that = (Coordinate)obj;
+ return name.equals(that.name) && windowId.equals(that.windowId);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode() + windowId.hashCode();
+ }
+ }
+}
16 years, 3 months
JBoss Portal SVN: r10238 - branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands.
by portal-commits@lists.jboss.org
Author: mmillson
Date: 2008-03-07 09:32:43 -0500 (Fri, 07 Mar 2008)
New Revision: 10238
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java
Log:
Test case for [JBPORTAL-1872].
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java 2008-03-07 12:50:04 UTC (rev 10237)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java 2008-03-07 14:32:43 UTC (rev 10238)
@@ -84,6 +84,7 @@
assertEquals("Language Incorrect", content.getLocale().getLanguage(), "en");
assertEquals("Title Incorrect", content.getTitle(), "English Title");
assertEquals("Desc Incorrect", content.getDescription(), "English Description");
+ assertNotNull("Last Modified Date Missing", content.getLastModified());
}
/**
16 years, 3 months