[webbeans-commits] Webbeans SVN: r2235 - ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Mar 27 14:16:09 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-03-27 14:16:09 -0400 (Fri, 27 Mar 2009)
New Revision: 2235

Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
Log:
servlet listener is getting called twice on GF so only proceed on outer most calls

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2009-03-27 17:52:50 UTC (rev 2234)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2009-03-27 18:16:09 UTC (rev 2235)
@@ -98,10 +98,13 @@
     */
    public void beginRequest(HttpServletRequest request)
    {
-      BeanStore beanStore = new ConcurrentHashMapBeanStore();
-      request.setAttribute(REQUEST_ATTRIBUTE_NAME, beanStore);
-      super.beginRequest(request.getRequestURI(), beanStore);
-      restoreSessionContext(request.getSession());
+      if (request.getAttribute(REQUEST_ATTRIBUTE_NAME) == null)
+      {
+         BeanStore beanStore = new ConcurrentHashMapBeanStore();
+         request.setAttribute(REQUEST_ATTRIBUTE_NAME, beanStore);
+         super.beginRequest(request.getRequestURI(), beanStore);
+         restoreSessionContext(request.getSession());
+      }
    }
 
    /**
@@ -111,13 +114,17 @@
     */
    public void endRequest(HttpServletRequest request)
    {
-      BeanStore beanStore = (BeanStore) request.getAttribute(REQUEST_ATTRIBUTE_NAME);
-      if (beanStore == null)
+      if (request.getAttribute(REQUEST_ATTRIBUTE_NAME) != null)
       {
-         throw new IllegalStateException("Cannot obtain request scoped beans from the request");
+         BeanStore beanStore = (BeanStore) request.getAttribute(REQUEST_ATTRIBUTE_NAME);
+         if (beanStore == null)
+         {
+            throw new IllegalStateException("Cannot obtain request scoped beans from the request");
+         }
+         super.endRequest(request.getRequestURI(), beanStore);
+         request.removeAttribute(REQUEST_ATTRIBUTE_NAME);
+         SessionContext.INSTANCE.setBeanStore(null);
       }
-      super.endRequest(request.getRequestURI(), beanStore);
-      SessionContext.INSTANCE.setBeanStore(null);
    }
 
 }




More information about the weld-commits mailing list