aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-10-16 11:43:02 +0300
committerLeif Åstrand <leif@vaadin.com>2012-10-16 11:43:02 +0300
commit6b3a109b3af8b9adfa48a95407a872eeaedd8ef0 (patch)
tree697b73fabf2f4c512bb1dd5ee68cff100fa9fce8 /server
parent754cf6a33685507cc3a7d5afeb761f227df66fb8 (diff)
downloadvaadin-framework-6b3a109b3af8b9adfa48a95407a872eeaedd8ef0.tar.gz
vaadin-framework-6b3a109b3af8b9adfa48a95407a872eeaedd8ef0.zip
Add VaadinService.closeSession + test (#9859)
Also test that the HttpSession can be invalidated (#6093) Change-Id: I4e415fe15d7a734db81562e24a5ab6a7fbc5304b
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/VaadinService.java18
-rw-r--r--server/src/com/vaadin/server/VaadinServiceSession.java20
2 files changed, 38 insertions, 0 deletions
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 9d78d4c107..44e82b5898 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -737,4 +737,22 @@ public abstract class VaadinService implements Serializable {
*/
public abstract String getMainDivId(VaadinServiceSession session,
VaadinRequest request, Class<? extends UI> uiClass);
+
+ /**
+ * Closes the VaadinServiceSession and discards all associated UI state.
+ * After the session has been discarded, any UIs that have been left open
+ * will give an Out of sync error (
+ * {@link SystemMessages#getOutOfSyncCaption()}) error and a new session
+ * will be created for serving new UIs.
+ * <p>
+ * To avoid causing out of sync errors, you should typically redirect to
+ * some other page using {@link Page#setLocation(String)} to make the
+ * browser unload the invalidated UI.
+ *
+ * @param session
+ * the session to close
+ */
+ public void closeSession(VaadinServiceSession session) {
+ session.removeFromSession(this);
+ }
}
diff --git a/server/src/com/vaadin/server/VaadinServiceSession.java b/server/src/com/vaadin/server/VaadinServiceSession.java
index 62a11c710a..de5accbfd0 100644
--- a/server/src/com/vaadin/server/VaadinServiceSession.java
+++ b/server/src/com/vaadin/server/VaadinServiceSession.java
@@ -1036,4 +1036,24 @@ public class VaadinServiceSession implements HttpSessionBindingListener,
return service;
}
+ /**
+ * Closes this session and discards all associated UI state. After the
+ * session has been discarded, any UIs that have been left open will give an
+ * Out of sync error ({@link SystemMessages#getOutOfSyncCaption()}) error
+ * and a new session will be created for serving new UIs.
+ * <p>
+ * To avoid causing out of sync errors, you should typically redirect to
+ * some other page using {@link Page#setLocation(String)} to make the
+ * browser unload the invalidated UI.
+ * <p>
+ * This method is just a shorthand to
+ * {@link VaadinService#closeSession(VaadinServiceSession)}
+ *
+ * @see VaadinService#closeSession(VaadinServiceSession)
+ *
+ */
+ public void close() {
+ getService().closeSession(this);
+ }
+
}