diff options
17 files changed, 76 insertions, 164 deletions
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 58a125c10f..70c875b10c 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -25,10 +25,10 @@ <servlet-class>com.vaadin.launcher.ApplicationRunnerServlet</servlet-class> </servlet> - <!-- For testing GAE - the deployment script changes this to use GAEApplicationServlet --> + <!-- For testing GAE - the deployment script changes this to use GAEVaadinServlet --> <servlet> <servlet-name>IntegrationTest</servlet-name> - <servlet-class>com.vaadin.server.ApplicationServlet</servlet-class> + <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> <init-param> <param-name>application</param-name> <param-value>com.vaadin.tests.integration.IntegrationTestApplication</param-value> diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java index 0bb9bf1989..f620a39a70 100644 --- a/client/src/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/client/ApplicationConfiguration.java @@ -146,7 +146,7 @@ public class ApplicationConfiguration implements EntryPoint { * * @return a string with the version * - * @see com.vaadin.server.AbstractApplicationServlet#VERSION + * @see com.vaadin.server.VaadinServlet#VERSION */ private native String getVaadinVersion() /*-{ diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index 8a043154d7..2af3c6a59f 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -48,7 +48,6 @@ import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.ConverterFactory; import com.vaadin.data.util.converter.DefaultConverterFactory; import com.vaadin.event.EventRouter; -import com.vaadin.server.AbstractApplicationServlet; import com.vaadin.server.AbstractErrorMessage; import com.vaadin.server.ApplicationContext; import com.vaadin.server.BootstrapFragmentResponse; @@ -64,6 +63,7 @@ import com.vaadin.server.RequestHandler; import com.vaadin.server.ServletApplicationContext; import com.vaadin.server.Terminal; import com.vaadin.server.UIProvider; +import com.vaadin.server.VaadinServlet; import com.vaadin.server.VariableOwner; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedRequest.BrowserDetails; @@ -1728,7 +1728,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * Handles a request by passing it to each registered {@link RequestHandler} * in turn until one produces a response. This method is used for requests * that have not been handled by any specific functionality in the terminal - * implementation (e.g. {@link AbstractApplicationServlet}). + * implementation (e.g. {@link VaadinServlet}). * <p> * The request handlers are invoked in the revere order in which they were * added to the application until a response has been produced. This means diff --git a/server/src/com/vaadin/data/Validator.java b/server/src/com/vaadin/data/Validator.java index 1755a44920..421d88f574 100644 --- a/server/src/com/vaadin/data/Validator.java +++ b/server/src/com/vaadin/data/Validator.java @@ -18,7 +18,7 @@ package com.vaadin.data; import java.io.Serializable; -import com.vaadin.server.AbstractApplicationServlet; +import com.vaadin.server.VaadinServlet; /** * Interface that implements a method for validating if an {@link Object} is @@ -144,8 +144,7 @@ public interface Validator extends Serializable { * Note that this API may change in future versions. */ public String getHtmlMessage() { - return AbstractApplicationServlet - .safeEscapeForHtml(getLocalizedMessage()); + return VaadinServlet.safeEscapeForHtml(getLocalizedMessage()); } /** diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 740ecf843b..2e42f51249 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -1484,7 +1484,7 @@ public abstract class AbstractCommunicationManager implements Serializable { themeName = requestThemeName; } if (themeName == null) { - themeName = AbstractApplicationServlet.getDefaultTheme(); + themeName = VaadinServlet.getDefaultTheme(); } return themeName; } @@ -1502,7 +1502,7 @@ public abstract class AbstractCommunicationManager implements Serializable { public boolean isXSRFEnabled(Application application) { return !"true" .equals(application - .getProperty(AbstractApplicationServlet.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION)); + .getProperty(VaadinServlet.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION)); } /** diff --git a/server/src/com/vaadin/server/AbstractErrorMessage.java b/server/src/com/vaadin/server/AbstractErrorMessage.java index 0928ea4bd4..4e30dff06f 100644 --- a/server/src/com/vaadin/server/AbstractErrorMessage.java +++ b/server/src/com/vaadin/server/AbstractErrorMessage.java @@ -109,12 +109,11 @@ public abstract class AbstractErrorMessage implements ErrorMessage { String result = null; switch (getMode()) { case TEXT: - result = AbstractApplicationServlet.safeEscapeForHtml(getMessage()); + result = VaadinServlet.safeEscapeForHtml(getMessage()); break; case PREFORMATTED: - result = "<pre>" - + AbstractApplicationServlet - .safeEscapeForHtml(getMessage()) + "</pre>"; + result = "<pre>" + VaadinServlet.safeEscapeForHtml(getMessage()) + + "</pre>"; break; case XHTML: result = getMessage(); diff --git a/server/src/com/vaadin/server/ApplicationServlet.java b/server/src/com/vaadin/server/ApplicationServlet.java deleted file mode 100644 index 905b48d62f..0000000000 --- a/server/src/com/vaadin/server/ApplicationServlet.java +++ /dev/null @@ -1,85 +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 javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - -import com.vaadin.Application; -import com.vaadin.server.ServletPortletHelper.ApplicationClassException; - -/** - * This servlet connects a Vaadin Application to Web. - * - * @author Vaadin Ltd. - * @since 5.0 - */ - -@SuppressWarnings("serial") -public class ApplicationServlet extends AbstractApplicationServlet { - - // Private fields - private Class<? extends Application> applicationClass; - - /** - * Called by the servlet container to indicate to a servlet that the servlet - * is being placed into service. - * - * @param servletConfig - * the object containing the servlet's configuration and - * initialization parameters - * @throws javax.servlet.ServletException - * if an exception has occurred that interferes with the - * servlet's normal operation. - */ - @Override - public void init(javax.servlet.ServletConfig servletConfig) - throws javax.servlet.ServletException { - super.init(servletConfig); - - // Loads the application class using the classloader defined in the - // deployment configuration - - try { - applicationClass = ServletPortletHelper - .getApplicationClass(getDeploymentConfiguration()); - } catch (ApplicationClassException e) { - throw new ServletException(e); - } - } - - @Override - protected Application getNewApplication(HttpServletRequest request) - throws ServletException { - - // Creates a new application instance - try { - final Application application = getApplicationClass().newInstance(); - application.addUIProvider(new DefaultUIProvider()); - - return application; - } catch (final IllegalAccessException e) { - throw new ServletException("getNewApplication failed", e); - } catch (final InstantiationException e) { - throw new ServletException("getNewApplication failed", e); - } - } - - protected Class<? extends Application> getApplicationClass() { - return applicationClass; - } -} diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 98ed1071de..a1438312b6 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -277,7 +277,7 @@ public abstract class BootstrapHandler implements RequestHandler { .getConfiguredWidgetset(request); } - widgetset = AbstractApplicationServlet.stripSpecialChars(widgetset); + widgetset = VaadinServlet.stripSpecialChars(widgetset); return widgetset; } @@ -450,7 +450,7 @@ public abstract class BootstrapHandler implements RequestHandler { String staticFileLocation = deploymentConfiguration .getStaticFileLocation(request); String widgetsetBase = staticFileLocation + "/" - + AbstractApplicationServlet.WIDGETSET_DIRECTORY_PATH; + + VaadinServlet.WIDGETSET_DIRECTORY_PATH; defaults.put("widgetsetBase", widgetsetBase); if (!application.isProductionMode()) { @@ -486,8 +486,8 @@ public abstract class BootstrapHandler implements RequestHandler { WrappedRequest request = context.getRequest(); final String staticFilePath = request.getDeploymentConfiguration() .getStaticFileLocation(request); - return staticFilePath + "/" - + AbstractApplicationServlet.THEME_DIRECTORY_PATH + themeName; + return staticFilePath + "/" + VaadinServlet.THEME_DIRECTORY_PATH + + themeName; } /** @@ -517,7 +517,7 @@ public abstract class BootstrapHandler implements RequestHandler { // XSS preventation, theme names shouldn't contain special chars anyway. // The servlet denies them via url parameter. - themeName = AbstractApplicationServlet.stripSpecialChars(themeName); + themeName = VaadinServlet.stripSpecialChars(themeName); return themeName; } diff --git a/server/src/com/vaadin/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java index af28438f57..cc92023919 100644 --- a/server/src/com/vaadin/server/CommunicationManager.java +++ b/server/src/com/vaadin/server/CommunicationManager.java @@ -45,7 +45,7 @@ public class CommunicationManager extends AbstractCommunicationManager { */ @Deprecated public CommunicationManager(Application application, - AbstractApplicationServlet applicationServlet) { + VaadinServlet applicationServlet) { super(application); } @@ -100,7 +100,7 @@ public class CommunicationManager extends AbstractCommunicationManager { @Override public String getThemeName(BootstrapContext context) { String themeName = context.getRequest().getParameter( - AbstractApplicationServlet.URL_PARAMETER_THEME); + VaadinServlet.URL_PARAMETER_THEME); if (themeName == null) { themeName = super.getThemeName(context); } @@ -117,7 +117,7 @@ public class CommunicationManager extends AbstractCommunicationManager { ServletContext servletContext = context.getHttpSession() .getServletContext(); return servletContext.getResourceAsStream("/" - + AbstractApplicationServlet.THEME_DIRECTORY_PATH + themeName - + "/" + resource); + + VaadinServlet.THEME_DIRECTORY_PATH + themeName + "/" + + resource); } } diff --git a/server/src/com/vaadin/server/GAEApplicationServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java index 240984c760..642737f73b 100644 --- a/server/src/com/vaadin/server/GAEApplicationServlet.java +++ b/server/src/com/vaadin/server/GAEVaadinServlet.java @@ -103,7 +103,7 @@ import com.google.apphosting.api.DeadlineExceededException; * possible. * </ul> */ -public class GAEApplicationServlet extends ApplicationServlet { +public class GAEVaadinServlet extends VaadinServlet { // memcache mutex is MUTEX_BASE + sessio id private static final String MUTEX_BASE = "_vmutex"; @@ -423,6 +423,6 @@ public class GAEApplicationServlet extends ApplicationServlet { } private static final Logger getLogger() { - return Logger.getLogger(GAEApplicationServlet.class.getName()); + return Logger.getLogger(GAEVaadinServlet.class.getName()); } } diff --git a/server/src/com/vaadin/server/ServletApplicationContext.java b/server/src/com/vaadin/server/ServletApplicationContext.java index 639ff117d1..a38c523254 100644 --- a/server/src/com/vaadin/server/ServletApplicationContext.java +++ b/server/src/com/vaadin/server/ServletApplicationContext.java @@ -123,7 +123,7 @@ public class ServletApplicationContext extends ApplicationContext { */ @Override public File getBaseDirectory() { - final String realPath = ApplicationServlet.getResourcePath( + final String realPath = VaadinServlet.getResourcePath( session.getServletContext(), "/"); if (realPath == null) { return null; @@ -175,7 +175,7 @@ public class ServletApplicationContext extends ApplicationContext { * @return CommunicationManager */ public CommunicationManager getApplicationManager(Application application, - AbstractApplicationServlet servlet) { + VaadinServlet servlet) { CommunicationManager mgr = (CommunicationManager) applicationToAjaxAppMgrMap .get(application); diff --git a/server/src/com/vaadin/server/SystemError.java b/server/src/com/vaadin/server/SystemError.java index 5d1426e87c..aa9ffcaf52 100644 --- a/server/src/com/vaadin/server/SystemError.java +++ b/server/src/com/vaadin/server/SystemError.java @@ -80,8 +80,7 @@ public class SystemError extends AbstractErrorMessage { StringBuilder sb = new StringBuilder(); if (getMessage() != null) { sb.append("<h2>"); - sb.append(AbstractApplicationServlet - .safeEscapeForHtml(getMessage())); + sb.append(VaadinServlet.safeEscapeForHtml(getMessage())); sb.append("</h2>"); } return sb.toString(); diff --git a/server/src/com/vaadin/server/AbstractApplicationServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 8b3103b794..0766d46e93 100644 --- a/server/src/com/vaadin/server/AbstractApplicationServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -47,31 +47,18 @@ import javax.servlet.http.HttpSession; import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.server.AbstractCommunicationManager.Callback; +import com.vaadin.server.ServletPortletHelper.ApplicationClassException; import com.vaadin.shared.ApplicationConstants; import com.vaadin.ui.UI; -/** - * Abstract implementation of the ApplicationServlet which handles all - * communication between the client and the server. - * - * It is possible to extend this class to provide own functionality but in most - * cases this is unnecessary. - * - * - * @author Vaadin Ltd. - * @since 6.0 - */ - @SuppressWarnings("serial") -public abstract class AbstractApplicationServlet extends HttpServlet implements - Constants { +public class VaadinServlet extends HttpServlet implements Constants { private static class AbstractApplicationServletWrapper implements Callback { - private final AbstractApplicationServlet servlet; + private final VaadinServlet servlet; - public AbstractApplicationServletWrapper( - AbstractApplicationServlet servlet) { + public AbstractApplicationServletWrapper(VaadinServlet servlet) { this.servlet = servlet; } @@ -136,21 +123,21 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements public String getStaticFileLocation(WrappedRequest request) { HttpServletRequest servletRequest = WrappedHttpServletRequest .cast(request); - return AbstractApplicationServlet.this + return VaadinServlet.this .getStaticFilesLocation(servletRequest); } @Override public String getConfiguredWidgetset(WrappedRequest request) { return getApplicationOrSystemProperty( - AbstractApplicationServlet.PARAMETER_WIDGETSET, - AbstractApplicationServlet.DEFAULT_WIDGETSET); + VaadinServlet.PARAMETER_WIDGETSET, + VaadinServlet.DEFAULT_WIDGETSET); } @Override public String getConfiguredTheme(WrappedRequest request) { // Use the default - return AbstractApplicationServlet.getDefaultTheme(); + return VaadinServlet.getDefaultTheme(); } @Override @@ -165,7 +152,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements @Override public SystemMessages getSystemMessages() { - return AbstractApplicationServlet.this.getSystemMessages(); + return VaadinServlet.this.getSystemMessages(); } }; @@ -845,8 +832,26 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * @return A new Application instance. * @throws ServletException */ - protected abstract Application getNewApplication(HttpServletRequest request) - throws ServletException; + protected Application getNewApplication(HttpServletRequest request) + throws ServletException { + + // Creates a new application instance + try { + Class<? extends Application> applicationClass = ServletPortletHelper + .getApplicationClass(getDeploymentConfiguration()); + + final Application application = applicationClass.newInstance(); + application.addUIProvider(new DefaultUIProvider()); + + return application; + } catch (final IllegalAccessException e) { + throw new ServletException("getNewApplication failed", e); + } catch (final InstantiationException e) { + throw new ServletException("getNewApplication failed", e); + } catch (ApplicationClassException e) { + throw new ServletException("getNewApplication failed", e); + } + } /** * Starts the application if it is not already running. @@ -858,7 +863,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * @throws MalformedURLException */ private void startApplication(HttpServletRequest request, - Application application, ServletApplicationContext webApplicationContext) + Application application, + ServletApplicationContext webApplicationContext) throws ServletException, MalformedURLException { if (!application.isRunning()) { @@ -1471,7 +1477,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * the HTTP session. * @return the application context for HttpSession. */ - protected ServletApplicationContext getApplicationContext(HttpSession session) { + protected ServletApplicationContext getApplicationContext( + HttpSession session) { /* * TODO the ApplicationContext.getApplicationContext() should be removed * and logic moved here. Now overriding context type is possible, but @@ -1501,10 +1508,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * * @deprecated Instead of overriding this method, override * {@link ServletApplicationContext} implementation via - * {@link AbstractApplicationServlet#getApplicationContext(HttpSession)} + * {@link VaadinServlet#getApplicationContext(HttpSession)} * method and in that customized implementation return your * CommunicationManager in - * {@link ServletApplicationContext#getApplicationManager(Application, AbstractApplicationServlet)} + * {@link ServletApplicationContext#getApplicationManager(Application, VaadinServlet)} * method. * * @param application @@ -1552,6 +1559,6 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } private static final Logger getLogger() { - return Logger.getLogger(AbstractApplicationServlet.class.getName()); + return Logger.getLogger(VaadinServlet.class.getName()); } } diff --git a/server/src/com/vaadin/server/WebBrowser.java b/server/src/com/vaadin/server/WebBrowser.java index 92090da14a..96cab99e40 100644 --- a/server/src/com/vaadin/server/WebBrowser.java +++ b/server/src/com/vaadin/server/WebBrowser.java @@ -335,9 +335,8 @@ public class WebBrowser { } /** - * For internal use by AbstractApplicationServlet/AbstractApplicationPortlet - * only. Updates all properties in the class according to the given - * information. + * For internal use by VaadinServlet/VaadinPortlet only. Updates all + * properties in the class according to the given information. * * @param sw * Screen width @@ -406,9 +405,8 @@ public class WebBrowser { } /** - * For internal use by AbstractApplicationServlet/AbstractApplicationPortlet - * only. Updates all properties in the class according to the given - * information. + * For internal use by VaadinServlet/VaadinPortlet only. Updates all + * properties in the class according to the given information. * * @param request * the wrapped request to read the information from diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index d1ccaacde3..0f914d3947 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -33,7 +33,6 @@ import com.vaadin.event.Action.Handler; import com.vaadin.event.ActionManager; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; -import com.vaadin.server.AbstractApplicationServlet; import com.vaadin.server.LegacyComponent; import com.vaadin.server.Page; import com.vaadin.server.Page.BrowserWindowResizeEvent; @@ -41,6 +40,7 @@ import com.vaadin.server.Page.BrowserWindowResizeListener; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; +import com.vaadin.server.VaadinServlet; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedRequest.BrowserDetails; import com.vaadin.shared.EventId; @@ -63,7 +63,7 @@ import com.vaadin.tools.ReflectTools; * </p> * <p> * When a new UI instance is needed, typically because the user opens a URL in a - * browser window which points to {@link AbstractApplicationServlet}, + * browser window which points to {@link VaadinServlet}, * {@link Application#getUIForRequest(WrappedRequest)} is invoked to get a UI. * That method does by default create a UI according to the * {@value Application#UI_PARAMETER} parameter from web.xml. diff --git a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java index df16e98bba..3ae41610fa 100644 --- a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java +++ b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java @@ -15,14 +15,11 @@ import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; -import com.vaadin.server.AbstractApplicationServlet; -import com.vaadin.server.ApplicationServlet; - import junit.framework.TestCase; public class TestAbstractApplicationServletStaticFilesLocation extends TestCase { - ApplicationServlet servlet; + VaadinServlet servlet; private Method getStaticFilesLocationMethod; @@ -30,18 +27,16 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase protected void setUp() throws Exception { super.setUp(); - servlet = new ApplicationServlet(); + servlet = new VaadinServlet(); // Workaround to avoid calling init and creating servlet config - Field f = AbstractApplicationServlet.class - .getDeclaredField("applicationProperties"); + Field f = VaadinServlet.class.getDeclaredField("applicationProperties"); f.setAccessible(true); f.set(servlet, new Properties()); - getStaticFilesLocationMethod = AbstractApplicationServlet.class - .getDeclaredMethod( - "getStaticFilesLocation", - new Class[] { javax.servlet.http.HttpServletRequest.class }); + getStaticFilesLocationMethod = VaadinServlet.class.getDeclaredMethod( + "getStaticFilesLocation", + new Class[] { javax.servlet.http.HttpServletRequest.class }); getStaticFilesLocationMethod.setAccessible(true); } diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index e2fe5df4c7..bbe6e061fb 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; -import com.vaadin.server.AbstractApplicationServlet; +import com.vaadin.server.VaadinServlet; import com.vaadin.server.AbstractUIProvider; import com.vaadin.server.WrappedHttpServletRequest; import com.vaadin.server.WrappedRequest; @@ -38,7 +38,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.UI; @SuppressWarnings("serial") -public class ApplicationRunnerServlet extends AbstractApplicationServlet { +public class ApplicationRunnerServlet extends VaadinServlet { /** * The name of the application class currently used. Only valid within one |