aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-04-08 13:39:25 +0300
committerVaadin Code Review <review@vaadin.com>2013-04-09 07:17:29 +0000
commitb074fa31126279a009d628f2ab873e661c5fec0a (patch)
treed0d081b2ec33cb799e92f4df001ccd8b44ca68f8 /server
parent87888f166123d377ba44e801066f8858b9d33eda (diff)
downloadvaadin-framework-b074fa31126279a009d628f2ab873e661c5fec0a.tar.gz
vaadin-framework-b074fa31126279a009d628f2ab873e661c5fec0a.zip
Show message for missing Atmosphere or version mismatch (#11499)
Change-Id: I05ed55319092248db4a3f2d0975f918c9176a6c6
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/Constants.java21
-rw-r--r--server/src/com/vaadin/server/DefaultDeploymentConfiguration.java25
-rw-r--r--server/tests/src/com/vaadin/tests/server/TestAtmosphereVersion.java18
3 files changed, 64 insertions, 0 deletions
diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java
index d0f8507c94..4880bc84c0 100644
--- a/server/src/com/vaadin/server/Constants.java
+++ b/server/src/com/vaadin/server/Constants.java
@@ -63,6 +63,27 @@ public interface Constants {
+ " Widgetset version: %s\n"
+ "=================================================================";
+ static final String REQUIRED_ATMOSPHERE_VERSION = "1.0.12";
+
+ static final String INVALID_ATMOSPHERE_VERSION_WARNING = "\n"
+ + "=================================================================\n"
+ + "With push enabled, Vaadin depends on Atomsphere {0} but\n"
+ + "version {1} was found. This might cause compatibility\n"
+ + "problems.\n"
+ + "=================================================================";
+
+ static final String ATMOSPHERE_MISSING_ERROR = "\n"
+ + "=================================================================\n"
+ + "Atmosphere could not be loaded. When using push with Vaadin, the\n"
+ + "Atmosphere framework must be present on the classpath.\n"
+ + "If using a dependency management system, please add a dependency\n"
+ + "to vaadin-push.\n"
+ + "If managing dependencies manually, please make sure Atmosphere\n"
+ + REQUIRED_ATMOSPHERE_VERSION
+ + " is included on the classpath.\n"
+ + "Push will be disabled.\n"
+ + "=================================================================";
+
static final String URL_PARAMETER_THEME = "theme";
static final String SERVLET_PARAMETER_PRODUCTION_MODE = "productionMode";
diff --git a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
index d11bd69997..a6f06b6a79 100644
--- a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
@@ -17,8 +17,11 @@
package com.vaadin.server;
import java.util.Properties;
+import java.util.logging.Level;
import java.util.logging.Logger;
+import org.atmosphere.util.Version;
+
import com.vaadin.shared.communication.PushMode;
/**
@@ -265,6 +268,28 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
getLogger().warning(Constants.WARNING_PUSH_MODE_NOT_RECOGNIZED);
pushMode = PushMode.DISABLED;
}
+
+ if (pushMode != PushMode.DISABLED && !checkAtomsphereVersion()) {
+ pushMode = PushMode.DISABLED;
+ }
+ }
+
+ private boolean checkAtomsphereVersion() {
+ try {
+ String rawVersion = Version.getRawVersion();
+ if (!Constants.REQUIRED_ATMOSPHERE_VERSION.equals(rawVersion)) {
+ getLogger().log(
+ Level.WARNING,
+ Constants.INVALID_ATMOSPHERE_VERSION_WARNING,
+ new Object[] { Constants.REQUIRED_ATMOSPHERE_VERSION,
+ rawVersion });
+ }
+ return true;
+ } catch (NoClassDefFoundError e) {
+ getLogger()
+ .log(Level.SEVERE, Constants.ATMOSPHERE_MISSING_ERROR, e);
+ return false;
+ }
}
private Logger getLogger() {
diff --git a/server/tests/src/com/vaadin/tests/server/TestAtmosphereVersion.java b/server/tests/src/com/vaadin/tests/server/TestAtmosphereVersion.java
new file mode 100644
index 0000000000..5c27ef0752
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/TestAtmosphereVersion.java
@@ -0,0 +1,18 @@
+package com.vaadin.tests.server;
+
+import junit.framework.TestCase;
+
+import org.atmosphere.util.Version;
+
+import com.vaadin.server.Constants;
+
+public class TestAtmosphereVersion extends TestCase {
+ /**
+ * Test that the atmosphere version constant matches the version on our
+ * classpath
+ */
+ public void testAtmosphereVersion() {
+ assertEquals(Constants.REQUIRED_ATMOSPHERE_VERSION,
+ Version.getRawVersion());
+ }
+}