summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-09-21 13:43:28 +0300
committerVaadin Code Review <review@vaadin.com>2014-09-30 12:39:21 +0000
commitfc18848319f680b664979cca472ada0e0857a79c (patch)
treec67a6b793576a2b289a2229291747e8fc3180711 /server/src/com/vaadin
parent34934d1055d2451a3633d4380648ce661da17ce7 (diff)
downloadvaadin-framework-fc18848319f680b664979cca472ada0e0857a79c.tar.gz
vaadin-framework-fc18848319f680b664979cca472ada0e0857a79c.zip
Dedicated methods for init params in DeploymentConfiguration (#12087).
Change-Id: I3610814509f38ed4c8789de52cc53e7b19a4c4a2
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/server/AbstractDeploymentConfiguration.java54
-rw-r--r--server/src/com/vaadin/server/DefaultDeploymentConfiguration.java3
-rw-r--r--server/src/com/vaadin/server/DefaultUIProvider.java12
-rw-r--r--server/src/com/vaadin/server/DeploymentConfiguration.java32
-rw-r--r--server/src/com/vaadin/server/ServletPortletHelper.java6
-rw-r--r--server/src/com/vaadin/server/VaadinPortletService.java4
-rw-r--r--server/src/com/vaadin/server/VaadinService.java2
-rw-r--r--server/src/com/vaadin/server/VaadinServletService.java7
8 files changed, 97 insertions, 23 deletions
diff --git a/server/src/com/vaadin/server/AbstractDeploymentConfiguration.java b/server/src/com/vaadin/server/AbstractDeploymentConfiguration.java
new file mode 100644
index 0000000000..43d4570d90
--- /dev/null
+++ b/server/src/com/vaadin/server/AbstractDeploymentConfiguration.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.server;
+
+/**
+ * An abstract base class for DeploymentConfiguration implementations. This
+ * class provides default implementation for common config properties.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class AbstractDeploymentConfiguration implements
+ DeploymentConfiguration {
+
+ @Override
+ public String getUIClassName() {
+ return getApplicationOrSystemProperty(VaadinSession.UI_PARAMETER, null);
+ }
+
+ @Override
+ public String getUIProviderClassName() {
+ return getApplicationOrSystemProperty(
+ Constants.SERVLET_PARAMETER_UI_PROVIDER, null);
+ }
+
+ @Override
+ public String getWidgetset(String defaultValue) {
+ return getApplicationOrSystemProperty(Constants.PARAMETER_WIDGETSET,
+ defaultValue);
+ }
+
+ @Override
+ public String getResourcesPath() {
+ return getApplicationOrSystemProperty(
+ Constants.PARAMETER_VAADIN_RESOURCES, null);
+ }
+
+ @Override
+ public String getClassLoaderName() {
+ return getApplicationOrSystemProperty("ClassLoader", null);
+ }
+}
diff --git a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
index fd14c3cd3f..22d5210eaa 100644
--- a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
@@ -29,7 +29,8 @@ import com.vaadin.shared.communication.PushMode;
* @author Vaadin Ltd
* @since 7.0.0
*/
-public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
+public class DefaultDeploymentConfiguration extends
+ AbstractDeploymentConfiguration {
/**
* Default value for {@link #getResourceCacheTime()} = {@value} .
*/
diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java
index 2a1a59dbe6..38525fc020 100644
--- a/server/src/com/vaadin/server/DefaultUIProvider.java
+++ b/server/src/com/vaadin/server/DefaultUIProvider.java
@@ -24,15 +24,9 @@ public class DefaultUIProvider extends UIProvider {
public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
VaadinRequest request = event.getRequest();
- Object uiClassNameObj = request
- .getService()
- .getDeploymentConfiguration()
- .getApplicationOrSystemProperty(VaadinSession.UI_PARAMETER,
- null);
-
- if (uiClassNameObj instanceof String) {
- String uiClassName = uiClassNameObj.toString();
-
+ String uiClassName = request.getService().getDeploymentConfiguration()
+ .getUIClassName();
+ if (uiClassName != null) {
ClassLoader classLoader = request.getService().getClassLoader();
try {
Class<? extends UI> uiClass = Class.forName(uiClassName, true,
diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java
index fcfeecc31f..3124729773 100644
--- a/server/src/com/vaadin/server/DeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DeploymentConfiguration.java
@@ -163,6 +163,38 @@ public interface DeploymentConfiguration extends Serializable {
String defaultValue);
/**
+ * Gets UI class configuration option value.
+ *
+ * @return UI class name
+ */
+ public String getUIClassName();
+
+ /**
+ * Gets UI provider class configuration option value.
+ *
+ * @return UI class name
+ */
+ public String getUIProviderClassName();
+
+ /**
+ * Gets Widgetset configuration option value. {@code defaultValue} is
+ * returned if widgetset parameter is not configured.
+ *
+ * @return UI class name
+ */
+ public String getWidgetset(String defaultValue);
+
+ /**
+ * Gets resources path configuration option value.
+ */
+ public String getResourcesPath();
+
+ /**
+ * Gets class loader configuration option value.
+ */
+ public String getClassLoaderName();
+
+ /**
* Returns to legacy Property.toString() mode used. See
* {@link AbstractProperty#isLegacyToStringEnabled()} for more information.
*
diff --git a/server/src/com/vaadin/server/ServletPortletHelper.java b/server/src/com/vaadin/server/ServletPortletHelper.java
index 2ec747ba3a..197d9fe416 100644
--- a/server/src/com/vaadin/server/ServletPortletHelper.java
+++ b/server/src/com/vaadin/server/ServletPortletHelper.java
@@ -130,8 +130,7 @@ public class ServletPortletHelper implements Serializable {
public static void initDefaultUIProvider(VaadinSession session,
VaadinService vaadinService) throws ServiceException {
String uiProperty = vaadinService.getDeploymentConfiguration()
- .getApplicationOrSystemProperty(VaadinSession.UI_PARAMETER,
- null);
+ .getUIClassName();
// Add provider for UI parameter first to give it lower priority
// (providers are FILO)
@@ -141,8 +140,7 @@ public class ServletPortletHelper implements Serializable {
}
String uiProviderProperty = vaadinService.getDeploymentConfiguration()
- .getApplicationOrSystemProperty(
- Constants.SERVLET_PARAMETER_UI_PROVIDER, null);
+ .getUIProviderClassName();
// Then add custom UI provider if defined
if (uiProviderProperty != null) {
UIProvider uiProvider = getUIProvider(uiProviderProperty,
diff --git a/server/src/com/vaadin/server/VaadinPortletService.java b/server/src/com/vaadin/server/VaadinPortletService.java
index c6d9b8e46a..cff024672c 100644
--- a/server/src/com/vaadin/server/VaadinPortletService.java
+++ b/server/src/com/vaadin/server/VaadinPortletService.java
@@ -124,9 +124,7 @@ public class VaadinPortletService extends VaadinService {
@Override
public String getConfiguredWidgetset(VaadinRequest request) {
- String widgetset = getDeploymentConfiguration()
- .getApplicationOrSystemProperty(
- VaadinPortlet.PARAMETER_WIDGETSET, null);
+ String widgetset = getDeploymentConfiguration().getWidgetset(null);
if (widgetset == null) {
widgetset = getParameter(request,
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 8fd6da8dee..008ba9c1c8 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -155,7 +155,7 @@ public abstract class VaadinService implements Serializable {
this.deploymentConfiguration = deploymentConfiguration;
final String classLoaderName = getDeploymentConfiguration()
- .getApplicationOrSystemProperty("ClassLoader", null);
+ .getClassLoaderName();
if (classLoaderName != null) {
try {
final Class<?> classLoaderClass = getClass().getClassLoader()
diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java
index a4ff3943c9..8946ac4fae 100644
--- a/server/src/com/vaadin/server/VaadinServletService.java
+++ b/server/src/com/vaadin/server/VaadinServletService.java
@@ -118,9 +118,7 @@ public class VaadinServletService extends VaadinService {
VaadinServletRequest servletRequest = (VaadinServletRequest) request;
String staticFileLocation;
// if property is defined in configurations, use that
- staticFileLocation = getDeploymentConfiguration()
- .getApplicationOrSystemProperty(
- VaadinServlet.PARAMETER_VAADIN_RESOURCES, null);
+ staticFileLocation = getDeploymentConfiguration().getResourcesPath();
if (staticFileLocation != null) {
return staticFileLocation;
}
@@ -159,8 +157,7 @@ public class VaadinServletService extends VaadinService {
@Override
public String getConfiguredWidgetset(VaadinRequest request) {
- return getDeploymentConfiguration().getApplicationOrSystemProperty(
- VaadinServlet.PARAMETER_WIDGETSET,
+ return getDeploymentConfiguration().getWidgetset(
VaadinServlet.DEFAULT_WIDGETSET);
}