]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add WrappedRequest.getWrappedSession(boolean) (#9655)
authorLeif Åstrand <leif@vaadin.com>
Tue, 18 Sep 2012 10:20:18 +0000 (13:20 +0300)
committerLeif Åstrand <leif@vaadin.com>
Tue, 18 Sep 2012 10:22:02 +0000 (13:22 +0300)
server/src/com/vaadin/server/CombinedRequest.java
server/src/com/vaadin/server/WrappedHttpServletRequest.java
server/src/com/vaadin/server/WrappedPortletRequest.java
server/src/com/vaadin/server/WrappedRequest.java

index 2364527a65ae5ffe2c6bdef76809036cd03c3479..91c5093ece370a5805827851f0df341b258b6a80 100644 (file)
@@ -114,7 +114,12 @@ public class CombinedRequest implements WrappedRequest {
 
     @Override
     public WrappedSession getWrappedSession() {
-        return secondRequest.getWrappedSession();
+        return getWrappedSession(true);
+    }
+
+    @Override
+    public WrappedSession getWrappedSession(boolean allowSessionCreation) {
+        return secondRequest.getWrappedSession(allowSessionCreation);
     }
 
     @Override
index 87c6c521afd6f0dabb2d804435e2ad1e9402d74a..adfbde87ef56b5019be4b139ccca5ad158ae2833 100644 (file)
@@ -56,7 +56,12 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper
 
     @Override
     public WrappedSession getWrappedSession() {
-        return new WrappedHttpSession(getSession());
+        return getWrappedSession(true);
+    }
+
+    @Override
+    public WrappedSession getWrappedSession(boolean allowSessionCreation) {
+        return new WrappedHttpSession(getSession(allowSessionCreation));
     }
 
     /**
@@ -111,4 +116,5 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper
         }
         return (WrappedHttpServletRequest) request;
     }
+
 }
\ No newline at end of file
index dd46194a2ae9cc9a62411891f4382a2892c345ba..78bfe838b1cb794357698aa8d4f98b7384625782 100644 (file)
@@ -114,7 +114,13 @@ public class WrappedPortletRequest implements WrappedRequest {
 
     @Override
     public WrappedSession getWrappedSession() {
-        return new WrappedPortletSession(request.getPortletSession());
+        return getWrappedSession(true);
+    }
+
+    @Override
+    public WrappedSession getWrappedSession(boolean allowSessionCreation) {
+        return new WrappedPortletSession(
+                request.getPortletSession(allowSessionCreation));
     }
 
     /**
index 504f21aed499e1831efd86e724ffe4b8f1609855..aeaff2b3844e1981aebd263b4bc36f565308b9a8 100644 (file)
@@ -161,7 +161,8 @@ public interface WrappedRequest extends Serializable {
     public String getRequestPathInfo();
 
     /**
-     * Gets the session associated with this request.
+     * Gets the session associated with this request, creating a new if there is
+     * no session.
      * 
      * @see WrappedSession
      * @see HttpServletRequest#getSession()
@@ -171,6 +172,23 @@ public interface WrappedRequest extends Serializable {
      */
     public WrappedSession getWrappedSession();
 
+    /**
+     * Gets the session associated with this request, optionally creating a new
+     * if there is no session.
+     * 
+     * @param allowSessionCreation
+     *            <code>true</code> to create a new session for this request if
+     *            necessary; <code>false</code> to return <code>null</code> if
+     *            there's no current session
+     * 
+     * @see WrappedSession
+     * @see HttpServletRequest#getSession(boolean)
+     * @see PortletRequest#getPortletSession(boolean)
+     * 
+     * @return the wrapped session for this request
+     */
+    public WrappedSession getWrappedSession(boolean allowSessionCreation);
+
     /**
      * Returns the MIME type of the body of the request, or null if the type is
      * not known.