]> source.dussan.org Git - vaadin-framework.git/commitdiff
Ensure there's a service for each session (#9733) 10/10/1
authorLeif Åstrand <leif@vaadin.com>
Fri, 28 Sep 2012 11:22:00 +0000 (14:22 +0300)
committerLeif Åstrand <leif@vaadin.com>
Fri, 28 Sep 2012 11:22:00 +0000 (14:22 +0300)
Change-Id: I9425c2d33fd09759b18930741344e9181dc79364

15 files changed:
server/src/com/vaadin/server/VaadinPortletService.java
server/src/com/vaadin/server/VaadinPortletSession.java
server/src/com/vaadin/server/VaadinServiceSession.java
server/src/com/vaadin/server/VaadinServletService.java
server/src/com/vaadin/server/VaadinServletSession.java
server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java
server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java
server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java
server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java
server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java
server/tests/src/com/vaadin/ui/LabelDataSource.java

index 298b875a551ddfcb691a99161cf19adeea5ab631..aa81c39d9dfbaad6846b5eabb41a8259c96305da 100644 (file)
@@ -208,7 +208,7 @@ public class VaadinPortletService extends VaadinService {
     @Override
     protected VaadinServiceSession createVaadinSession(VaadinRequest request)
             throws ServiceException {
-        return new VaadinPortletSession();
+        return new VaadinPortletSession(this);
     }
 
     @Override
index 427314975e3b626e0bd8bdb1500e2158f7b9aecf..6b89342b2bd6a4713b69c2c7f22b5fc3b6196c20 100644 (file)
@@ -66,6 +66,16 @@ public class VaadinPortletSession extends VaadinServiceSession {
     private final Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>();
     private final Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>();
 
+    /**
+     * Create a portlet service session for the given portlet service
+     * 
+     * @param service
+     *            the portlet service to which the new session belongs
+     */
+    public VaadinPortletSession(VaadinPortletService service) {
+        super(service);
+    }
+
     public PortletSession getPortletSession() {
         WrappedSession wrappedSession = getSession();
         PortletSession session = ((WrappedPortletSession) wrappedSession)
index 2b6b6514044d995463ea1d5479067c31c0ea76e6..c581a1930cc9ccf6f44fa0d6b89ee405c357ccf7 100644 (file)
@@ -198,6 +198,16 @@ public class VaadinServiceSession implements HttpSessionBindingListener,
 
     private VaadinService service;
 
+    /**
+     * Create a new service session tied to a Vaadin service
+     * 
+     * @param service
+     *            the Vaadin service for the new session
+     */
+    public VaadinServiceSession(VaadinService service) {
+        this.service = service;
+    }
+
     /**
      * @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
      */
@@ -1123,4 +1133,8 @@ public class VaadinServiceSession implements HttpSessionBindingListener,
         return Collections.unmodifiableList(uiProviders);
     }
 
+    public VaadinService getService() {
+        return service;
+    }
+
 }
index 5d01c84948f8a6502a8087dc2fab3f170e94546b..ca894b8a4facb61b5068347225d7a61875ba2620 100644 (file)
@@ -188,7 +188,7 @@ public class VaadinServletService extends VaadinService {
     @Override
     protected VaadinServiceSession createVaadinSession(VaadinRequest request)
             throws ServiceException {
-        return new VaadinServletSession();
+        return new VaadinServletSession(this);
     }
 
     @Override
index fa048194c3c6df53d5b473c7caf148899d6dc738..78f58d64fefa23bde032a480ec226a2e6041af1f 100644 (file)
@@ -41,6 +41,16 @@ public class VaadinServletSession extends VaadinServiceSession {
 
     private transient boolean reinitializingSession = false;
 
+    /**
+     * Create a servlet service session for the given servlet service
+     * 
+     * @param service
+     *            the servlet service to which the new session belongs
+     */
+    public VaadinServletSession(VaadinServletService service) {
+        super(service);
+    }
+
     @Override
     public void valueUnbound(HttpSessionBindingEvent event) {
         if (!reinitializingSession) {
index 72747dca2d75d1a3c7e555fbd185a18dd0db7e9d..0ba7779e7981d1a39cee5dac72c593a268097eea 100644 (file)
@@ -66,7 +66,8 @@ public class ConverterFactory extends TestCase {
 
     public void testApplicationConverterFactoryInBackgroundThread() {
         VaadinServiceSession.setCurrent(null);
-        final VaadinServiceSession appWithCustomIntegerConverter = new VaadinServiceSession();
+        final VaadinServiceSession appWithCustomIntegerConverter = new VaadinServiceSession(
+                null);
         appWithCustomIntegerConverter
                 .setConverterFactory(new ConverterFactory42());
 
@@ -83,7 +84,8 @@ public class ConverterFactory extends TestCase {
     }
 
     public void testApplicationConverterFactoryForDetachedComponent() {
-        final VaadinServiceSession appWithCustomIntegerConverter = new VaadinServiceSession();
+        final VaadinServiceSession appWithCustomIntegerConverter = new VaadinServiceSession(
+                null);
         appWithCustomIntegerConverter
                 .setConverterFactory(new ConverterFactory42());
         VaadinServiceSession.setCurrent(appWithCustomIntegerConverter);
@@ -96,10 +98,11 @@ public class ConverterFactory extends TestCase {
     }
 
     public void testApplicationConverterFactoryForDifferentThanCurrentApplication() {
-        final VaadinServiceSession fieldAppWithCustomIntegerConverter = new VaadinServiceSession();
+        final VaadinServiceSession fieldAppWithCustomIntegerConverter = new VaadinServiceSession(
+                null);
         fieldAppWithCustomIntegerConverter
                 .setConverterFactory(new ConverterFactory42());
-        VaadinServiceSession.setCurrent(new VaadinServiceSession());
+        VaadinServiceSession.setCurrent(new VaadinServiceSession(null));
 
         TextField tf = new TextField("", "123") {
             @Override
index 0130086371a46889646d8b6f39bb555cb5700648..5c74077ca950900093e012f8b47190b4d76d076c 100644 (file)
@@ -21,7 +21,7 @@ public class TestStreamVariableMapping extends TestCase {
 
     @Override
     protected void setUp() throws Exception {
-        final VaadinServiceSession application = new VaadinServiceSession();
+        final VaadinServiceSession application = new VaadinServiceSession(null);
         final UI uI = new UI() {
             @Override
             protected void init(VaadinRequest request) {
@@ -66,7 +66,7 @@ public class TestStreamVariableMapping extends TestCase {
     }
 
     private CommunicationManager createCommunicationManager() {
-        return new CommunicationManager(new VaadinServiceSession());
+        return new CommunicationManager(new VaadinServiceSession(null));
     }
 
 }
index faec1d99a17c6c0324f38d9ee5be7a9b2eb541c1..8d4cdc3c7c9b60e5d699a07318fdfd4d880b27a5 100644 (file)
@@ -186,7 +186,7 @@ public class AbstractFieldValueConversions extends TestCase {
     }
 
     public void testNumberDoubleConverterChange() {
-        final VaadinServiceSession a = new VaadinServiceSession();
+        final VaadinServiceSession a = new VaadinServiceSession(null);
         VaadinServiceSession.setCurrent(a);
         TextField tf = new TextField() {
             @Override
index b29876ef3c5b1797399cfe3dabb44cddcfc64ee0..43a7d90922e12701c0cdadc2b5976f9ed7b517b9 100644 (file)
@@ -26,7 +26,7 @@ public class DefaultConverterFactory extends TestCase {
     }
 
     public void testDefaultNumberConversion() {
-        VaadinServiceSession app = new VaadinServiceSession();
+        VaadinServiceSession app = new VaadinServiceSession(null);
         VaadinServiceSession.setCurrent(app);
         TextField tf = new TextField();
         tf.setLocale(new Locale("en", "US"));
index bfa79ec9c8083cb81dba0e539681c19fe44ce75e..83bb7c4613abdd94ecbde2fd416b74236e25b00d 100644 (file)
@@ -18,9 +18,8 @@ public class RemoveListenersOnDetach {
     int numReadOnlyChanges = 0;
 
     AbstractField field = new AbstractField() {
-        final private VaadinServiceSession application = new VaadinServiceSession() {
-
-        };
+        final private VaadinServiceSession application = new VaadinServiceSession(
+                null);
         private UI uI = new UI() {
 
             @Override
index 37363e7d4b44ba2820c285f586e4b69d0aab3c78..68e983f8a511ae7906af4eba66ae61ef526b3297 100644 (file)
@@ -37,7 +37,7 @@ public class LabelConverters extends TestCase {
     }
 
     public void testIntegerDataSource() {
-        VaadinServiceSession.setCurrent(new VaadinServiceSession());
+        VaadinServiceSession.setCurrent(new VaadinServiceSession(null));
         Label l = new Label("Foo");
         Property ds = new MethodProperty<Integer>(Person.createTestPerson1(),
                 "age");
index 161165cf645233a18f3b7c4a1c82937783e9577b..e071c0e484426a2b4d6112d76cab24b3ce863403 100644 (file)
@@ -113,7 +113,7 @@ public class CustomUIClassLoader extends TestCase {
     }
 
     private VaadinServiceSession createStubApplication() {
-        return new VaadinServiceSession() {
+        return new VaadinServiceSession(null) {
             @Override
             public DeploymentConfiguration getConfiguration() {
                 return createConfigurationMock();
index 19cf69422ff5bd62d20ed45e6b19923ab7640a60..8aac9a9598980cf1b551ee4f28bfb07943cf8398 100644 (file)
@@ -25,7 +25,7 @@ public class AddRemoveSubWindow {
 
     @Test
     public void addSubWindow() {
-        VaadinServiceSession.setCurrent(new VaadinServiceSession());
+        VaadinServiceSession.setCurrent(new VaadinServiceSession(null));
         TestApp app = new TestApp();
         app.init();
         Window subWindow = new Window("Sub window");
index 5374641beab5e5882b493f964cabf276d1a16c44..a00e5e09960ebddeadc1b7cade7b7a89e983b285 100644 (file)
@@ -15,7 +15,7 @@ import com.vaadin.ui.Window;
 
 public class AttachDetachWindow {
 
-    private VaadinServiceSession testApp = new VaadinServiceSession();
+    private VaadinServiceSession testApp = new VaadinServiceSession(null);
 
     private interface TestContainer {
         public boolean attachCalled();
index 30295553a2c84bd78e63d7ca06bcef76b9ea1f80..506a6358142ff22c40532fafdd194622b5e30665 100644 (file)
@@ -39,7 +39,7 @@ public class LabelDataSource {
 
     @Before
     public void setup() {
-        vaadinSession = new VaadinServiceSession();
+        vaadinSession = new VaadinServiceSession(null);
         VaadinServiceSession.setCurrent(vaadinSession);
 
         label = new Label();