Author: mstruk
Date: 2012-02-27 05:00:47 -0500 (Mon, 27 Feb 2012)
New Revision: 8470
Modified:
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/pom.xml
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7ServletContainerContext.java
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7WebAppContext.java
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
Log:
Bring AS7 support up to date with wci changes
Modified: sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/pom.xml
===================================================================
--- sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/pom.xml 2012-02-27 04:36:23
UTC (rev 8469)
+++ sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/pom.xml 2012-02-27 10:00:47
UTC (rev 8470)
@@ -2,8 +2,9 @@
<parent>
<groupId>org.gatein.wci</groupId>
<artifactId>wci-jboss</artifactId>
- <version>2.1.0-Beta07-AS7-Beta02</version>
+ <version>2.1.1-Beta03-AS7-Beta03</version>
</parent>
+
<modelVersion>4.0.0</modelVersion>
<artifactId>wci-jboss7</artifactId>
<packaging>jar</packaging>
@@ -17,7 +18,7 @@
<dependency>
<groupId>org.jboss.web</groupId>
<artifactId>jbossweb</artifactId>
- <version>7.0.1.Final</version>
+ <version>7.0.10.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
Modified:
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7ServletContainerContext.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7ServletContainerContext.java 2012-02-27
04:36:23 UTC (rev 8469)
+++
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7ServletContainerContext.java 2012-02-27
10:00:47 UTC (rev 8470)
@@ -37,12 +37,15 @@
import org.gatein.wci.RequestDispatchCallback;
import org.gatein.wci.ServletContainerVisitor;
import org.gatein.wci.WebApp;
+import org.gatein.wci.api.GateInServlet;
+import org.gatein.wci.api.GateInServletRegistrations;
import org.gatein.wci.authentication.GenericAuthentication;
import org.gatein.wci.authentication.TicketService;
import org.gatein.wci.command.CommandDispatcher;
import org.gatein.wci.impl.DefaultServletContainerFactory;
import org.gatein.wci.security.Credentials;
import org.gatein.wci.spi.ServletContainerContext;
+import org.gatein.wci.spi.WebAppContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -50,7 +53,9 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
/**
@@ -71,6 +76,9 @@
/** The monitored contexts. */
private final Set<String> monitoredContexts = new HashSet<String>();
+ /** The monitored contexts which were manually added. */
+ private static Map<String, String> manualMonitoredContexts = new
HashMap<String, String>();
+
/** . */
private final Engine engine;
@@ -91,13 +99,23 @@
public Object include(ServletContext targetServletContext, HttpServletRequest request,
HttpServletResponse response,
RequestDispatchCallback callback, Object handback) throws ServletException,
IOException
- {
- return dispatcher.include(targetServletContext, request, response, callback,
handback);
- }
+ {
+ if
(manualMonitoredContexts.containsKey(targetServletContext.getServletContextName()))
+ {
+ String dispatherPath =
manualMonitoredContexts.get(targetServletContext.getServletContextName());
+ CommandDispatcher dispatcher = new CommandDispatcher(dispatherPath);
+ return dispatcher.include(targetServletContext, request, response, callback,
handback);
+ }
+ else
+ {
+ return dispatcher.include(targetServletContext, request, response, callback,
handback);
+ }
+ }
public void setCallback(Registration registration)
{
this.registration = registration;
+ GateInServletRegistrations.setServletContainerContext(this);
}
public void unsetCallback(Registration registration)
@@ -351,13 +369,19 @@
{
log.debug("Context added " + context.getPath());
+ // skip if the webapp has explicitly stated it doesn't want native
registration
+ // usefull when portlets are dependent on servlet ordering
+ if (isDisabledNativeRegistration(context.getServletContext()))
+ return;
+
// we need to preemptively synchronize on context to prevent deadlocks from
// opposite order locking on jboss-as7
synchronized(context)
{
+ // skip if the webapp has explicitly stated it doesn't want native
registration
+ // usefull when portlets are dependent on servlet ordering
JB7WebAppContext webAppContext = new JB7WebAppContext(context);
- //
if (registration != null)
{
registration.registerWebApp(webAppContext);
@@ -374,6 +398,11 @@
{
try
{
+ // skip if the webapp has explicitly stated it doesn't want native
registration
+ // usefull when portlets are dependent on servlet ordering
+ if (isDisabledNativeRegistration(context.getServletContext()))
+ return;
+
// we need to preemptively synchronize on context to prevent deadlocks from
// opposite order locking on jboss-as7
synchronized(context)
@@ -389,5 +418,49 @@
e.printStackTrace();
}
}
+
+ private boolean isDisabledNativeRegistration(ServletContext servletContext)
+ {
+ if (servletContext != null)
+ {
+ String disableWCINativeRegistration =
servletContext.getInitParameter(GateInServlet.WCIDISABLENATIVEREGISTRATION);
+ if (disableWCINativeRegistration != null &&
disableWCINativeRegistration.equalsIgnoreCase("true"))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public void registerWebApp(WebAppContext webappContext, String dispatchPath)
+ {
+ if (isDisabledNativeRegistration(webappContext.getServletContext()))
+ {
+
this.manualMonitoredContexts.put(webappContext.getServletContext().getServletContextName(),
dispatchPath);
+ registration.registerWebApp(webappContext);
+ }
+ }
+
+ @Override
+ public void unregisterWebApp(ServletContext servletContext)
+ {
+ if (isDisabledNativeRegistration(servletContext))
+ {
+ this.manualMonitoredContexts.remove(servletContext.getServletContextName());
+ //if the registration is null, then this ServletContainerContext has been stopped
already
+ //and all the registrations have already been removed.
+ if (registration != null)
+ {
+ registration.unregisterWebApp(servletContext.getContextPath());
+ }
+ }
+ }
}
-
Modified:
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7WebAppContext.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7WebAppContext.java 2012-02-27
04:36:23 UTC (rev 8469)
+++
sandbox/as7_support/branches/gatein-as7/wci/jboss/jboss7/src/main/java/org/gatein/wci/jboss/JB7WebAppContext.java 2012-02-27
10:00:47 UTC (rev 8470)
@@ -92,7 +92,7 @@
private void cleanup()
{
- // This code can cause deadlocks on .war undeploy when container performs multiple
such operations concurrently
+ // This code might cause deadlocks on .war undeploy when container performs
multiple such operations concurrently
// as for example when JBoss AS7 is shutting down.
if (commandServlet != null)
@@ -150,4 +150,3 @@
return false;
}
}
-
Modified:
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2012-02-27
04:36:23 UTC (rev 8469)
+++
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2012-02-27
10:00:47 UTC (rev 8470)
@@ -354,27 +354,37 @@
{
throw new IllegalStateException("Disposed registration");
}
- synchronized (container.lock)
+
+ if (webAppId == null)
{
- if (webAppId == null)
- {
- throw new IllegalArgumentException("No null web app id
accepted");
- }
+ throw new IllegalArgumentException("No null web app id accepted");
+ }
- //
- WebAppImpl webApp = container.webAppMap.remove(webAppId);
- if (webApp != null)
+ WebAppImpl webApp = container.webAppMap.get(webAppId);
+ if (webApp == null)
+ {
+ log.debug("Web application " + webAppId + " was not
registered");
+ return false;
+ }
+ // lock context before locking container to prevent deadlocks
+ synchronized (webApp.context)
+ {
+ synchronized (container.lock)
{
- log.debug("Web application " + webAppId + "
cleanup");
- container.fireEvent(new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED));
- webApp.context.stop();
- return true;
+ 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;
+ }
}
- else
- {
- log.debug("Web application " + webAppId + " was not
registered");
- return false;
- }
}
}
Modified:
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
===================================================================
---
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2012-02-27
04:36:23 UTC (rev 8469)
+++
sandbox/as7_support/branches/gatein-as7/wci/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2012-02-27
10:00:47 UTC (rev 8470)
@@ -43,126 +43,126 @@
*/
public interface ServletContainerContext
{
- /**
- * 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 ServletException any servlet exception
- * @throws IOException any io exception
- */
- Object include(
- ServletContext targetServletContext, HttpServletRequest request,
- HttpServletResponse response,
- RequestDispatchCallback callback,
- Object handback) throws ServletException, IOException;
+ /**
+ * 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 ServletException any servlet exception
+ * @throws IOException any io exception
+ */
+ Object include(
+ ServletContext targetServletContext, HttpServletRequest request,
+ HttpServletResponse response,
+ RequestDispatchCallback callback,
+ Object handback) throws ServletException, IOException;
- /**
- * Install the call back object.
- *
- * @param registration the call back
- */
- void setCallback(Registration registration);
+ /**
+ * Install the call back object.
+ *
+ * @param registration the call back
+ */
+ void setCallback(Registration registration);
- /**
- * Uninstall the call back object.
- *
- * @param registration the call back
- */
- void unsetCallback(Registration registration);
+ /**
+ * Uninstall the call back object.
+ *
+ * @param registration the call back
+ */
+ void unsetCallback(Registration registration);
- /**
- * Manually register a webapp with this ServletContainerContext.
- *
- * @param webappContext the WebAppContext associated with the application
- * @param dispathPath the path to be used
- */
- void registerWebApp(WebAppContext webappContext, String dispatchPath);
+ /**
+ * Manually register a webapp with this ServletContainerContext.
+ *
+ * @param webappContext the WebAppContext associated with the application
+ * @param dispathPath the path to be used
+ */
+ void registerWebApp(WebAppContext webappContext, String dispatchPath);
- /**
- * Manually unregister a webapp associated with this ServletContainerContext.
- *
- * @param servletContext the servletContext of the application to be deregistered
- */
- void unregisterWebApp(ServletContext servletContext);
+ /**
+ * Manually unregister a webapp associated with this ServletContainerContext.
+ *
+ * @param servletContext the servletContext of the application to be deregistered
+ */
+ void unregisterWebApp(ServletContext servletContext);
- /**
- * Authentication support.
- *
- * @param request the request valid in the current servlet context
- * @param response the response valid in the current servlet context
- * @param credentials the credentials which try to authenticate
- * @param validityMillis the validity of the authentication
- */
- void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis) throws ServletException, IOException;
+ /**
+ * Authentication support.
+ *
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ * @param credentials the credentials which try to authenticate
+ * @param validityMillis the validity of the authentication
+ */
+ void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis) throws ServletException, IOException;
- /**
- * Authentication support.
- *
- * @param request the request valid in the current servlet context
- * @param response the response valid in the current servlet context
- * @param credentials the credentials which try to authenticate
- * @param validityMillis the validity of the authentication
- */
- void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis, String initialURI) throws ServletException,
IOException;
+ /**
+ * Authentication support.
+ *
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ * @param credentials the credentials which try to authenticate
+ * @param validityMillis the validity of the authentication
+ */
+ void login(HttpServletRequest request, HttpServletResponse response, Credentials
credentials, long validityMillis, String initialURI) throws ServletException,
IOException;
- /**
- * Authentication support.
- *
- * @param request the request valid in the current servlet context
- * @param response the response valid in the current servlet context
- */
- void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException;
+ /**
+ * Authentication support.
+ *
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ */
+ void logout(HttpServletRequest request, HttpServletResponse response) throws
ServletException;
- /**
- * Returns the name and version of the servlet container in which the
- * context is running.
- *
- * <P>
- * The form of the returned string is
<code>containername/versionnumber</code>.
- *
- *
- * @return the string containing at least name and version number
- */
- public String getContainerInfo();
+ /**
+ * Returns the name and version of the servlet container in which the
+ * context is running.
+ *
+ * <P>
+ * The form of the returned string is
<code>containername/versionnumber</code>.
+ *
+ *
+ * @return the string containing at least name and version number
+ */
+ public String getContainerInfo();
- /**
- * 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
- {
+ /**
+ * 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;
+ /**
+ * 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;
+ /**
+ * 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;
- }
+ /**
+ * Cancel the registration against the servlet container.
+ *
+ * @throws IllegalStateException if the registration is cancelled
+ */
+ void cancel() throws IllegalStateException;
+ }
}