[webbeans-commits] Webbeans SVN: r1797 - in ri/trunk/impl/src: main/java/org/jboss/webbeans/servlet and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Mar 6 10:58:47 EST 2009


Author: pete.muir at jboss.org
Date: 2009-03-06 10:58:47 -0500 (Fri, 06 Mar 2009)
New Revision: 1797

Added:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/context/ContextTest.java
Removed:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
Log:
WBRI-155

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java	2009-03-06 15:27:47 UTC (rev 1796)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java	2009-03-06 15:58:47 UTC (rev 1797)
@@ -99,7 +99,7 @@
    
    public void beginSession()
    {
-      super.beginSession("Mock", sessionBeanStore);
+      super.restoreSession("Mock", sessionBeanStore);
    }
    
    public void endSession()

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java	2009-03-06 15:27:47 UTC (rev 1796)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java	2009-03-06 15:58:47 UTC (rev 1797)
@@ -34,9 +34,9 @@
 
    private static LogProvider log = Logging.getLogProvider(AbstractLifecycle.class);
 
-   protected void beginSession(String id, BeanStore sessionBeanStore)
+   protected void restoreSession(String id, BeanStore sessionBeanStore)
    {
-      log.trace("Starting session " + id);
+      log.trace("Restoring session " + id);
       SessionContext.INSTANCE.setBeanStore(sessionBeanStore);
       SessionContext.INSTANCE.setActive(true);
    }

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java (from rev 1791, ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java	2009-03-06 15:58:47 UTC (rev 1797)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.servlet;
+
+import java.io.IOException;
+
+import javax.context.Conversation;
+import javax.faces.context.FacesContext;
+import javax.inject.AnnotationLiteral;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.conversation.bindings.ConversationIdName;
+
+/**
+ * Filter for handling conversation propagation over redirects
+ * 
+ * @author Nicklas Karlsson
+ * 
+ */
+public class ConversationPropagationFilter implements Filter
+{
+
+   /**
+    * Helper class for handling URLs
+    * 
+    * @author Nicklas Karlsson
+    */
+   private class UrlTransformer
+   {
+      private String URL;
+      private FacesContext context;
+
+      private boolean isUrlAbsolute()
+      {
+         // TODO: any API call to do this?
+         return URL.startsWith("http://") || URL.startsWith("https://");
+      }
+
+      public UrlTransformer(String URL)
+      {
+         this.URL = URL;
+         context = FacesContext.getCurrentInstance();
+      }
+
+      public UrlTransformer appendConversation(String cid)
+      {
+         String cidName = CurrentManager.rootManager().getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>()
+         {
+         });
+         URL = URL + (URL.indexOf("?") > 0 ? "&" : "?") + cidName + "=" + cid;
+         return this;
+      }
+
+      public UrlTransformer getRedirectView()
+      {
+         if (isUrlAbsolute())
+         {
+            String requestPath = context.getExternalContext().getRequestContextPath();
+            URL = URL.substring(URL.indexOf(requestPath) + requestPath.length());
+         }
+         return this;
+      }
+
+      public UrlTransformer getActionUrl()
+      {
+         URL = context.getApplication().getViewHandler().getActionURL(context, URL);
+         return this;
+      }
+
+      public String encode()
+      {
+         return context.getExternalContext().encodeActionURL(URL);
+      }
+   }
+
+   public void destroy()
+   {
+   }
+
+   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+   {
+      chain.doFilter(request, wrapResponse((HttpServletResponse) response));
+   }
+
+   private ServletResponse wrapResponse(HttpServletResponse response)
+   {
+      return new HttpServletResponseWrapper(response)
+      {
+         @Override
+         public void sendRedirect(String path) throws IOException
+         {
+            Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
+            if (conversation.isLongRunning())
+            {
+               path = new UrlTransformer(path).getRedirectView().getActionUrl().appendConversation(conversation.getId()).encode();
+            }
+            super.sendRedirect(path);
+         }
+      };
+   }
+
+   public void init(FilterConfig config) throws ServletException
+   {
+   }
+
+}

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-06 15:27:47 UTC (rev 1796)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2009-03-06 15:58:47 UTC (rev 1797)
@@ -59,7 +59,6 @@
     */
    public void beginSession(HttpSession session)
    {
-      super.beginSession(session.getId(), null);
    }
 
    /**
@@ -85,7 +84,7 @@
    protected BeanStore restoreSessionContext(HttpSession session)
    {
       BeanStore sessionBeanStore = new HttpSessionBeanStore(session);
-      SessionContext.INSTANCE.setBeanStore(sessionBeanStore);
+      super.restoreSession(session.getId(), sessionBeanStore);
       CurrentManager.rootManager().getInstanceByType(HttpSessionManager.class).setSession(session);
       return sessionBeanStore;
    }

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java	2009-03-06 15:27:47 UTC (rev 1796)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java	2009-03-06 15:58:47 UTC (rev 1797)
@@ -1,128 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.servlet;
-
-import java.io.IOException;
-
-import javax.context.Conversation;
-import javax.faces.context.FacesContext;
-import javax.inject.AnnotationLiteral;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.conversation.bindings.ConversationIdName;
-
-/**
- * Filter for handling conversation propagation over redirects
- * 
- * @author Nicklas Karlsson
- * 
- */
-public class WebBeansServletFilter implements Filter
-{
-
-   /**
-    * Helper class for handling URLs
-    * 
-    * @author Nicklas Karlsson
-    */
-   private class UrlTransformer
-   {
-      private String URL;
-      private FacesContext context;
-
-      private boolean isUrlAbsolute()
-      {
-         // TODO: any API call to do this?
-         return URL.startsWith("http://") || URL.startsWith("https://");
-      }
-
-      public UrlTransformer(String URL)
-      {
-         this.URL = URL;
-         context = FacesContext.getCurrentInstance();
-      }
-
-      public UrlTransformer appendConversation(String cid)
-      {
-         String cidName = CurrentManager.rootManager().getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>()
-         {
-         });
-         URL = URL + (URL.indexOf("?") > 0 ? "&" : "?") + cidName + "=" + cid;
-         return this;
-      }
-
-      public UrlTransformer getRedirectView()
-      {
-         if (isUrlAbsolute())
-         {
-            String requestPath = context.getExternalContext().getRequestContextPath();
-            URL = URL.substring(URL.indexOf(requestPath) + requestPath.length());
-         }
-         return this;
-      }
-
-      public UrlTransformer getActionUrl()
-      {
-         URL = context.getApplication().getViewHandler().getActionURL(context, URL);
-         return this;
-      }
-
-      public String encode()
-      {
-         return context.getExternalContext().encodeActionURL(URL);
-      }
-   }
-
-   public void destroy()
-   {
-   }
-
-   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
-   {
-      chain.doFilter(request, wrapResponse((HttpServletResponse) response));
-   }
-
-   private ServletResponse wrapResponse(HttpServletResponse response)
-   {
-      return new HttpServletResponseWrapper(response)
-      {
-         @Override
-         public void sendRedirect(String path) throws IOException
-         {
-            Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
-            if (conversation.isLongRunning())
-            {
-               path = new UrlTransformer(path).getRedirectView().getActionUrl().appendConversation(conversation.getId()).encode();
-            }
-            super.sendRedirect(path);
-         }
-      };
-   }
-
-   public void init(FilterConfig config) throws ServletException
-   {
-   }
-
-}

Added: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/context/ContextTest.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/context/ContextTest.java	                        (rev 0)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/context/ContextTest.java	2009-03-06 15:58:47 UTC (rev 1797)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.unit.context;
+
+import org.jboss.webbeans.test.unit.AbstractTest;
+import org.testng.annotations.Test;
+
+public class ContextTest extends AbstractTest
+{
+   // WBRI-155
+   @Test(groups="stub")
+   public void testSessionContextActiveForMultipleSimultaneousThreads()
+   {
+      assert false;
+      // TODO Implement this test
+   }
+   
+}


Property changes on: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/context/ContextTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list