diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-18 13:20:18 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-18 13:22:02 +0300 |
commit | 41c0e015c48079c60d1a37d8bdecf9c55a821191 (patch) | |
tree | aebba46f557ec8ab756ed3ef562b444a16c1a77d | |
parent | fba2fa761488d3d45523fc9f570b51820e607f15 (diff) | |
download | vaadin-framework-41c0e015c48079c60d1a37d8bdecf9c55a821191.tar.gz vaadin-framework-41c0e015c48079c60d1a37d8bdecf9c55a821191.zip |
Add WrappedRequest.getWrappedSession(boolean) (#9655)
4 files changed, 39 insertions, 4 deletions
diff --git a/server/src/com/vaadin/server/CombinedRequest.java b/server/src/com/vaadin/server/CombinedRequest.java index 2364527a65..91c5093ece 100644 --- a/server/src/com/vaadin/server/CombinedRequest.java +++ b/server/src/com/vaadin/server/CombinedRequest.java @@ -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 diff --git a/server/src/com/vaadin/server/WrappedHttpServletRequest.java b/server/src/com/vaadin/server/WrappedHttpServletRequest.java index 87c6c521af..adfbde87ef 100644 --- a/server/src/com/vaadin/server/WrappedHttpServletRequest.java +++ b/server/src/com/vaadin/server/WrappedHttpServletRequest.java @@ -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 diff --git a/server/src/com/vaadin/server/WrappedPortletRequest.java b/server/src/com/vaadin/server/WrappedPortletRequest.java index dd46194a2a..78bfe838b1 100644 --- a/server/src/com/vaadin/server/WrappedPortletRequest.java +++ b/server/src/com/vaadin/server/WrappedPortletRequest.java @@ -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)); } /** diff --git a/server/src/com/vaadin/server/WrappedRequest.java b/server/src/com/vaadin/server/WrappedRequest.java index 504f21aed4..aeaff2b384 100644 --- a/server/src/com/vaadin/server/WrappedRequest.java +++ b/server/src/com/vaadin/server/WrappedRequest.java @@ -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() @@ -172,6 +173,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. * |