diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-08-20 12:22:27 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-08-21 14:44:22 +0300 |
commit | 3741529097e52114b526fb1598d6d4f70be49b2b (patch) | |
tree | 9496f2639ffdfe62440b2f3c0e160688b809b0b2 /server/src | |
parent | e69c4908ba61b1fd09f0b50ecbc2e0ec11cd06f5 (diff) | |
download | vaadin-framework-3741529097e52114b526fb1598d6d4f70be49b2b.tar.gz vaadin-framework-3741529097e52114b526fb1598d6d4f70be49b2b.zip |
Add heartbeat interval to DeploymentConfiguration, include in bootstrap config (#9265)
Diffstat (limited to 'server/src')
4 files changed, 40 insertions, 5 deletions
diff --git a/server/src/com/vaadin/terminal/DeploymentConfiguration.java b/server/src/com/vaadin/terminal/DeploymentConfiguration.java index 14a5a3724f..550bfdb7cf 100644 --- a/server/src/com/vaadin/terminal/DeploymentConfiguration.java +++ b/server/src/com/vaadin/terminal/DeploymentConfiguration.java @@ -153,4 +153,11 @@ public interface DeploymentConfiguration extends Serializable { * @return The resource cache time. */ public int getResourceCacheTime(); + + /** + * Returns the number of seconds between heartbeat requests of a root. + * + * @return + */ + public int getHeartbeatInterval(); } diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java b/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java index ad5acad5e9..3e7f1eaf71 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java @@ -33,6 +33,7 @@ public abstract class AbstractDeploymentConfiguration implements private boolean productionMode; private boolean xsrfProtectionEnabled; private int resourceCacheTime; + private int heartbeatInterval; public AbstractDeploymentConfiguration(Class<?> systemPropertyBaseClass, Properties applicationProperties) { @@ -42,12 +43,12 @@ public abstract class AbstractDeploymentConfiguration implements checkProductionMode(); checkXsrfProtection(); checkResourceCacheTime(); + checkHeartbeatInterval(); } @Override public String getApplicationOrSystemProperty(String propertyName, String defaultValue) { - String val = null; // Try application properties @@ -178,6 +179,11 @@ public abstract class AbstractDeploymentConfiguration implements return resourceCacheTime; } + @Override + public int getHeartbeatInterval() { + return heartbeatInterval; + } + /** * Log a warning if Vaadin is not running in production mode. */ @@ -218,6 +224,18 @@ public abstract class AbstractDeploymentConfiguration implements } } + private void checkHeartbeatInterval() { + try { + heartbeatInterval = Integer + .parseInt(getApplicationOrSystemProperty( + Constants.SERVLET_PARAMETER_HEARTBEAT_RATE, "500")); + } catch (NumberFormatException e) { + getLogger().warning( + Constants.WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC); + heartbeatInterval = 500; + } + } + private Logger getLogger() { return Logger.getLogger(getClass().getName()); } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index fad80cacaa..de31e4e779 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -170,8 +170,8 @@ public abstract class BootstrapHandler implements RequestHandler { Map<String, Object> headers = new LinkedHashMap<String, Object>(); Document document = Document.createShell(""); BootstrapPageResponse pageResponse = new BootstrapPageResponse( - this, request, context.getApplication(), context.getRootId(), document, - headers); + this, request, context.getApplication(), + context.getRootId(), document, headers); List<Node> fragmentNodes = fragmentResponse.getFragmentNodes(); Element body = document.body(); for (Node node : fragmentNodes) { @@ -274,8 +274,8 @@ public abstract class BootstrapHandler implements RequestHandler { public BootstrapContext createContext(WrappedRequest request, WrappedResponse response, Application application, Integer rootId) { BootstrapContext context = new BootstrapContext(response, - new BootstrapFragmentResponse(this, request, - application, rootId, new ArrayList<Node>())); + new BootstrapFragmentResponse(this, request, application, + rootId, new ArrayList<Node>())); return context; } @@ -500,6 +500,9 @@ public abstract class BootstrapHandler implements RequestHandler { defaults.put("standalone", true); } + defaults.put("heartbeatInterval", + deploymentConfiguration.getHeartbeatInterval()); + defaults.put("appUri", getAppUri(context)); return defaults; diff --git a/server/src/com/vaadin/terminal/gwt/server/Constants.java b/server/src/com/vaadin/terminal/gwt/server/Constants.java index 78c043da69..a04288055e 100644 --- a/server/src/com/vaadin/terminal/gwt/server/Constants.java +++ b/server/src/com/vaadin/terminal/gwt/server/Constants.java @@ -41,6 +41,12 @@ public interface Constants { + "in web.xml. The default of 1h will be used.\n" + "==========================================================="; + static final String WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC = "\n" + + "===========================================================\n" + + "WARNING: heartbeatInterval has been set to a non integer value " + + "in web.xml. The default of 5min will be used.\n" + + "==========================================================="; + static final String WIDGETSET_MISMATCH_INFO = "\n" + "=================================================================\n" + "The widgetset in use does not seem to be built for the Vaadin\n" @@ -58,6 +64,7 @@ public interface Constants { static final String SERVLET_PARAMETER_PRODUCTION_MODE = "productionMode"; 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"; // Configurable parameter names static final String PARAMETER_VAADIN_RESOURCES = "Resources"; |