From: Leif Åstrand Date: Thu, 6 Sep 2012 07:57:39 +0000 (+0300) Subject: Rename ApplicationConfiguration -> DeploymentConfiguration (#9402) X-Git-Tag: 7.0.0.beta1~173 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=201121c5e00ee78d85add849f8b071fce076cc0d;p=vaadin-framework.git Rename ApplicationConfiguration -> DeploymentConfiguration (#9402) --- diff --git a/server/src/com/vaadin/DefaultApplicationConfiguration.java b/server/src/com/vaadin/DefaultApplicationConfiguration.java deleted file mode 100644 index 2e2267193e..0000000000 --- a/server/src/com/vaadin/DefaultApplicationConfiguration.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2011 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; - -import java.util.Properties; -import java.util.logging.Logger; - -import com.vaadin.server.ApplicationConfiguration; -import com.vaadin.server.Constants; - -public class DefaultApplicationConfiguration implements - ApplicationConfiguration { - private final Properties applicationProperties; - private boolean productionMode; - private boolean xsrfProtectionEnabled; - private int resourceCacheTime; - private int heartbeatInterval; - private boolean idleRootCleanupEnabled; - private final Class systemPropertyBaseClass; - - public DefaultApplicationConfiguration(Class systemPropertyBaseClass, - Properties applicationProperties) { - this.applicationProperties = applicationProperties; - this.systemPropertyBaseClass = systemPropertyBaseClass; - - checkProductionMode(); - checkXsrfProtection(); - checkResourceCacheTime(); - checkHeartbeatInterval(); - checkIdleUICleanup(); - } - - @Override - public String getApplicationOrSystemProperty(String propertyName, - String defaultValue) { - String val = null; - - // Try application properties - val = getApplicationProperty(propertyName); - if (val != null) { - return val; - } - - // Try system properties - val = getSystemProperty(propertyName); - if (val != null) { - return val; - } - - return defaultValue; - } - - /** - * Gets an system property value. - * - * @param parameterName - * the Name or the parameter. - * @return String value or null if not found - */ - protected String getSystemProperty(String parameterName) { - String val = null; - - String pkgName; - final Package pkg = systemPropertyBaseClass.getPackage(); - if (pkg != null) { - pkgName = pkg.getName(); - } else { - final String className = systemPropertyBaseClass.getName(); - pkgName = new String(className.toCharArray(), 0, - className.lastIndexOf('.')); - } - val = System.getProperty(pkgName + "." + parameterName); - if (val != null) { - return val; - } - - // Try lowercased system properties - val = System.getProperty(pkgName + "." + parameterName.toLowerCase()); - return val; - } - - /** - * Gets an application property value. - * - * @param parameterName - * the Name or the parameter. - * @return String value or null if not found - */ - public String getApplicationProperty(String parameterName) { - - String val = applicationProperties.getProperty(parameterName); - if (val != null) { - return val; - } - - // Try lower case application properties for backward compatibility with - // 3.0.2 and earlier - val = applicationProperties.getProperty(parameterName.toLowerCase()); - - return val; - } - - /** - * {@inheritDoc} - * - * The default is false. - */ - @Override - public boolean isProductionMode() { - return productionMode; - } - - /** - * {@inheritDoc} - *

- * The default is true. - */ - @Override - public boolean isXsrfProtectionEnabled() { - return xsrfProtectionEnabled; - } - - /** - * {@inheritDoc} - *

- * The default interval is 3600 seconds (1 hour). - */ - @Override - public int getResourceCacheTime() { - return resourceCacheTime; - } - - /** - * {@inheritDoc} - *

- * The default interval is 300 seconds (5 minutes). - */ - @Override - public int getHeartbeatInterval() { - return heartbeatInterval; - } - - @Override - public boolean isIdleUICleanupEnabled() { - return idleRootCleanupEnabled; - } - - /** - * Log a warning if Vaadin is not running in production mode. - */ - private void checkProductionMode() { - productionMode = getApplicationOrSystemProperty( - Constants.SERVLET_PARAMETER_PRODUCTION_MODE, "false").equals( - "true"); - if (!productionMode) { - getLogger().warning(Constants.NOT_PRODUCTION_MODE_INFO); - } - } - - /** - * Log a warning if cross-site request forgery protection is disabled. - */ - private void checkXsrfProtection() { - xsrfProtectionEnabled = !getApplicationOrSystemProperty( - Constants.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, "false") - .equals("true"); - if (!xsrfProtectionEnabled) { - getLogger().warning(Constants.WARNING_XSRF_PROTECTION_DISABLED); - } - } - - /** - * Log a warning if resource cache time is set but is not an integer. - */ - private void checkResourceCacheTime() { - try { - resourceCacheTime = Integer - .parseInt(getApplicationOrSystemProperty( - Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME, - "3600")); - } catch (NumberFormatException e) { - getLogger().warning( - Constants.WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC); - resourceCacheTime = 3600; - } - } - - private void checkHeartbeatInterval() { - try { - heartbeatInterval = Integer - .parseInt(getApplicationOrSystemProperty( - Constants.SERVLET_PARAMETER_HEARTBEAT_RATE, "300")); - } catch (NumberFormatException e) { - getLogger().warning( - Constants.WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC); - heartbeatInterval = 300; - } - } - - private void checkIdleUICleanup() { - idleRootCleanupEnabled = getApplicationOrSystemProperty( - Constants.SERVLET_PARAMETER_CLOSE_IDLE_UIS, "false").equals( - "true"); - } - - private Logger getLogger() { - return Logger.getLogger(getClass().getName()); - } - - @Override - public Properties getInitParameters() { - return applicationProperties; - } - -} diff --git a/server/src/com/vaadin/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/DefaultDeploymentConfiguration.java new file mode 100644 index 0000000000..6159137cc3 --- /dev/null +++ b/server/src/com/vaadin/DefaultDeploymentConfiguration.java @@ -0,0 +1,228 @@ +/* + * Copyright 2011 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; + +import java.util.Properties; +import java.util.logging.Logger; + +import com.vaadin.server.Constants; +import com.vaadin.server.DeploymentConfiguration; + +public class DefaultDeploymentConfiguration implements DeploymentConfiguration { + private final Properties initParameters; + private boolean productionMode; + private boolean xsrfProtectionEnabled; + private int resourceCacheTime; + private int heartbeatInterval; + private boolean idleRootCleanupEnabled; + private final Class systemPropertyBaseClass; + + public DefaultDeploymentConfiguration(Class systemPropertyBaseClass, + Properties initParameters) { + this.initParameters = initParameters; + this.systemPropertyBaseClass = systemPropertyBaseClass; + + checkProductionMode(); + checkXsrfProtection(); + checkResourceCacheTime(); + checkHeartbeatInterval(); + checkIdleUICleanup(); + } + + @Override + public String getApplicationOrSystemProperty(String propertyName, + String defaultValue) { + String val = null; + + // Try application properties + val = getApplicationProperty(propertyName); + if (val != null) { + return val; + } + + // Try system properties + val = getSystemProperty(propertyName); + if (val != null) { + return val; + } + + return defaultValue; + } + + /** + * Gets an system property value. + * + * @param parameterName + * the Name or the parameter. + * @return String value or null if not found + */ + protected String getSystemProperty(String parameterName) { + String val = null; + + String pkgName; + final Package pkg = systemPropertyBaseClass.getPackage(); + if (pkg != null) { + pkgName = pkg.getName(); + } else { + final String className = systemPropertyBaseClass.getName(); + pkgName = new String(className.toCharArray(), 0, + className.lastIndexOf('.')); + } + val = System.getProperty(pkgName + "." + parameterName); + if (val != null) { + return val; + } + + // Try lowercased system properties + val = System.getProperty(pkgName + "." + parameterName.toLowerCase()); + return val; + } + + /** + * Gets an application property value. + * + * @param parameterName + * the Name or the parameter. + * @return String value or null if not found + */ + public String getApplicationProperty(String parameterName) { + + String val = initParameters.getProperty(parameterName); + if (val != null) { + return val; + } + + // Try lower case application properties for backward compatibility with + // 3.0.2 and earlier + val = initParameters.getProperty(parameterName.toLowerCase()); + + return val; + } + + /** + * {@inheritDoc} + * + * The default is false. + */ + @Override + public boolean isProductionMode() { + return productionMode; + } + + /** + * {@inheritDoc} + *

+ * The default is true. + */ + @Override + public boolean isXsrfProtectionEnabled() { + return xsrfProtectionEnabled; + } + + /** + * {@inheritDoc} + *

+ * The default interval is 3600 seconds (1 hour). + */ + @Override + public int getResourceCacheTime() { + return resourceCacheTime; + } + + /** + * {@inheritDoc} + *

+ * The default interval is 300 seconds (5 minutes). + */ + @Override + public int getHeartbeatInterval() { + return heartbeatInterval; + } + + @Override + public boolean isIdleUICleanupEnabled() { + return idleRootCleanupEnabled; + } + + /** + * Log a warning if Vaadin is not running in production mode. + */ + private void checkProductionMode() { + productionMode = getApplicationOrSystemProperty( + Constants.SERVLET_PARAMETER_PRODUCTION_MODE, "false").equals( + "true"); + if (!productionMode) { + getLogger().warning(Constants.NOT_PRODUCTION_MODE_INFO); + } + } + + /** + * Log a warning if cross-site request forgery protection is disabled. + */ + private void checkXsrfProtection() { + xsrfProtectionEnabled = !getApplicationOrSystemProperty( + Constants.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, "false") + .equals("true"); + if (!xsrfProtectionEnabled) { + getLogger().warning(Constants.WARNING_XSRF_PROTECTION_DISABLED); + } + } + + /** + * Log a warning if resource cache time is set but is not an integer. + */ + private void checkResourceCacheTime() { + try { + resourceCacheTime = Integer + .parseInt(getApplicationOrSystemProperty( + Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME, + "3600")); + } catch (NumberFormatException e) { + getLogger().warning( + Constants.WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC); + resourceCacheTime = 3600; + } + } + + private void checkHeartbeatInterval() { + try { + heartbeatInterval = Integer + .parseInt(getApplicationOrSystemProperty( + Constants.SERVLET_PARAMETER_HEARTBEAT_RATE, "300")); + } catch (NumberFormatException e) { + getLogger().warning( + Constants.WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC); + heartbeatInterval = 300; + } + } + + private void checkIdleUICleanup() { + idleRootCleanupEnabled = getApplicationOrSystemProperty( + Constants.SERVLET_PARAMETER_CLOSE_IDLE_UIS, "false").equals( + "true"); + } + + private Logger getLogger() { + return Logger.getLogger(getClass().getName()); + } + + @Override + public Properties getInitParameters() { + return initParameters; + } + +} diff --git a/server/src/com/vaadin/server/AbstractVaadinService.java b/server/src/com/vaadin/server/AbstractVaadinService.java index 516ce23333..dc6342b299 100644 --- a/server/src/com/vaadin/server/AbstractVaadinService.java +++ b/server/src/com/vaadin/server/AbstractVaadinService.java @@ -23,21 +23,20 @@ import java.util.ServiceLoader; public abstract class AbstractVaadinService implements VaadinService { private AddonContext addonContext; - private final ApplicationConfiguration applicationConfiguration; + private final DeploymentConfiguration deploymentConfiguration; - public AbstractVaadinService( - ApplicationConfiguration applicationConfiguration) { - this.applicationConfiguration = applicationConfiguration; + public AbstractVaadinService(DeploymentConfiguration deploymentConfiguration) { + this.deploymentConfiguration = deploymentConfiguration; } @Override - public ApplicationConfiguration getApplicationConfiguration() { - return applicationConfiguration; + public DeploymentConfiguration getDeploymentConfiguration() { + return deploymentConfiguration; } @Override public ClassLoader getClassLoader() { - final String classLoaderName = getApplicationConfiguration() + final String classLoaderName = getDeploymentConfiguration() .getApplicationOrSystemProperty("ClassLoader", null); ClassLoader classLoader; if (classLoaderName == null) { diff --git a/server/src/com/vaadin/server/ApplicationConfiguration.java b/server/src/com/vaadin/server/ApplicationConfiguration.java deleted file mode 100644 index dfb202f3fa..0000000000 --- a/server/src/com/vaadin/server/ApplicationConfiguration.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2011 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; - -import java.util.Properties; - -/** - * A collection of properties configured for all applications as well as a way - * of accessing third party properties not explicitely supported by this class. - * - * @author Vaadin Ltd - * @version @VERSION@ - * @since 7.0.0 - */ -public interface ApplicationConfiguration { - /** - * Returns whether Vaadin is in production mode. - * - * @return true if in production mode, false otherwise. - */ - public boolean isProductionMode(); - - /** - * Returns whether cross-site request forgery protection is enabled. - * - * @return true if XSRF protection is enabled, false otherwise. - */ - public boolean isXsrfProtectionEnabled(); - - /** - * Returns the time resources can be cached in the browsers, in seconds. - * - * @return The resource cache time. - */ - public int getResourceCacheTime(); - - /** - * Returns the number of seconds between heartbeat requests of a UI, or a - * non-positive number if heartbeat is disabled. - * - * @return The time between heartbeats. - */ - public int getHeartbeatInterval(); - - /** - * Returns whether UIs that have no other activity than heartbeat requests - * should be closed after they have been idle the maximum inactivity time - * enforced by the session. - * - * @see WrappedSession#getMaxInactiveInterval() - * - * @since 7.0.0 - * - * @return True if UIs receiving only heartbeat requests are eventually - * closed; false if heartbeat requests extend UI lifetime - * indefinitely. - */ - public boolean isIdleUICleanupEnabled(); - - /** - * Gets the properties configured for the deployment, e.g. as init - * parameters to the servlet or portlet. - * - * @return properties for the application. - */ - public Properties getInitParameters(); - - /** - * Gets a configured property. The properties are typically read from e.g. - * web.xml or from system properties of the JVM. - * - * @param propertyName - * The simple of the property, in some contexts, lookup might be - * performed using variations of the provided name. - * @param defaultValue - * the default value that should be used if no value has been - * defined - * @return the property value, or the passed default value if no property - * value is found - */ - public String getApplicationOrSystemProperty(String propertyName, - String defaultValue); - -} diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 37b9649e55..4ebac73b6b 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -459,7 +459,7 @@ public abstract class BootstrapHandler implements RequestHandler { } defaults.put("heartbeatInterval", vaadinService - .getApplicationConfiguration().getHeartbeatInterval()); + .getDeploymentConfiguration().getHeartbeatInterval()); defaults.put("appUri", getAppUri(context)); diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java new file mode 100644 index 0000000000..0333091632 --- /dev/null +++ b/server/src/com/vaadin/server/DeploymentConfiguration.java @@ -0,0 +1,99 @@ +/* + * Copyright 2011 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; + +import java.io.Serializable; +import java.util.Properties; + +/** + * A collection of properties configured at deploy time as well as a way of + * accessing third party properties not explicitly supported by this class. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public interface DeploymentConfiguration extends Serializable { + /** + * Returns whether Vaadin is in production mode. + * + * @return true if in production mode, false otherwise. + */ + public boolean isProductionMode(); + + /** + * Returns whether cross-site request forgery protection is enabled. + * + * @return true if XSRF protection is enabled, false otherwise. + */ + public boolean isXsrfProtectionEnabled(); + + /** + * Returns the time resources can be cached in the browsers, in seconds. + * + * @return The resource cache time. + */ + public int getResourceCacheTime(); + + /** + * Returns the number of seconds between heartbeat requests of a UI, or a + * non-positive number if heartbeat is disabled. + * + * @return The time between heartbeats. + */ + public int getHeartbeatInterval(); + + /** + * Returns whether UIs that have no other activity than heartbeat requests + * should be closed after they have been idle the maximum inactivity time + * enforced by the session. + * + * @see WrappedSession#getMaxInactiveInterval() + * + * @since 7.0.0 + * + * @return True if UIs receiving only heartbeat requests are eventually + * closed; false if heartbeat requests extend UI lifetime + * indefinitely. + */ + public boolean isIdleUICleanupEnabled(); + + /** + * Gets the properties configured for the deployment, e.g. as init + * parameters to the servlet or portlet. + * + * @return properties for the application. + */ + public Properties getInitParameters(); + + /** + * Gets a configured property. The properties are typically read from e.g. + * web.xml or from system properties of the JVM. + * + * @param propertyName + * The simple of the property, in some contexts, lookup might be + * performed using variations of the provided name. + * @param defaultValue + * the default value that should be used if no value has been + * defined + * @return the property value, or the passed default value if no property + * value is found + */ + public String getApplicationOrSystemProperty(String propertyName, + String defaultValue); + +} diff --git a/server/src/com/vaadin/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java index 5b6948e2e3..fe22ea770e 100644 --- a/server/src/com/vaadin/server/PortletCommunicationManager.java +++ b/server/src/com/vaadin/server/PortletCommunicationManager.java @@ -129,7 +129,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { protected String getMainDivStyle(BootstrapContext context) { VaadinService vaadinService = context.getRequest() .getVaadinService(); - return vaadinService.getApplicationConfiguration() + return vaadinService.getDeploymentConfiguration() .getApplicationOrSystemProperty( VaadinPortlet.PORTLET_PARAMETER_STYLE, null); } diff --git a/server/src/com/vaadin/server/ServletPortletHelper.java b/server/src/com/vaadin/server/ServletPortletHelper.java index f964415fdc..e7e4c813ce 100644 --- a/server/src/com/vaadin/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/server/ServletPortletHelper.java @@ -43,7 +43,7 @@ class ServletPortletHelper implements Serializable { static Class getLegacyApplicationClass( VaadinService vaadinService) throws ApplicationClassException { - Properties initParameters = vaadinService.getApplicationConfiguration() + Properties initParameters = vaadinService.getDeploymentConfiguration() .getInitParameters(); String applicationParameter = initParameters.getProperty("application"); ClassLoader classLoader = vaadinService.getClassLoader(); @@ -133,7 +133,7 @@ class ServletPortletHelper implements Serializable { public static void initDefaultUIProvider(VaadinSession application, VaadinService vaadinService) throws ApplicationClassException { - String uiProperty = vaadinService.getApplicationConfiguration() + String uiProperty = vaadinService.getDeploymentConfiguration() .getInitParameters().getProperty(VaadinSession.UI_PARAMETER); if (uiProperty != null) { verifyUIClass(uiProperty, vaadinService.getClassLoader()); diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index be571fbf60..4c902252c9 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -55,7 +55,7 @@ import javax.servlet.http.HttpServletResponse; import com.liferay.portal.kernel.util.PortalClassInvoker; import com.liferay.portal.kernel.util.PropsUtil; -import com.vaadin.DefaultApplicationConfiguration; +import com.vaadin.DefaultDeploymentConfiguration; import com.vaadin.server.AbstractCommunicationManager.Callback; import com.vaadin.server.ServletPortletHelper.ApplicationClassException; import com.vaadin.server.VaadinSession.ApplicationStartEvent; @@ -78,8 +78,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { private final VaadinPortlet portlet; public PortletService(VaadinPortlet portlet, - ApplicationConfiguration applicationConfiguration) { - super(applicationConfiguration); + DeploymentConfiguration deploymentConfiguration) { + super(deploymentConfiguration); this.portlet = portlet; } @@ -90,7 +90,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { @Override public String getConfiguredWidgetset(WrappedRequest request) { - String widgetset = getApplicationConfiguration() + String widgetset = getDeploymentConfiguration() .getApplicationOrSystemProperty(PARAMETER_WIDGETSET, null); if (widgetset == null) { @@ -324,41 +324,38 @@ public class VaadinPortlet extends GenericPortlet implements Constants { @Override public void init(PortletConfig config) throws PortletException { super.init(config); - Properties applicationProperties = new Properties(); + Properties initParameters = new Properties(); // Read default parameters from the context final PortletContext context = config.getPortletContext(); for (final Enumeration e = context.getInitParameterNames(); e .hasMoreElements();) { final String name = e.nextElement(); - applicationProperties.setProperty(name, - context.getInitParameter(name)); + initParameters.setProperty(name, context.getInitParameter(name)); } // Override with application settings from portlet.xml for (final Enumeration e = config.getInitParameterNames(); e .hasMoreElements();) { final String name = e.nextElement(); - applicationProperties.setProperty(name, - config.getInitParameter(name)); + initParameters.setProperty(name, config.getInitParameter(name)); } - ApplicationConfiguration applicationConfiguration = createApplicationConfiguration(applicationProperties); - vaadinService = createPortletService(applicationConfiguration); + DeploymentConfiguration deploymentConfiguration = createDeploymentConfiguration(initParameters); + vaadinService = createPortletService(deploymentConfiguration); addonContext = new AddonContext(vaadinService); addonContext.init(); } - protected ApplicationConfiguration createApplicationConfiguration( - Properties applicationProperties) { - return new DefaultApplicationConfiguration(getClass(), - applicationProperties); + protected DeploymentConfiguration createDeploymentConfiguration( + Properties initParameters) { + return new DefaultDeploymentConfiguration(getClass(), initParameters); } protected PortletService createPortletService( - ApplicationConfiguration applicationConfiguration) { - return new PortletService(this, applicationConfiguration); + DeploymentConfiguration deploymentConfiguration) { + return new PortletService(this, deploymentConfiguration); } @Override @@ -830,8 +827,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { newApplication.setLocale(locale); // No application URL when running inside a portlet newApplication.start(new ApplicationStartEvent(null, getVaadinService() - .getApplicationConfiguration(), - new PortletCommunicationManager(newApplication))); + .getDeploymentConfiguration(), new PortletCommunicationManager( + newApplication))); addonContext.fireApplicationStarted(newApplication); return newApplication; diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 41c864fcd9..1e9a2667c3 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -106,11 +106,11 @@ public interface VaadinService extends Serializable { public String getMimeType(String resourceName); /** - * Gets the application configuration. + * Gets the deployment configuration. * - * @return the application configuration + * @return the deployment configuration */ - public ApplicationConfiguration getApplicationConfiguration(); + public DeploymentConfiguration getDeploymentConfiguration(); public Iterator getAddonContextListeners(); diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index ce436205d8..ff58c8da99 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -44,7 +44,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import com.vaadin.DefaultApplicationConfiguration; +import com.vaadin.DefaultDeploymentConfiguration; import com.vaadin.server.AbstractCommunicationManager.Callback; import com.vaadin.server.ServletPortletHelper.ApplicationClassException; import com.vaadin.server.VaadinSession.ApplicationStartEvent; @@ -59,8 +59,8 @@ public class VaadinServlet extends HttpServlet implements Constants { private final VaadinServlet servlet; public ServletService(VaadinServlet servlet, - ApplicationConfiguration applicationProperties) { - super(applicationProperties); + DeploymentConfiguration deploymentConfiguration) { + super(deploymentConfiguration); this.servlet = servlet; } @@ -74,7 +74,7 @@ public class VaadinServlet extends HttpServlet implements Constants { .cast(request); String staticFileLocation; // if property is defined in configurations, use that - staticFileLocation = getApplicationConfiguration() + staticFileLocation = getDeploymentConfiguration() .getApplicationOrSystemProperty(PARAMETER_VAADIN_RESOURCES, null); if (staticFileLocation != null) { @@ -112,10 +112,9 @@ public class VaadinServlet extends HttpServlet implements Constants { @Override public String getConfiguredWidgetset(WrappedRequest request) { - return getApplicationConfiguration() - .getApplicationOrSystemProperty( - VaadinServlet.PARAMETER_WIDGETSET, - VaadinServlet.DEFAULT_WIDGETSET); + return getDeploymentConfiguration().getApplicationOrSystemProperty( + VaadinServlet.PARAMETER_WIDGETSET, + VaadinServlet.DEFAULT_WIDGETSET); } @Override @@ -193,41 +192,39 @@ public class VaadinServlet extends HttpServlet implements Constants { public void init(javax.servlet.ServletConfig servletConfig) throws javax.servlet.ServletException { super.init(servletConfig); - Properties applicationProperties = new Properties(); + Properties initParameters = new Properties(); // Read default parameters from server.xml final ServletContext context = servletConfig.getServletContext(); for (final Enumeration e = context.getInitParameterNames(); e .hasMoreElements();) { final String name = e.nextElement(); - applicationProperties.setProperty(name, - context.getInitParameter(name)); + initParameters.setProperty(name, context.getInitParameter(name)); } // Override with application config from web.xml for (final Enumeration e = servletConfig .getInitParameterNames(); e.hasMoreElements();) { final String name = e.nextElement(); - applicationProperties.setProperty(name, + initParameters.setProperty(name, servletConfig.getInitParameter(name)); } - ApplicationConfiguration applicationConfiguration = createApplicationConfiguration(applicationProperties); - servletService = createServletService(applicationConfiguration); + DeploymentConfiguration deploymentConfiguration = createDeploymentConfiguration(initParameters); + servletService = createServletService(deploymentConfiguration); addonContext = new AddonContext(servletService); addonContext.init(); } - protected ApplicationConfiguration createApplicationConfiguration( - Properties applicationProperties) { - return new DefaultApplicationConfiguration(getClass(), - applicationProperties); + protected DeploymentConfiguration createDeploymentConfiguration( + Properties initParameters) { + return new DefaultDeploymentConfiguration(getClass(), initParameters); } protected ServletService createServletService( - ApplicationConfiguration applicationConfiguration) { - return new ServletService(this, applicationConfiguration); + DeploymentConfiguration deploymentConfiguration) { + return new ServletService(this, deploymentConfiguration); } @Override @@ -642,7 +639,7 @@ public class VaadinServlet extends HttpServlet implements Constants { Locale locale = request.getLocale(); newApplication.setLocale(locale); newApplication.start(new ApplicationStartEvent(applicationUrl, - getVaadinService().getApplicationConfiguration(), + getVaadinService().getDeploymentConfiguration(), createCommunicationManager(newApplication))); addonContext.fireApplicationStarted(newApplication); @@ -1008,7 +1005,7 @@ public class VaadinServlet extends HttpServlet implements Constants { * parameter in web.xml */ int resourceCacheTime = getVaadinService() - .getApplicationConfiguration().getResourceCacheTime(); + .getDeploymentConfiguration().getResourceCacheTime(); response.setHeader("Cache-Control", "max-age= " + String.valueOf(resourceCacheTime)); } diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index c4b0680c47..52a7cd72ee 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -128,7 +128,7 @@ public class VaadinSession implements Terminal.ErrorListener, public static class ApplicationStartEvent implements Serializable { private final URL applicationUrl; - private final ApplicationConfiguration configuration; + private final DeploymentConfiguration configuration; private final AbstractCommunicationManager communicationManager; @@ -141,7 +141,7 @@ public class VaadinSession implements Terminal.ErrorListener, * the communication manager for the application. */ public ApplicationStartEvent(URL applicationUrl, - ApplicationConfiguration configuration, + DeploymentConfiguration configuration, AbstractCommunicationManager communicationManager) { this.applicationUrl = applicationUrl; this.configuration = configuration; @@ -161,11 +161,11 @@ public class VaadinSession implements Terminal.ErrorListener, } /** - * Returns the application configuration used by this application. + * Returns the deployment configuration used by this session. * * @return the deployment configuration. */ - public ApplicationConfiguration getConfiguration() { + public DeploymentConfiguration getConfiguration() { return configuration; } @@ -187,7 +187,7 @@ public class VaadinSession implements Terminal.ErrorListener, /** * Configuration for the application. */ - private ApplicationConfiguration configuration; + private DeploymentConfiguration configuration; /** * The application's URL. @@ -421,7 +421,7 @@ public class VaadinSession implements Terminal.ErrorListener, * * @return the application configuration */ - public ApplicationConfiguration getConfiguration() { + public DeploymentConfiguration getConfiguration() { return configuration; } @@ -1885,7 +1885,7 @@ public class VaadinSession implements Terminal.ErrorListener, * * @see #getUidlRequestTimeout() * @see #closeInactiveUIs() - * @see ApplicationConfiguration#getHeartbeatInterval() + * @see DeploymentConfiguration#getHeartbeatInterval() * * @since 7.0.0 * @@ -1907,7 +1907,7 @@ public class VaadinSession implements Terminal.ErrorListener, * otherwise heartbeat requests are enough to extend UI lifetime * indefinitely. * - * @see ApplicationConfiguration#isIdleUICleanupEnabled() + * @see DeploymentConfiguration#isIdleUICleanupEnabled() * @see #getHeartbeatTimeout() * @see #closeInactiveUIs() * diff --git a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java index d8d1521a4c..e949df466d 100644 --- a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java +++ b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java @@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletRequest; import junit.framework.TestCase; -import com.vaadin.DefaultApplicationConfiguration; +import com.vaadin.DefaultDeploymentConfiguration; import com.vaadin.server.VaadinServlet.ServletService; public class TestAbstractApplicationServletStaticFilesLocation extends TestCase { @@ -32,7 +32,7 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase Field f = VaadinServlet.class.getDeclaredField("servletService"); f.setAccessible(true); f.set(servlet, new ServletService(servlet, - new DefaultApplicationConfiguration(servlet.getClass(), + new DefaultDeploymentConfiguration(servlet.getClass(), new Properties()))); } diff --git a/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java b/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java index acc89895ef..707eb577cc 100644 --- a/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java +++ b/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java @@ -8,8 +8,8 @@ import junit.framework.TestCase; import org.easymock.EasyMock; -import com.vaadin.DefaultApplicationConfiguration; -import com.vaadin.server.ApplicationConfiguration; +import com.vaadin.DefaultDeploymentConfiguration; +import com.vaadin.server.DeploymentConfiguration; import com.vaadin.server.DefaultUIProvider; import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinSession; @@ -64,10 +64,10 @@ public class CustomUIClassLoader extends TestCase { assertEquals(MyUI.class, uiClass); } - private static ApplicationConfiguration createConfigurationMock() { + private static DeploymentConfiguration createConfigurationMock() { Properties properties = new Properties(); properties.put(VaadinSession.UI_PARAMETER, MyUI.class.getName()); - return new DefaultApplicationConfiguration(CustomUIClassLoader.class, + return new DefaultDeploymentConfiguration(CustomUIClassLoader.class, properties); } @@ -115,7 +115,7 @@ public class CustomUIClassLoader extends TestCase { private VaadinSession createStubApplication() { return new VaadinSession() { @Override - public ApplicationConfiguration getConfiguration() { + public DeploymentConfiguration getConfiguration() { return createConfigurationMock(); } }; diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index 230a7b9230..b483a9fd9d 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; import com.vaadin.server.AbstractUIProvider; -import com.vaadin.server.ApplicationConfiguration; +import com.vaadin.server.DeploymentConfiguration; import com.vaadin.server.LegacyVaadinServlet; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinServletSession; @@ -270,8 +270,8 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { @Override protected ServletService createServletService( - ApplicationConfiguration applicationConfiguration) { - return new ServletService(this, applicationConfiguration) { + DeploymentConfiguration deploymentConfiguration) { + return new ServletService(this, deploymentConfiguration) { @Override public String getStaticFileLocation(WrappedRequest request) { URIS uris = getApplicationRunnerURIs(WrappedHttpServletRequest