]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add VaadinSession getter to VaadinService (#9402)
authorLeif Åstrand <leif@vaadin.com>
Thu, 6 Sep 2012 13:51:47 +0000 (16:51 +0300)
committerLeif Åstrand <leif@vaadin.com>
Thu, 6 Sep 2012 14:07:49 +0000 (17:07 +0300)
server/src/com/vaadin/server/AbstractVaadinService.java
server/src/com/vaadin/server/VaadinPortlet.java
server/src/com/vaadin/server/VaadinService.java
server/src/com/vaadin/server/VaadinServlet.java

index dc6342b2994c1bf735d2d582dab001409bc3c82e..6e14c1984b9bbf8f2c9754d4218eaf35b0769771 100644 (file)
@@ -76,4 +76,11 @@ public abstract class AbstractVaadinService implements VaadinService {
     public AddonContext getAddonContext() {
         return addonContext;
     }
+
+    @Override
+    public VaadinSession getVaadinSession(WrappedRequest request) {
+        return (VaadinSession) request.getAttribute(VaadinSession.class
+                .getName());
+    }
+
 }
index af59a09c82c0d8918fefe6d0934d30edcc55c551..4bd68bde66e1427df59e6057408422df8c7bd553 100644 (file)
@@ -462,6 +462,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
                     return;
                 }
                 VaadinSession.setCurrent(application);
+                request.setAttribute(VaadinSession.class.getName(), application);
 
                 /*
                  * Get or create an application context and an application
index 1e9a2667c3abea358841db4378eab44431f226a0..827902def2ea22fde3ba605d5d3e5e2ead50bc33 100644 (file)
@@ -138,4 +138,18 @@ public interface VaadinService extends Serializable {
      *         base directory.
      */
     public File getBaseDirectory();
+
+    /**
+     * Gets the Vaadin session associated with this request.
+     * 
+     * @param request
+     *            the request to get a vaadin session for.
+     * 
+     * @see VaadinSession
+     * 
+     * @return the vaadin session for the request, or <code>null</code> if no
+     *         session is found and this is a request for which a new session
+     *         shouldn't be created.
+     */
+    public VaadinSession getVaadinSession(WrappedRequest request);
 }
index e7e5dfe7d8d0c985d4fe740d6c766fe85a57d0c2..cbf576565886ad74f4f77bb544913fa59394fe7a 100644 (file)
@@ -306,6 +306,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
             if (application == null) {
                 return;
             }
+            request.setAttribute(VaadinSession.class.getName(), application);
             VaadinSession.setCurrent(application);
 
             /*