diff options
author | Artur Signell <artur@vaadin.com> | 2014-05-22 16:05:47 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-05-22 13:37:41 +0000 |
commit | 660d17bff945a7b9b65735b23b4057769d07388b (patch) | |
tree | 5cf8b2b5e096436ca25728098ffc41a8090cfd56 /server/src | |
parent | 40d35f2bc97ba6516ee5d6cbb7954607c357a698 (diff) | |
download | vaadin-framework-660d17bff945a7b9b65735b23b4057769d07388b.tar.gz vaadin-framework-660d17bff945a7b9b65735b23b4057769d07388b.zip |
Helpers for retrieving the current PortletRequest (#13806)
Change-Id: I5d400a05071844729d68abb1ba0c31c33e32e9c7
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/com/vaadin/server/VaadinPortletRequest.java | 28 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinPortletService.java | 40 |
2 files changed, 65 insertions, 3 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortletRequest.java b/server/src/com/vaadin/server/VaadinPortletRequest.java index 47cbebffe4..e1b521d57f 100644 --- a/server/src/com/vaadin/server/VaadinPortletRequest.java +++ b/server/src/com/vaadin/server/VaadinPortletRequest.java @@ -239,4 +239,32 @@ public class VaadinPortletRequest extends PortletRequestWrapper implements return null; } + /** + * Gets the currently processed portlet request. The current portlet request + * is automatically defined when the request is started. The current portlet + * request can not be used in e.g. background threads because of the way + * server implementations reuse request instances. + * + * @return the current portlet request instance if available, otherwise + * <code>null</code> + * + */ + public static PortletRequest getCurrentPortletRequest() { + return VaadinPortletService.getCurrentPortletRequest(); + + } + + /** + * Gets the currently processed Vaadin portlet request. The current request + * is automatically defined when the request is started. The current request + * can not be used in e.g. background threads because of the way server + * implementations reuse request instances. + * + * @return the current Vaadin portlet request instance if available, + * otherwise <code>null</code> + * + */ + public static VaadinPortletRequest getCurrent() { + return VaadinPortletService.getCurrentRequest(); + } } diff --git a/server/src/com/vaadin/server/VaadinPortletService.java b/server/src/com/vaadin/server/VaadinPortletService.java index 3666853253..2b290b4cc4 100644 --- a/server/src/com/vaadin/server/VaadinPortletService.java +++ b/server/src/com/vaadin/server/VaadinPortletService.java @@ -248,15 +248,49 @@ public class VaadinPortletService extends VaadinService { return type; } + /** + * Gets the currently processed portlet request. The current portlet request + * is automatically defined when the request is started. The current portlet + * request can not be used in e.g. background threads because of the way + * server implementations reuse request instances. + * + * @return the current portlet request instance if available, otherwise + * <code>null</code> + * + */ public static PortletRequest getCurrentPortletRequest() { - VaadinRequest currentRequest = VaadinService.getCurrentRequest(); - if (currentRequest instanceof VaadinPortletRequest) { - return ((VaadinPortletRequest) currentRequest).getPortletRequest(); + VaadinPortletRequest currentRequest = getCurrentRequest(); + if (currentRequest != null) { + return currentRequest.getPortletRequest(); } else { return null; } } + /** + * Gets the currently processed Vaadin portlet request. The current request + * is automatically defined when the request is started. The current request + * can not be used in e.g. background threads because of the way server + * implementations reuse request instances. + * + * @return the current Vaadin portlet request instance if available, + * otherwise <code>null</code> + * + */ + public static VaadinPortletRequest getCurrentRequest() { + return (VaadinPortletRequest) VaadinService.getCurrentRequest(); + } + + /** + * Gets the currently processed Vaadin portlet response. The current + * response is automatically defined when the request is started. The + * current response can not be used in e.g. background threads because of + * the way server implementations reuse response instances. + * + * @return the current Vaadin portlet response instance if available, + * otherwise <code>null</code> + * + */ public static VaadinPortletResponse getCurrentResponse() { return (VaadinPortletResponse) VaadinService.getCurrentResponse(); } |