summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/com/vaadin/server/DefaultDeploymentConfiguration.java33
-rw-r--r--server/src/com/vaadin/server/DeploymentConfiguration.java24
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java32
3 files changed, 70 insertions, 19 deletions
diff --git a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
index 993d60133b..519d81eb6d 100644
--- a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
@@ -86,27 +86,24 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
}
private void checkLegacyPropertyToString() {
- // Verify that the default value has not changed without also
- // updating logic here
- assert DEFAULT_LEGACY_PROPERTY_TO_STRING == LegacyProperyToStringMode.WARNING;
-
String param = getApplicationOrSystemProperty(
- Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING, "warning");
-
- if ("true".equals(param)) {
- legacyPropertyToStringMode = LegacyProperyToStringMode.ENABLED;
- } else if ("false".equals(param)) {
- legacyPropertyToStringMode = LegacyProperyToStringMode.DISABLED;
- } else {
- if (!"warning".equals(param)) {
- getLogger()
- .log(Level.WARNING,
- Constants.WARNING_UNKNOWN_LEGACY_PROPERTY_TOSTRING_VALUE,
- param);
-
+ Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING,
+ DEFAULT_LEGACY_PROPERTY_TO_STRING.getPropertyString());
+
+ for (LegacyProperyToStringMode mode : LegacyProperyToStringMode
+ .values()) {
+ if (mode.getPropertyString().equals(param)) {
+ legacyPropertyToStringMode = mode;
+ return;
}
- legacyPropertyToStringMode = DEFAULT_LEGACY_PROPERTY_TO_STRING;
}
+
+ getLogger()
+ .log(Level.WARNING,
+ Constants.WARNING_UNKNOWN_LEGACY_PROPERTY_TOSTRING_VALUE,
+ param);
+
+ legacyPropertyToStringMode = DEFAULT_LEGACY_PROPERTY_TO_STRING;
}
@Override
diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java
index bf9c019b6d..8c24379db3 100644
--- a/server/src/com/vaadin/server/DeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DeploymentConfiguration.java
@@ -40,7 +40,29 @@ public interface DeploymentConfiguration extends Serializable {
*/
@Deprecated
public enum LegacyProperyToStringMode {
- DISABLED, WARNING, ENABLED;
+ DISABLED("false"), WARNING("warning"), ENABLED("true");
+
+ private final String propertyString;
+
+ private LegacyProperyToStringMode(String propertyString) {
+ this.propertyString = propertyString;
+ }
+
+ /**
+ * Gets the string that should be used in e.g. web.xml for selecting
+ * this mode.
+ *
+ * @return the property value
+ */
+ public String getPropertyString() {
+ return propertyString;
+ }
+
+ @Override
+ public String toString() {
+ // Used by VaadinServlet.readConfigurationAnnotation()
+ return getPropertyString();
+ }
public boolean useLegacyMode() {
return this == WARNING || this == ENABLED;
diff --git a/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java b/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java
index 3098970e6a..58b44dc3db 100644
--- a/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServletConfigurationTest.java
@@ -70,6 +70,28 @@ public class VaadinServletConfigurationTest {
}
@Test
+ public void testLegacyEnabledAnnotation() throws ServletException {
+ VaadinServlet servlet = new LegacyPropertyEnabledTestServlet();
+ servlet.init(new MockServletConfig());
+ DeploymentConfiguration configuration = servlet.getService()
+ .getDeploymentConfiguration();
+
+ Assert.assertEquals(LegacyProperyToStringMode.ENABLED,
+ configuration.getLegacyPropertyToStringMode());
+ }
+
+ @Test
+ public void testLegacyWarningAnnotation() throws ServletException {
+ VaadinServlet servlet = new LegacyPropertyWarningTestServlet();
+ servlet.init(new MockServletConfig());
+ DeploymentConfiguration configuration = servlet.getService()
+ .getDeploymentConfiguration();
+
+ Assert.assertEquals(LegacyProperyToStringMode.WARNING,
+ configuration.getLegacyPropertyToStringMode());
+ }
+
+ @Test
public void testValuesOverriddenForServlet() throws ServletException {
Properties servletInitParams = new Properties();
servletInitParams.setProperty("productionMode", "false");
@@ -102,3 +124,13 @@ public class VaadinServletConfigurationTest {
class TestServlet extends VaadinServlet {
}
+
+@VaadinServletConfiguration(productionMode = true, ui = MockUIContainingServlet.class, legacyPropertyToStringMode = LegacyProperyToStringMode.WARNING)
+class LegacyPropertyWarningTestServlet extends VaadinServlet {
+
+}
+
+@VaadinServletConfiguration(productionMode = true, ui = MockUIContainingServlet.class, legacyPropertyToStringMode = LegacyProperyToStringMode.ENABLED)
+class LegacyPropertyEnabledTestServlet extends VaadinServlet {
+
+}