Change-Id: I05ed55319092248db4a3f2d0975f918c9176a6c6tags/7.1.0.beta1
@@ -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"; |
@@ -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() { |
@@ -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()); | |||
} | |||
} |