summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/terminal
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2012-08-24 11:31:35 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2012-08-24 11:31:35 +0300
commitc8cee295021dcd33982217e3ad1c374bfca63a29 (patch)
treeee04063b2982bc772dcf2f3022c48d627eda096a /server/src/com/vaadin/terminal
parent7e3d95735858ba8726a7dc472a054ba279d7af21 (diff)
downloadvaadin-framework-c8cee295021dcd33982217e3ad1c374bfca63a29.tar.gz
vaadin-framework-c8cee295021dcd33982217e3ad1c374bfca63a29.zip
Add support for heartbeat not extending session (#9266)
Diffstat (limited to 'server/src/com/vaadin/terminal')
-rw-r--r--server/src/com/vaadin/terminal/DeploymentConfiguration.java20
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java4
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java13
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/Constants.java2
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java5
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java4
6 files changed, 43 insertions, 5 deletions
diff --git a/server/src/com/vaadin/terminal/DeploymentConfiguration.java b/server/src/com/vaadin/terminal/DeploymentConfiguration.java
index 8d5686ebbd..d3fd4567f2 100644
--- a/server/src/com/vaadin/terminal/DeploymentConfiguration.java
+++ b/server/src/com/vaadin/terminal/DeploymentConfiguration.java
@@ -23,6 +23,7 @@ import java.util.Properties;
import javax.portlet.PortletContext;
import javax.servlet.ServletContext;
+import com.vaadin.service.ApplicationContext;
import com.vaadin.terminal.gwt.server.AddonContext;
import com.vaadin.terminal.gwt.server.AddonContextListener;
@@ -162,11 +163,26 @@ public interface DeploymentConfiguration extends Serializable {
/**
* Returns the number of seconds between heartbeat requests of a root, or a
- * non-negative number if heartbeat is disabled.
+ * non-positive number if heartbeat is disabled.
*
* @since 7.0.0
*
- * @return
+ * @return The time between heartbeats.
*/
public int getHeartbeatInterval();
+
+ /**
+ * Returns whether roots that have no other activity than heartbeat requests
+ * should be closed after they have been idle the maximum inactivity time
+ * enforced by the session.
+ *
+ * @see ApplicationContext#getMaxInactiveInterval()
+ *
+ * @since 7.0.0
+ *
+ * @return True if roots receiving only heartbeat requests are eventually
+ * closed; false if heartbeat requests extend root lifetime
+ * indefinitely.
+ */
+ public boolean isIdleRootCleanupEnabled();
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 8bb14af45f..b5ea6a8735 100644
--- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -581,7 +581,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
}
// Keep the root alive
- root.heartbeat();
+ root.setLastUidlRequestTime(System.currentTimeMillis());
// Change all variables based on request parameters
if (!handleVariables(request, response, callback, application, root)) {
@@ -2683,7 +2683,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
// null-check below handles this as well
}
if (root != null) {
- root.heartbeat();
+ root.setLastHeartbeatTime(System.currentTimeMillis());
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND,
"Root not found");
diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java b/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
index 1895560209..30ba82f664 100644
--- a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
+++ b/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
@@ -34,6 +34,7 @@ public abstract class AbstractDeploymentConfiguration implements
private boolean xsrfProtectionEnabled;
private int resourceCacheTime;
private int heartbeatInterval;
+ private boolean idleRootCleanupEnabled;
public AbstractDeploymentConfiguration(Class<?> systemPropertyBaseClass,
Properties applicationProperties) {
@@ -44,6 +45,7 @@ public abstract class AbstractDeploymentConfiguration implements
checkXsrfProtection();
checkResourceCacheTime();
checkHeartbeatInterval();
+ checkIdleRootCleanup();
}
@Override
@@ -204,6 +206,11 @@ public abstract class AbstractDeploymentConfiguration implements
return heartbeatInterval;
}
+ @Override
+ public boolean isIdleRootCleanupEnabled() {
+ return idleRootCleanupEnabled;
+ }
+
/**
* Log a warning if Vaadin is not running in production mode.
*/
@@ -256,6 +263,12 @@ public abstract class AbstractDeploymentConfiguration implements
}
}
+ private void checkIdleRootCleanup() {
+ idleRootCleanupEnabled = getApplicationOrSystemProperty(
+ Constants.SERVLET_PARAMETER_CLOSE_IDLE_ROOTS, "false").equals(
+ "true");
+ }
+
private Logger getLogger() {
return Logger.getLogger(getClass().getName());
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/Constants.java b/server/src/com/vaadin/terminal/gwt/server/Constants.java
index a04288055e..adf26bf7f7 100644
--- a/server/src/com/vaadin/terminal/gwt/server/Constants.java
+++ b/server/src/com/vaadin/terminal/gwt/server/Constants.java
@@ -65,6 +65,7 @@ public interface Constants {
static final String SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION = "disable-xsrf-protection";
static final String SERVLET_PARAMETER_RESOURCE_CACHE_TIME = "resourceCacheTime";
static final String SERVLET_PARAMETER_HEARTBEAT_RATE = "heartbeatRate";
+ static final String SERVLET_PARAMETER_CLOSE_IDLE_ROOTS = "closeIdleRoots";
// Configurable parameter names
static final String PARAMETER_VAADIN_RESOURCES = "Resources";
@@ -95,5 +96,4 @@ public interface Constants {
static final String PORTAL_PARAMETER_VAADIN_WIDGETSET = "vaadin.widgetset";
static final String PORTAL_PARAMETER_VAADIN_RESOURCE_PATH = "vaadin.resources.path";
static final String PORTAL_PARAMETER_VAADIN_THEME = "vaadin.theme";
-
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
index eba7d6e3a3..a7ee5be96d 100644
--- a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
+++ b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
@@ -404,6 +404,11 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext {
}
}
+ @Override
+ public int getMaxInactiveInterval() {
+ return getPortletSession().getMaxInactiveInterval();
+ }
+
private Logger getLogger() {
return Logger.getLogger(PortletApplicationContext2.class.getName());
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java b/server/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java
index 4cc0ed188d..bfcc0c1038 100644
--- a/server/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java
+++ b/server/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java
@@ -187,4 +187,8 @@ public class WebApplicationContext extends AbstractWebApplicationContext {
return mgr;
}
+ @Override
+ public int getMaxInactiveInterval() {
+ return getHttpSession().getMaxInactiveInterval();
+ }
}