diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-07-23 13:18:04 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-07-23 13:18:04 +0300 |
commit | b345bf217a01e5395c893914e065e30f77e35350 (patch) | |
tree | adb57cc78c6c37230f99d0ff1c86903cf6152424 /server | |
parent | 7cf124627e712d8e956d7e3f60e181230075daf9 (diff) | |
parent | 7f5a0a7827570188b7c62ed362f4724886b1a94d (diff) | |
download | vaadin-framework-b345bf217a01e5395c893914e065e30f77e35350.tar.gz vaadin-framework-b345bf217a01e5395c893914e065e30f77e35350.zip |
Merge changes from origin/7.1
3229847 Fix lost focus in Table when refreshing row cache (#12231)
654d570 Don't close an unbound VaadinSession for GAEVaadinServlet (#12209)
2ea19f3 Make VaadinService.closeInactiveUIs set UI threadlocals (#12186)
7f5a0a7 Add Require-Bundle for our rebased atmosphere bundle (#12195)
Change-Id: I65c9a33462b3508b763115f8410fec3e62e16d45
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/GAEVaadinServlet.java | 11 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinService.java | 41 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinSession.java | 8 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/UI.java | 36 |
4 files changed, 80 insertions, 16 deletions
diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java index 5a12295d9d..6690da7562 100644 --- a/server/src/com/vaadin/server/GAEVaadinServlet.java +++ b/server/src/com/vaadin/server/GAEVaadinServlet.java @@ -401,7 +401,18 @@ public class GAEVaadinServlet extends VaadinServlet { if (serviceSession == null) { return; } + + /* + * Inform VaadinSession.valueUnbound that it should not kill the session + * even though it gets unbound. + */ + serviceSession.setAttribute( + VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE, Boolean.TRUE); serviceSession.removeFromSession(getService()); + + // Remove preservation marker + serviceSession.setAttribute( + VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE, null); } /** diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 7baa57c6dc..bd4637c407 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -73,9 +73,25 @@ import com.vaadin.util.ReflectTools; * @since 7.0 */ public abstract class VaadinService implements Serializable { - static final String REINITIALIZING_SESSION_MARKER = VaadinService.class + /** + * Attribute name for telling + * {@link VaadinSession#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)} + * that it should not close a {@link VaadinSession} even though it gets + * unbound. If a {@code VaadinSession} has an attribute with this name and + * the attribute value is {@link Boolean#TRUE}, that session will not be + * closed when it is unbound from the underlying session. + */ + // Use the old name.reinitializing value for backwards compatibility + static final String PRESERVE_UNBOUND_SESSION_ATTRIBUTE = VaadinService.class .getName() + ".reinitializing"; + /** + * @deprecated As of 7.1.1, use {@link #PRESERVE_UNBOUND_SESSION_ATTRIBUTE} + * instead + */ + @Deprecated + static final String REINITIALIZING_SESSION_MARKER = PRESERVE_UNBOUND_SESSION_ATTRIBUTE; + private static final Method SESSION_INIT_METHOD = ReflectTools.findMethod( SessionInitListener.class, "sessionInit", SessionInitEvent.class); @@ -976,7 +992,7 @@ public abstract class VaadinService implements Serializable { if (value instanceof VaadinSession) { // set flag to avoid cleanup VaadinSession serviceSession = (VaadinSession) value; - serviceSession.setAttribute(REINITIALIZING_SESSION_MARKER, + serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE, Boolean.TRUE); } attrs.put(name, value); @@ -1003,8 +1019,8 @@ public abstract class VaadinService implements Serializable { serviceSession.getLockInstance()); serviceSession.storeInSession(service, newSession); - serviceSession - .setAttribute(REINITIALIZING_SESSION_MARKER, null); + serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE, + null); } } @@ -1126,13 +1142,18 @@ public abstract class VaadinService implements Serializable { * @since 7.0.0 */ private void closeInactiveUIs(VaadinSession session) { - String sessionId = session.getSession().getId(); - for (UI ui : session.getUIs()) { + final String sessionId = session.getSession().getId(); + for (final UI ui : session.getUIs()) { if (!isUIActive(ui) && !ui.isClosing()) { - getLogger().log(Level.FINE, - "Closing inactive UI #{0} in session {1}", - new Object[] { ui.getUIId(), sessionId }); - ui.close(); + ui.accessSynchronously(new Runnable() { + @Override + public void run() { + getLogger().log(Level.FINE, + "Closing inactive UI #{0} in session {1}", + new Object[] { ui.getUIId(), sessionId }); + ui.close(); + } + }); } } } diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index 890b2eba29..8f27241384 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -240,9 +240,11 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { } else if (VaadinService.getCurrentRequest() != null && getCurrent() == this) { assert hasLock(); - // Ignore if the session is being moved to a different backing - // session - if (getAttribute(VaadinService.REINITIALIZING_SESSION_MARKER) == Boolean.TRUE) { + /* + * Ignore if the session is being moved to a different backing + * session or if GAEVaadinServlet is doing its normal cleanup. + */ + if (getAttribute(VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE) == Boolean.TRUE) { return; } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 63f04acd43..d4756e9ec1 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -441,8 +441,12 @@ public abstract class UI extends AbstractSingleComponentContainer implements * the server that originates from this UI. * {@link VaadinService#findUI(VaadinRequest)} uses this id to find the * route to which the request belongs. + * <p> + * This method is not intended to be overridden. If it is overridden, care + * should be taken since this method might be called in situations where + * {@link UI#getCurrent()} does not return this UI. * - * @return + * @return the id of this UI */ public int getUIId() { return uiId; @@ -1017,9 +1021,12 @@ public abstract class UI extends AbstractSingleComponentContainer implements /** * Returns the timestamp of the last received heartbeat for this UI. + * <p> + * This method is not intended to be overridden. If it is overridden, care + * should be taken since this method might be called in situations where + * {@link UI#getCurrent()} does not return this UI. * - * @see #heartbeat() - * @see VaadinSession#cleanupInactiveUIs() + * @see VaadinService#closeInactiveUIs(VaadinSession) * * @return The time the last heartbeat request occurred, in milliseconds * since the epoch. @@ -1032,6 +1039,10 @@ public abstract class UI extends AbstractSingleComponentContainer implements * Sets the last heartbeat request timestamp for this UI. Called by the * framework whenever the application receives a valid heartbeat request for * this UI. + * <p> + * This method is not intended to be overridden. If it is overridden, care + * should be taken since this method might be called in situations where + * {@link UI#getCurrent()} does not return this UI. * * @param lastHeartbeat * The time the last heartbeat request occurred, in milliseconds @@ -1075,6 +1086,11 @@ public abstract class UI extends AbstractSingleComponentContainer implements if (getPushConnection() != null) { // Push the Rpc to the client. The connection will be closed when // the UI is detached and cleaned up. + + // Can't use UI.push() directly since it checks for a valid session + if (session != null) { + session.getService().runPendingAccessTasks(session); + } getPushConnection().push(); } @@ -1082,6 +1098,10 @@ public abstract class UI extends AbstractSingleComponentContainer implements /** * Returns whether this UI is marked as closed and is to be detached. + * <p> + * This method is not intended to be overridden. If it is overridden, care + * should be taken since this method might be called in situations where + * {@link UI#getCurrent()} does not return this UI. * * @see #close() * @@ -1356,6 +1376,13 @@ public abstract class UI extends AbstractSingleComponentContainer implements * Returns the internal push connection object used by this UI. This method * should only be called by the framework. If the returned PushConnection is * not null, it is guaranteed to have {@code isConnected() == true}. + * <p> + * This method is not intended to be overridden. If it is overridden, care + * should be taken since this method might be called in situations where + * {@link UI#getCurrent()} does not return this UI. + * + * @return the push connection used by this UI, <code>null</code> if there + * is no active push connection. */ public PushConnection getPushConnection() { assert (pushConnection == null || pushConnection.isConnected()); @@ -1366,6 +1393,9 @@ public abstract class UI extends AbstractSingleComponentContainer implements * Sets the internal push connection object used by this UI. This method * should only be called by the framework. If {@pushConnection} is not null, * its {@code isConnected()} must be true. + * + * @param pushConnection + * the push connection to use for this UI */ public void setPushConnection(PushConnection pushConnection) { // If pushMode is disabled then there should never be a pushConnection |