From d1c361e251800c6f7d596ddf79ed1c7569196856 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 5 Sep 2012 19:04:20 +0300 Subject: [PATCH] Rename Application to VaadinSession (#9402) --- server/src/com/vaadin/LegacyApplication.java | 27 +++---- .../data/util/converter/ConverterUtil.java | 8 +- .../converter/DefaultConverterFactory.java | 4 +- .../server/AbstractClientConnector.java | 3 +- .../server/AbstractCommunicationManager.java | 31 ++++---- .../com/vaadin/server/AbstractUIProvider.java | 3 +- .../src/com/vaadin/server/AddonContext.java | 9 +-- .../server/ApplicationStartedEvent.java | 7 +- .../server/ApplicationStartedListener.java | 5 +- .../server/BootstrapFragmentResponse.java | 5 +- .../com/vaadin/server/BootstrapHandler.java | 11 ++- .../vaadin/server/BootstrapPageResponse.java | 5 +- .../com/vaadin/server/BootstrapResponse.java | 7 +- .../src/com/vaadin/server/ClassResource.java | 3 +- .../com/vaadin/server/CombinedRequest.java | 3 +- .../vaadin/server/CommunicationManager.java | 11 ++- .../server/ConnectorResourceHandler.java | 5 +- .../com/vaadin/server/DefaultUIProvider.java | 5 +- .../src/com/vaadin/server/FileResource.java | 3 +- .../com/vaadin/server/GAEVaadinServlet.java | 9 +-- .../vaadin/server/GlobalResourceHandler.java | 3 +- .../vaadin/server/LegacyVaadinPortlet.java | 7 +- .../vaadin/server/LegacyVaadinServlet.java | 7 +- .../server/PortletCommunicationManager.java | 7 +- .../src/com/vaadin/server/RequestHandler.java | 5 +- .../src/com/vaadin/server/RequestTimer.java | 3 +- .../server/RestrictedRenderResponse.java | 2 +- .../vaadin/server/ServletPortletHelper.java | 11 ++- .../src/com/vaadin/server/StreamVariable.java | 3 +- .../src/com/vaadin/server/SystemMessages.java | 3 +- server/src/com/vaadin/server/UIProvider.java | 5 +- .../server/UnsupportedBrowserHandler.java | 3 +- .../src/com/vaadin/server/VaadinPortlet.java | 35 +++++---- ...ontext2.java => VaadinPortletSession.java} | 3 +- .../src/com/vaadin/server/VaadinServlet.java | 41 +++++----- ...Context.java => VaadinServletSession.java} | 3 +- .../VaadinSession.java} | 75 +++++++------------ .../server/WrappedHttpServletRequest.java | 3 +- .../vaadin/server/WrappedPortletRequest.java | 3 +- .../src/com/vaadin/ui/AbstractComponent.java | 8 +- server/src/com/vaadin/ui/Component.java | 6 +- server/src/com/vaadin/ui/LoginForm.java | 4 +- server/src/com/vaadin/ui/UI.java | 28 +++---- .../src/com/vaadin/tests/VaadinClasses.java | 4 +- .../data/converter/ConverterFactory.java | 18 ++--- .../server/TestStreamVariableMapping.java | 8 +- .../AbstractFieldValueConversions.java | 8 +- .../DefaultConverterFactory.java | 6 +- .../RemoveListenersOnDetach.java | 8 +- .../component/label/LabelConverters.java | 4 +- .../component/root/CustomUIClassLoader.java | 14 ++-- .../component/window/AttachDetachWindow.java | 6 +- .../launcher/ApplicationRunnerServlet.java | 12 +-- uitest/src/com/vaadin/tests/ModalWindow.java | 2 +- uitest/src/com/vaadin/tests/Parameters.java | 6 +- uitest/src/com/vaadin/tests/TestBench.java | 2 +- .../src/com/vaadin/tests/TreeFilesystem.java | 4 +- .../vaadin/tests/TreeFilesystemContainer.java | 4 +- .../application/ThreadLocalInstances.java | 8 +- .../applicationcontext/ChangeSessionId.java | 6 +- .../tests/components/AbstractTestCase.java | 4 +- .../components/AbstractTestUIProvider.java | 4 +- .../AbstractComponentDataBindingTest.java | 4 +- .../tests/components/ui/LazyInitUIs.java | 10 +-- .../components/ui/UIsInMultipleTabs.java | 8 +- .../integration/JSR286PortletApplication.java | 8 +- .../DifferentFeaturesForDifferentClients.java | 6 +- .../minitutorials/v7a1/DynamicImageUI.java | 4 +- .../minitutorials/v7a1/FindCurrentUI.java | 4 +- .../com/vaadin/tests/tickets/Ticket1589.java | 6 +- .../com/vaadin/tests/tickets/Ticket1921.java | 6 +- .../com/vaadin/tests/tickets/Ticket2292.java | 6 +- .../vaadin/tests/util/SampleDirectory.java | 4 +- 73 files changed, 286 insertions(+), 340 deletions(-) rename server/src/com/vaadin/server/{PortletApplicationContext2.java => VaadinPortletSession.java} (99%) rename server/src/com/vaadin/server/{ServletApplicationContext.java => VaadinServletSession.java} (97%) rename server/src/com/vaadin/{Application.java => server/VaadinSession.java} (96%) diff --git a/server/src/com/vaadin/LegacyApplication.java b/server/src/com/vaadin/LegacyApplication.java index b884136767..9f02a2d588 100644 --- a/server/src/com/vaadin/LegacyApplication.java +++ b/server/src/com/vaadin/LegacyApplication.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.vaadin.server.AbstractUIProvider; +import com.vaadin.server.VaadinSession; import com.vaadin.server.Terminal.ErrorEvent; import com.vaadin.server.Terminal.ErrorListener; import com.vaadin.server.WrappedRequest; @@ -68,8 +69,8 @@ public abstract class LegacyApplication extends AbstractUIProvider implements throw new IllegalStateException("mainWindow has already been set"); } if (mainWindow.getApplication() == null) { - mainWindow.setApplication(Application.getCurrent()); - } else if (mainWindow.getApplication() != Application.getCurrent()) { + mainWindow.setApplication(VaadinSession.getCurrent()); + } else if (mainWindow.getApplication() != VaadinSession.getCurrent()) { throw new IllegalStateException( "mainWindow is attached to another application"); } @@ -82,14 +83,14 @@ public abstract class LegacyApplication extends AbstractUIProvider implements } public void doInit() { - Application.getCurrent().setErrorHandler(this); + VaadinSession.getCurrent().setErrorHandler(this); init(); } protected abstract void init(); @Override - public Class getUIClass(Application application, + public Class getUIClass(VaadinSession application, WrappedRequest request) { UI uiInstance = getUIInstance(request); if (uiInstance != null) { @@ -99,7 +100,7 @@ public abstract class LegacyApplication extends AbstractUIProvider implements } @Override - public UI createInstance(Application application, Class type, + public UI createInstance(VaadinSession application, Class type, WrappedRequest request) { return getUIInstance(request); } @@ -179,7 +180,7 @@ public abstract class LegacyApplication extends AbstractUIProvider implements * Sets the application's theme. *

* Note that this theme can be overridden for a specific UI with - * {@link Application#getThemeForUI(UI)}. Setting theme to be + * {@link VaadinSession#getThemeForUI(UI)}. Setting theme to be * null selects the default theme. For the available theme * names, see the contents of the VAADIN/themes directory. *

@@ -241,7 +242,7 @@ public abstract class LegacyApplication extends AbstractUIProvider implements } legacyUINames.put(uI.getName(), uI); - uI.setApplication(Application.getCurrent()); + uI.setApplication(VaadinSession.getCurrent()); } /** @@ -280,22 +281,22 @@ public abstract class LegacyApplication extends AbstractUIProvider implements @Override public void terminalError(ErrorEvent event) { - Application.getCurrent().terminalError(event); + VaadinSession.getCurrent().terminalError(event); } - public Application getContext() { - return Application.getCurrent(); + public VaadinSession getContext() { + return VaadinSession.getCurrent(); } protected void close() { - Application.getCurrent().close(); + VaadinSession.getCurrent().close(); } public boolean isRunning() { - return Application.getCurrent().isRunning(); + return VaadinSession.getCurrent().isRunning(); } public URL getURL() { - return Application.getCurrent().getURL(); + return VaadinSession.getCurrent().getURL(); } } \ No newline at end of file diff --git a/server/src/com/vaadin/data/util/converter/ConverterUtil.java b/server/src/com/vaadin/data/util/converter/ConverterUtil.java index 36cd6d0859..a6014bb3eb 100644 --- a/server/src/com/vaadin/data/util/converter/ConverterUtil.java +++ b/server/src/com/vaadin/data/util/converter/ConverterUtil.java @@ -18,7 +18,7 @@ package com.vaadin.data.util.converter; import java.io.Serializable; import java.util.Locale; -import com.vaadin.Application; +import com.vaadin.server.VaadinSession; public class ConverterUtil implements Serializable { @@ -26,7 +26,7 @@ public class ConverterUtil implements Serializable { * Finds a converter that can convert from the given presentation type to * the given model type and back. Uses the given application to find a * {@link ConverterFactory} or, if application is null, uses the - * {@link Application#getCurrent()}. + * {@link VaadinSession#getCurrent()}. * * @param * The presentation type @@ -44,10 +44,10 @@ public class ConverterUtil implements Serializable { */ public static Converter getConverter( Class presentationType, - Class modelType, Application application) { + Class modelType, VaadinSession application) { Converter converter = null; if (application == null) { - application = Application.getCurrent(); + application = VaadinSession.getCurrent(); } if (application != null) { diff --git a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java index ffd432076f..17b89ccb20 100644 --- a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java +++ b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java @@ -19,14 +19,14 @@ package com.vaadin.data.util.converter; import java.util.Date; import java.util.logging.Logger; -import com.vaadin.Application; +import com.vaadin.server.VaadinSession; /** * Default implementation of {@link ConverterFactory}. Provides converters for * standard types like {@link String}, {@link Double} and {@link Date}.

*

* Custom converters can be provided by extending this class and using - * {@link Application#setConverterFactory(ConverterFactory)}. + * {@link VaadinSession#setConverterFactory(ConverterFactory)}. *

* * @author Vaadin Ltd diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java index 09e366260b..82a154d4e5 100644 --- a/server/src/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/com/vaadin/server/AbstractClientConnector.java @@ -31,7 +31,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.logging.Logger; -import com.vaadin.Application; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.communication.ClientRpc; @@ -358,7 +357,7 @@ public abstract class AbstractClientConnector implements ClientConnector { * * @return The connector's application, or null if not attached */ - protected Application getApplication() { + protected VaadinSession getApplication() { UI uI = getUI(); if (uI == null) { return null; diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 47bf652a3a..71f5a07d77 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -56,7 +56,6 @@ import java.util.logging.Logger; import javax.servlet.http.HttpServletResponse; -import com.vaadin.Application; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.external.json.JSONArray; @@ -143,7 +142,7 @@ public abstract class AbstractCommunicationManager implements Serializable { /** * The application this communication manager is used for */ - private final Application application; + private final VaadinSession application; private List locales; @@ -170,7 +169,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * * @param application */ - public AbstractCommunicationManager(Application application) { + public AbstractCommunicationManager(VaadinSession application) { this.application = application; application.addRequestHandler(getBootstrapHandler()); application.addRequestHandler(UNSUPPORTED_BROWSER_HANDLER); @@ -178,7 +177,7 @@ public abstract class AbstractCommunicationManager implements Serializable { requireLocale(application.getLocale().toString()); } - protected Application getApplication() { + protected VaadinSession getApplication() { return application; } @@ -366,7 +365,7 @@ public abstract class AbstractCommunicationManager implements Serializable { "StreamVariable for the post not found"); } - final Application application = getApplication(); + final VaadinSession application = getApplication(); OutputStream out = null; int totalBytes = 0; @@ -491,7 +490,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * Internally process a UIDL request from the client. * * This method calls - * {@link #handleVariables(WrappedRequest, WrappedResponse, Callback, Application, UI)} + * {@link #handleVariables(WrappedRequest, WrappedResponse, Callback, VaadinSession, UI)} * to process any changes to variables by the client and then repaints * affected components using {@link #paintAfterVariableChanges()}. * @@ -677,7 +676,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } sb.append("\nComponent hierarchy:\n"); - Application application2 = component.getApplication(); + VaadinSession application2 = component.getApplication(); sb.append(application2.getClass().getName()); sb.append("."); sb.append(application2.getClass().getSimpleName()); @@ -790,7 +789,7 @@ public abstract class AbstractCommunicationManager implements Serializable { final PrintWriter outWriter, UI ui, boolean analyzeLayouts) throws PaintException, JSONException { ArrayList dirtyVisibleConnectors = new ArrayList(); - Application application = ui.getApplication(); + VaadinSession application = ui.getApplication(); // Paints components ConnectorTracker uiConnectorTracker = ui.getConnectorTracker(); getLogger().log(Level.FINE, "* Creating response to client"); @@ -1521,7 +1520,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @param application * @return false if the XSRF is turned off, true otherwise */ - public boolean isXSRFEnabled(Application application) { + public boolean isXSRFEnabled(VaadinSession application) { return application.getConfiguration().isXsrfProtectionEnabled(); } @@ -1536,7 +1535,7 @@ public abstract class AbstractCommunicationManager implements Serializable { */ private boolean handleVariables(WrappedRequest request, WrappedResponse response, Callback callback, - Application application2, UI uI) throws IOException, + VaadinSession application2, UI uI) throws IOException, InvalidUIDLSecurityKeyException, JSONException { boolean success = true; @@ -1943,7 +1942,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @param m * map from variable names to values */ - private void handleChangeVariablesError(Application application, + private void handleChangeVariablesError(VaadinSession application, Component owner, Throwable t, Map m) { boolean handled = false; ChangeVariablesErrorEvent errorEvent = new ChangeVariablesErrorEvent( @@ -2155,7 +2154,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * Ends the Application. * * The browser is redirected to the Application logout URL set with - * {@link Application#setLogoutURL(String)}, or to the application URL if no + * {@link VaadinSession#setLogoutURL(String)}, or to the application URL if no * logout URL is given. * * @param request @@ -2168,7 +2167,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * if the writing failed due to input/output error. */ private void endApplication(WrappedRequest request, - WrappedResponse response, Application application) + WrappedResponse response, VaadinSession application) throws IOException { String logoutUrl = application.getLogoutURL(); @@ -2394,7 +2393,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } public void handleBrowserDetailsRequest(WrappedRequest request, - WrappedResponse response, Application application) + WrappedResponse response, VaadinSession application) throws IOException { assert UI.getCurrent() == null; @@ -2572,7 +2571,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @throws IOException * @throws InvalidUIDLSecurityKeyException */ - public void handleFileUpload(Application application, + public void handleFileUpload(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException, InvalidUIDLSecurityKeyException { @@ -2634,7 +2633,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @throws IOException */ public void handleHeartbeatRequest(WrappedRequest request, - WrappedResponse response, Application application) + WrappedResponse response, VaadinSession application) throws IOException { UI ui = null; try { diff --git a/server/src/com/vaadin/server/AbstractUIProvider.java b/server/src/com/vaadin/server/AbstractUIProvider.java index c7a137ebbd..ee8ebd2745 100644 --- a/server/src/com/vaadin/server/AbstractUIProvider.java +++ b/server/src/com/vaadin/server/AbstractUIProvider.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.lang.annotation.Annotation; -import com.vaadin.Application; import com.vaadin.annotations.PreserveOnRefresh; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; @@ -28,7 +27,7 @@ import com.vaadin.ui.UI; public abstract class AbstractUIProvider implements UIProvider { @Override - public UI createInstance(Application application, Class type, + public UI createInstance(VaadinSession application, Class type, WrappedRequest request) { try { return type.newInstance(); diff --git a/server/src/com/vaadin/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java index c9f2ac07eb..ca8c837a2e 100644 --- a/server/src/com/vaadin/server/AddonContext.java +++ b/server/src/com/vaadin/server/AddonContext.java @@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.List; import java.util.ServiceLoader; -import com.vaadin.Application; import com.vaadin.event.EventRouter; import com.vaadin.util.ReflectTools; @@ -116,7 +115,7 @@ public class AddonContext { * application. * * @see #addApplicationStartedListener(ApplicationStartedListener) - * @see Application#addBootstrapListener(BootstrapListener) + * @see VaadinSession#addBootstrapListener(BootstrapListener) * * @param listener * the bootstrap listener that should be added to all new @@ -136,7 +135,7 @@ public class AddonContext { * @param application * the newly started application */ - public void fireApplicationStarted(Application application) { + public void fireApplicationStarted(VaadinSession application) { eventRouter.fireEvent(new ApplicationStartedEvent(this, application)); for (BootstrapListener l : bootstrapListeners) { application.addBootstrapListener(l); @@ -144,9 +143,9 @@ public class AddonContext { } /** - * Adds a listener that will be notified any time a new {@link Application} + * Adds a listener that will be notified any time a new {@link VaadinSession} * instance is started or more precisely directly after - * {@link Application#init()} has been invoked. + * {@link VaadinSession#init()} has been invoked. * * @param applicationStartListener * the application start listener that should be added diff --git a/server/src/com/vaadin/server/ApplicationStartedEvent.java b/server/src/com/vaadin/server/ApplicationStartedEvent.java index d06744ae40..9ecab4d477 100644 --- a/server/src/com/vaadin/server/ApplicationStartedEvent.java +++ b/server/src/com/vaadin/server/ApplicationStartedEvent.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.util.EventObject; -import com.vaadin.Application; /** * Event used by @@ -29,7 +28,7 @@ import com.vaadin.Application; * @since 7.0.0 */ public class ApplicationStartedEvent extends EventObject { - private final Application application; + private final VaadinSession application; /** * Creates a new event. @@ -39,7 +38,7 @@ public class ApplicationStartedEvent extends EventObject { * @param application * the application that has been started */ - public ApplicationStartedEvent(AddonContext context, Application application) { + public ApplicationStartedEvent(AddonContext context, VaadinSession application) { super(context); this.application = application; } @@ -58,7 +57,7 @@ public class ApplicationStartedEvent extends EventObject { * * @return the newly created application */ - public Application getApplication() { + public VaadinSession getApplication() { return application; } diff --git a/server/src/com/vaadin/server/ApplicationStartedListener.java b/server/src/com/vaadin/server/ApplicationStartedListener.java index c54132d875..b7858447df 100644 --- a/server/src/com/vaadin/server/ApplicationStartedListener.java +++ b/server/src/com/vaadin/server/ApplicationStartedListener.java @@ -18,10 +18,9 @@ package com.vaadin.server; import java.util.EventListener; -import com.vaadin.Application; /** - * Listener that gets notified when a new {@link Application} has been started. + * Listener that gets notified when a new {@link VaadinSession} has been started. * Add-ons can use this listener to automatically integrate with API tied to the * Application API. * @@ -33,7 +32,7 @@ import com.vaadin.Application; public interface ApplicationStartedListener extends EventListener { /** * Tells the listener that an application has been started (meaning that - * {@link Application#init()} has been invoked. + * {@link VaadinSession#init()} has been invoked. * * @param event * details about the event diff --git a/server/src/com/vaadin/server/BootstrapFragmentResponse.java b/server/src/com/vaadin/server/BootstrapFragmentResponse.java index 149f59e7a5..4b960263e7 100644 --- a/server/src/com/vaadin/server/BootstrapFragmentResponse.java +++ b/server/src/com/vaadin/server/BootstrapFragmentResponse.java @@ -20,7 +20,6 @@ import java.util.List; import org.jsoup.nodes.Node; -import com.vaadin.Application; import com.vaadin.ui.UI; /** @@ -38,7 +37,7 @@ public class BootstrapFragmentResponse extends BootstrapResponse { * Crate a new bootstrap fragment response. * * @see BootstrapResponse#BootstrapResponse(BootstrapHandler, - * WrappedRequest, Application, Class) + * WrappedRequest, VaadinSession, Class) * * @param handler * the bootstrap handler that is firing the event @@ -55,7 +54,7 @@ public class BootstrapFragmentResponse extends BootstrapResponse { * application HTML */ public BootstrapFragmentResponse(BootstrapHandler handler, - WrappedRequest request, Application application, + WrappedRequest request, VaadinSession application, Class uiClass, List fragmentNodes) { super(handler, request, application, uiClass); this.fragmentNodes = fragmentNodes; diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index a793214942..6b8fb1952a 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -36,7 +36,6 @@ import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; import org.jsoup.parser.Tag; -import com.vaadin.Application; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; @@ -68,7 +67,7 @@ public abstract class BootstrapHandler implements RequestHandler { return bootstrapResponse.getRequest(); } - public Application getApplication() { + public VaadinSession getApplication() { return bootstrapResponse.getApplication(); } @@ -104,7 +103,7 @@ public abstract class BootstrapHandler implements RequestHandler { } @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { @@ -246,7 +245,7 @@ public abstract class BootstrapHandler implements RequestHandler { } private BootstrapContext createContext(WrappedRequest request, - WrappedResponse response, Application application, + WrappedResponse response, VaadinSession application, Class uiClass) { BootstrapContext context = new BootstrapContext(response, new BootstrapFragmentResponse(this, request, application, @@ -392,7 +391,7 @@ public abstract class BootstrapHandler implements RequestHandler { protected JSONObject getApplicationParameters(BootstrapContext context) throws JSONException, PaintException { - Application application = context.getApplication(); + VaadinSession application = context.getApplication(); JSONObject appConfig = new JSONObject(); @@ -421,7 +420,7 @@ public abstract class BootstrapHandler implements RequestHandler { JSONObject defaults = new JSONObject(); WrappedRequest request = context.getRequest(); - Application application = context.getApplication(); + VaadinSession application = context.getApplication(); DeploymentConfiguration deploymentConfiguration = request .getDeploymentConfiguration(); diff --git a/server/src/com/vaadin/server/BootstrapPageResponse.java b/server/src/com/vaadin/server/BootstrapPageResponse.java index a5fdfe4707..8f56042f8f 100644 --- a/server/src/com/vaadin/server/BootstrapPageResponse.java +++ b/server/src/com/vaadin/server/BootstrapPageResponse.java @@ -20,7 +20,6 @@ import java.util.Map; import org.jsoup.nodes.Document; -import com.vaadin.Application; import com.vaadin.ui.UI; /** @@ -40,7 +39,7 @@ public class BootstrapPageResponse extends BootstrapResponse { * Crate a new bootstrap page response. * * @see BootstrapResponse#BootstrapResponse(BootstrapHandler, - * WrappedRequest, Application, Class) + * WrappedRequest, VaadinSession, Class) * * @param handler * the bootstrap handler that is firing the event @@ -58,7 +57,7 @@ public class BootstrapPageResponse extends BootstrapResponse { * a map into which header data can be added */ public BootstrapPageResponse(BootstrapHandler handler, - WrappedRequest request, Application application, + WrappedRequest request, VaadinSession application, Class uiClass, Document document, Map headers) { super(handler, request, application, uiClass); diff --git a/server/src/com/vaadin/server/BootstrapResponse.java b/server/src/com/vaadin/server/BootstrapResponse.java index 3173569059..b75544a87c 100644 --- a/server/src/com/vaadin/server/BootstrapResponse.java +++ b/server/src/com/vaadin/server/BootstrapResponse.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.util.EventObject; -import com.vaadin.Application; import com.vaadin.ui.UI; /** @@ -30,7 +29,7 @@ import com.vaadin.ui.UI; */ public abstract class BootstrapResponse extends EventObject { private final WrappedRequest request; - private final Application application; + private final VaadinSession application; private final Class uiClass; /** @@ -48,7 +47,7 @@ public abstract class BootstrapResponse extends EventObject { * the class of the UI that will be displayed on the page */ public BootstrapResponse(BootstrapHandler handler, WrappedRequest request, - Application application, Class uiClass) { + VaadinSession application, Class uiClass) { super(handler); this.request = request; this.application = application; @@ -83,7 +82,7 @@ public abstract class BootstrapResponse extends EventObject { * * @return the application */ - public Application getApplication() { + public VaadinSession getApplication() { return application; } diff --git a/server/src/com/vaadin/server/ClassResource.java b/server/src/com/vaadin/server/ClassResource.java index 2f05115fd4..27643eda13 100644 --- a/server/src/com/vaadin/server/ClassResource.java +++ b/server/src/com/vaadin/server/ClassResource.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.io.Serializable; -import com.vaadin.Application; import com.vaadin.service.FileTypeResolver; import com.vaadin.ui.UI; import com.vaadin.ui.UI.LegacyWindow; @@ -115,7 +114,7 @@ public class ClassResource implements ConnectorResource, Serializable { if (associatedClass == null) { Class associatedClass = UI.getCurrent().getClass(); if (associatedClass == LegacyWindow.class) { - return Application.getCurrent().getClass(); + return VaadinSession.getCurrent().getClass(); } return associatedClass; } diff --git a/server/src/com/vaadin/server/CombinedRequest.java b/server/src/com/vaadin/server/CombinedRequest.java index 9176754d93..cc336ffa73 100644 --- a/server/src/com/vaadin/server/CombinedRequest.java +++ b/server/src/com/vaadin/server/CombinedRequest.java @@ -24,7 +24,6 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; -import com.vaadin.Application; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; @@ -143,7 +142,7 @@ public class CombinedRequest implements WrappedRequest { @Override public WebBrowser getWebBrowser() { - return Application.getCurrent().getBrowser(); + return VaadinSession.getCurrent().getBrowser(); } }; } diff --git a/server/src/com/vaadin/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java index beea884aae..3cc8831901 100644 --- a/server/src/com/vaadin/server/CommunicationManager.java +++ b/server/src/com/vaadin/server/CommunicationManager.java @@ -21,7 +21,6 @@ import java.net.URL; import javax.servlet.ServletContext; -import com.vaadin.Application; import com.vaadin.ui.UI; /** @@ -39,12 +38,12 @@ import com.vaadin.ui.UI; public class CommunicationManager extends AbstractCommunicationManager { /** - * @deprecated use {@link #CommunicationManager(Application)} instead + * @deprecated use {@link #CommunicationManager(VaadinSession)} instead * @param application * @param applicationServlet */ @Deprecated - public CommunicationManager(Application application, + public CommunicationManager(VaadinSession application, VaadinServlet applicationServlet) { super(application); } @@ -54,7 +53,7 @@ public class CommunicationManager extends AbstractCommunicationManager { * * @param application */ - public CommunicationManager(Application application) { + public CommunicationManager(VaadinSession application) { super(application); } @@ -88,7 +87,7 @@ public class CommunicationManager extends AbstractCommunicationManager { // don't use server and port in uri. It may cause problems with // some // virtual server configurations which lose the server name - Application application = context.getApplication(); + VaadinSession application = context.getApplication(); URL url = application.getURL(); String appUrl = url.getPath(); if (appUrl.endsWith("/")) { @@ -112,7 +111,7 @@ public class CommunicationManager extends AbstractCommunicationManager { @Override protected InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) { - ServletApplicationContext context = (ServletApplicationContext) uI + VaadinServletSession context = (VaadinServletSession) uI .getApplication(); ServletContext servletContext = context.getHttpSession() .getServletContext(); diff --git a/server/src/com/vaadin/server/ConnectorResourceHandler.java b/server/src/com/vaadin/server/ConnectorResourceHandler.java index b988510b8e..80d3a60a1a 100644 --- a/server/src/com/vaadin/server/ConnectorResourceHandler.java +++ b/server/src/com/vaadin/server/ConnectorResourceHandler.java @@ -8,7 +8,6 @@ import java.util.regex.Pattern; import javax.servlet.http.HttpServletResponse; -import com.vaadin.Application; import com.vaadin.shared.ApplicationConstants; import com.vaadin.ui.UI; @@ -25,7 +24,7 @@ public class ConnectorResourceHandler implements RequestHandler { } @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { String requestPath = request.getRequestPathInfo(); @@ -45,7 +44,7 @@ public class ConnectorResourceHandler implements RequestHandler { } UI.setCurrent(ui); - Application.setCurrent(ui.getApplication()); + VaadinSession.setCurrent(ui.getApplication()); ClientConnector connector = ui.getConnectorTracker().getConnector( cid); diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java index b326e3229e..9babf4704e 100644 --- a/server/src/com/vaadin/server/DefaultUIProvider.java +++ b/server/src/com/vaadin/server/DefaultUIProvider.java @@ -16,16 +16,15 @@ package com.vaadin.server; -import com.vaadin.Application; import com.vaadin.ui.UI; public class DefaultUIProvider extends AbstractUIProvider { @Override - public Class getUIClass(Application application, + public Class getUIClass(VaadinSession application, WrappedRequest request) { Object uiClassNameObj = application.getConfiguration() - .getInitParameters().getProperty(Application.UI_PARAMETER); + .getInitParameters().getProperty(VaadinSession.UI_PARAMETER); if (uiClassNameObj instanceof String) { String uiClassName = uiClassNameObj.toString(); diff --git a/server/src/com/vaadin/server/FileResource.java b/server/src/com/vaadin/server/FileResource.java index fbf353362e..2dd5b7f589 100644 --- a/server/src/com/vaadin/server/FileResource.java +++ b/server/src/com/vaadin/server/FileResource.java @@ -20,7 +20,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import com.vaadin.Application; import com.vaadin.server.Terminal.ErrorEvent; import com.vaadin.service.FileTypeResolver; @@ -74,7 +73,7 @@ public class FileResource implements ConnectorResource { return ds; } catch (final FileNotFoundException e) { // Log the exception using the application error handler - Application.getCurrent().getErrorHandler() + VaadinSession.getCurrent().getErrorHandler() .terminalError(new ErrorEvent() { @Override diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java index 1175d6a960..4ea1dff7f4 100644 --- a/server/src/com/vaadin/server/GAEVaadinServlet.java +++ b/server/src/com/vaadin/server/GAEVaadinServlet.java @@ -47,7 +47,6 @@ import com.google.appengine.api.memcache.Expiration; import com.google.appengine.api.memcache.MemcacheService; import com.google.appengine.api.memcache.MemcacheServiceFactory; import com.google.apphosting.api.DeadlineExceededException; -import com.vaadin.Application; /** * ApplicationServlet to be used when deploying to Google App Engine, in @@ -242,7 +241,7 @@ public class GAEVaadinServlet extends VaadinServlet { } // de-serialize or create application context, store in session - Application ctx = getApplicationContext(request, memcache); + VaadinSession ctx = getApplicationContext(request, memcache); super.service(request, response); @@ -292,7 +291,7 @@ public class GAEVaadinServlet extends VaadinServlet { } } - protected Application getApplicationContext(HttpServletRequest request, + protected VaadinSession getApplicationContext(HttpServletRequest request, MemcacheService memcache) { HttpSession session = request.getSession(); String id = AC_BASE + session.getId(); @@ -321,7 +320,7 @@ public class GAEVaadinServlet extends VaadinServlet { ObjectInputStream ois; try { ois = new ObjectInputStream(bais); - Application applicationContext = (Application) ois.readObject(); + VaadinSession applicationContext = (VaadinSession) ois.readObject(); applicationContext.storeInSession(new WrappedHttpSession( session)); } catch (IOException e) { @@ -360,7 +359,7 @@ public class GAEVaadinServlet extends VaadinServlet { private void cleanSession(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session != null) { - session.removeAttribute(ServletApplicationContext.class.getName()); + session.removeAttribute(VaadinServletSession.class.getName()); } } diff --git a/server/src/com/vaadin/server/GlobalResourceHandler.java b/server/src/com/vaadin/server/GlobalResourceHandler.java index 441d884f58..03dab9817d 100644 --- a/server/src/com/vaadin/server/GlobalResourceHandler.java +++ b/server/src/com/vaadin/server/GlobalResourceHandler.java @@ -28,7 +28,6 @@ import java.util.regex.Pattern; import javax.servlet.http.HttpServletResponse; -import com.vaadin.Application; import com.vaadin.shared.ApplicationConstants; import com.vaadin.ui.UI; @@ -66,7 +65,7 @@ public class GlobalResourceHandler implements RequestHandler { ""); @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { String pathInfo = request.getRequestPathInfo(); diff --git a/server/src/com/vaadin/server/LegacyVaadinPortlet.java b/server/src/com/vaadin/server/LegacyVaadinPortlet.java index 77a94e4d0a..6efd9b29b3 100644 --- a/server/src/com/vaadin/server/LegacyVaadinPortlet.java +++ b/server/src/com/vaadin/server/LegacyVaadinPortlet.java @@ -19,7 +19,6 @@ package com.vaadin.server; import javax.portlet.PortletException; import javax.portlet.PortletRequest; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.server.ServletPortletHelper.ApplicationClassException; @@ -46,13 +45,13 @@ public class LegacyVaadinPortlet extends VaadinPortlet { } @Override - protected PortletApplicationContext2 createApplication( + protected VaadinPortletSession createApplication( PortletRequest request) throws PortletException { - PortletApplicationContext2 application = super + VaadinPortletSession application = super .createApplication(request); // Must set current before running init() - Application.setCurrent(application); + VaadinSession.setCurrent(application); LegacyApplication legacyApplication = getNewApplication(request); legacyApplication.doInit(); diff --git a/server/src/com/vaadin/server/LegacyVaadinServlet.java b/server/src/com/vaadin/server/LegacyVaadinServlet.java index aa78c401f5..d853e55099 100644 --- a/server/src/com/vaadin/server/LegacyVaadinServlet.java +++ b/server/src/com/vaadin/server/LegacyVaadinServlet.java @@ -19,7 +19,6 @@ package com.vaadin.server; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.server.ServletPortletHelper.ApplicationClassException; @@ -46,13 +45,13 @@ public class LegacyVaadinServlet extends VaadinServlet { } @Override - protected ServletApplicationContext createApplication( + protected VaadinServletSession createApplication( HttpServletRequest request) throws ServletException { - ServletApplicationContext application = super + VaadinServletSession application = super .createApplication(request); // Must set current before running init() - Application.setCurrent(application); + VaadinSession.setCurrent(application); LegacyApplication legacyApplication = getNewApplication(request); legacyApplication.doInit(); diff --git a/server/src/com/vaadin/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java index ada42140c6..6eccfa6084 100644 --- a/server/src/com/vaadin/server/PortletCommunicationManager.java +++ b/server/src/com/vaadin/server/PortletCommunicationManager.java @@ -26,7 +26,6 @@ import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.ResourceURL; -import com.vaadin.Application; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; @@ -41,7 +40,7 @@ import com.vaadin.ui.UI; @SuppressWarnings("serial") public class PortletCommunicationManager extends AbstractCommunicationManager { - public PortletCommunicationManager(Application application) { + public PortletCommunicationManager(VaadinSession application) { super(application); } @@ -49,7 +48,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { protected BootstrapHandler createBootstrapHandler() { return new BootstrapHandler() { @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { PortletRequest portletRequest = WrappedPortletRequest.cast( @@ -157,7 +156,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { @Override protected InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) { - PortletApplicationContext2 context = (PortletApplicationContext2) uI + VaadinPortletSession context = (VaadinPortletSession) uI .getApplication(); PortletContext portletContext = context.getPortletSession() .getPortletContext(); diff --git a/server/src/com/vaadin/server/RequestHandler.java b/server/src/com/vaadin/server/RequestHandler.java index fcc506cc54..0557c06378 100644 --- a/server/src/com/vaadin/server/RequestHandler.java +++ b/server/src/com/vaadin/server/RequestHandler.java @@ -19,11 +19,10 @@ package com.vaadin.server; import java.io.IOException; import java.io.Serializable; -import com.vaadin.Application; /** * Handler for producing a response to non-UIDL requests. Handlers can be added - * to applications using {@link Application#addRequestHandler(RequestHandler)} + * to applications using {@link VaadinSession#addRequestHandler(RequestHandler)} */ public interface RequestHandler extends Serializable { @@ -42,7 +41,7 @@ public interface RequestHandler extends Serializable { * handlers should be called, otherwise false * @throws IOException */ - boolean handleRequest(Application application, WrappedRequest request, + boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException; } diff --git a/server/src/com/vaadin/server/RequestTimer.java b/server/src/com/vaadin/server/RequestTimer.java index afff901d2f..149a1499e7 100644 --- a/server/src/com/vaadin/server/RequestTimer.java +++ b/server/src/com/vaadin/server/RequestTimer.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.io.Serializable; -import com.vaadin.Application; /** * Times the handling of requests and stores the information as an attribute in @@ -45,7 +44,7 @@ public class RequestTimer implements Serializable { * * @param context */ - public void stop(Application context) { + public void stop(VaadinSession context) { // Measure and store the total handling time. This data can be // used in TestBench 3 tests. long time = (System.nanoTime() - requestStartTime) / 1000000; diff --git a/server/src/com/vaadin/server/RestrictedRenderResponse.java b/server/src/com/vaadin/server/RestrictedRenderResponse.java index 6923a042d6..206c5f349c 100644 --- a/server/src/com/vaadin/server/RestrictedRenderResponse.java +++ b/server/src/com/vaadin/server/RestrictedRenderResponse.java @@ -36,7 +36,7 @@ import org.w3c.dom.Element; * Read-only wrapper for a {@link RenderResponse}. * * Only for use by {@link PortletApplicationContext} and - * {@link PortletApplicationContext2}. + * {@link VaadinPortletSession}. */ class RestrictedRenderResponse implements RenderResponse, Serializable { diff --git a/server/src/com/vaadin/server/ServletPortletHelper.java b/server/src/com/vaadin/server/ServletPortletHelper.java index 28a63fe35b..068a9f9192 100644 --- a/server/src/com/vaadin/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/server/ServletPortletHelper.java @@ -3,7 +3,6 @@ package com.vaadin.server; import java.io.Serializable; import java.util.Properties; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.shared.ApplicationConstants; import com.vaadin.ui.UI; @@ -68,7 +67,7 @@ class ServletPortletHelper implements Serializable { private static void verifyUIClass(String className, ClassLoader classLoader) throws ApplicationClassException { if (className == null) { - throw new ApplicationClassException(Application.UI_PARAMETER + throw new ApplicationClassException(VaadinSession.UI_PARAMETER + " init parameter not defined"); } @@ -133,24 +132,24 @@ class ServletPortletHelper implements Serializable { ApplicationConstants.HEARTBEAT_REQUEST_PATH); } - public static void initDefaultUIProvider(Application application, + public static void initDefaultUIProvider(VaadinSession application, DeploymentConfiguration deploymentConfiguration) throws ApplicationClassException { String uiProperty = deploymentConfiguration .getApplicationConfiguration().getInitParameters() - .getProperty(Application.UI_PARAMETER); + .getProperty(VaadinSession.UI_PARAMETER); if (uiProperty != null) { verifyUIClass(uiProperty, deploymentConfiguration.getClassLoader()); application.addUIProvider(new DefaultUIProvider()); } } - public static void checkUiProviders(Application newApplication) + public static void checkUiProviders(VaadinSession newApplication) throws ApplicationClassException { if (newApplication.getUIProviders().isEmpty()) { throw new ApplicationClassException( "No UIProvider has been added to the application and there is no \"" - + Application.UI_PARAMETER + "\" init parameter."); + + VaadinSession.UI_PARAMETER + "\" init parameter."); } } diff --git a/server/src/com/vaadin/server/StreamVariable.java b/server/src/com/vaadin/server/StreamVariable.java index f289e7612a..a75cc2f0d7 100644 --- a/server/src/com/vaadin/server/StreamVariable.java +++ b/server/src/com/vaadin/server/StreamVariable.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.io.OutputStream; import java.io.Serializable; -import com.vaadin.Application; import com.vaadin.server.StreamVariable.StreamingEndEvent; import com.vaadin.server.StreamVariable.StreamingErrorEvent; import com.vaadin.server.StreamVariable.StreamingStartEvent; @@ -152,7 +151,7 @@ public interface StreamVariable extends Serializable { * the streaming ended before the end of the input. The streaming may fail * due an interruption by {@link } or due an other unknown exception in * communication. In the latter case the exception is also passed to - * {@link Application#terminalError(com.vaadin.server.Terminal.ErrorEvent)} + * {@link VaadinSession#terminalError(com.vaadin.server.Terminal.ErrorEvent)} * . */ public interface StreamingErrorEvent extends StreamingEvent { diff --git a/server/src/com/vaadin/server/SystemMessages.java b/server/src/com/vaadin/server/SystemMessages.java index 17aed0003e..3f6a0f9a68 100644 --- a/server/src/com/vaadin/server/SystemMessages.java +++ b/server/src/com/vaadin/server/SystemMessages.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.io.Serializable; -import com.vaadin.Application; /** @@ -26,7 +25,7 @@ import com.vaadin.Application; * critical situations that can occur. *

* Customize by overriding the static - * {@link Application#getSystemMessages()} and returning + * {@link VaadinSession#getSystemMessages()} and returning * {@link CustomizedSystemMessages}. *

*

diff --git a/server/src/com/vaadin/server/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java index 6a45b06c63..b2908a04d6 100644 --- a/server/src/com/vaadin/server/UIProvider.java +++ b/server/src/com/vaadin/server/UIProvider.java @@ -16,15 +16,14 @@ package com.vaadin.server; -import com.vaadin.Application; import com.vaadin.annotations.Widgetset; import com.vaadin.ui.UI; public interface UIProvider { - public Class getUIClass(Application application, + public Class getUIClass(VaadinSession application, WrappedRequest request); - public UI createInstance(Application application, Class type, + public UI createInstance(VaadinSession application, Class type, WrappedRequest request); public String getPageTitleForUI(WrappedRequest request, diff --git a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java index 325edb5d61..dccbf7ba7b 100644 --- a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java +++ b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java @@ -18,7 +18,6 @@ package com.vaadin.server; import java.io.IOException; import java.io.Writer; -import com.vaadin.Application; /** * A {@link RequestHandler} that presents an informative page if the browser in @@ -36,7 +35,7 @@ public class UnsupportedBrowserHandler implements RequestHandler { public static final String FORCE_LOAD_COOKIE = "vaadinforceload=1"; @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index e69a635b76..941d96ea25 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -55,11 +55,10 @@ import javax.servlet.http.HttpServletResponse; import com.liferay.portal.kernel.util.PortalClassInvoker; import com.liferay.portal.kernel.util.PropsUtil; -import com.vaadin.Application; -import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.DefaultApplicationConfiguration; import com.vaadin.server.AbstractCommunicationManager.Callback; import com.vaadin.server.ServletPortletHelper.ApplicationClassException; +import com.vaadin.server.VaadinSession.ApplicationStartEvent; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; @@ -456,7 +455,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { serveStaticResources((ResourceRequest) request, (ResourceResponse) response); } else { - Application application = null; + VaadinSession application = null; boolean applicationRunning = false; try { @@ -468,13 +467,13 @@ public class VaadinPortlet extends GenericPortlet implements Constants { if (application == null) { return; } - Application.setCurrent(application); + VaadinSession.setCurrent(application); /* * Get or create an application context and an application * manager for the session */ - PortletApplicationContext2 applicationContext = (PortletApplicationContext2) application; + VaadinPortletSession applicationContext = (VaadinPortletSession) application; PortletCommunicationManager applicationManager = (PortletCommunicationManager) applicationContext .getApplicationManager(); @@ -652,8 +651,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { */ private void handleOtherRequest(WrappedPortletRequest request, WrappedResponse response, RequestType requestType, - Application application, - PortletApplicationContext2 applicationContext, + VaadinSession application, + VaadinPortletSession applicationContext, PortletCommunicationManager applicationManager) throws PortletException, IOException, MalformedURLException { if (requestType == RequestType.APPLICATION_RESOURCE @@ -761,13 +760,13 @@ public class VaadinPortlet extends GenericPortlet implements Constants { } private void endApplication(PortletRequest request, - PortletResponse response, Application application) + PortletResponse response, VaadinSession application) throws IOException { application.removeFromSession(); // Do not send any redirects when running inside a portlet. } - private Application findApplicationInstance( + private VaadinSession findApplicationInstance( WrappedPortletRequest wrappedRequest, RequestType requestType) throws PortletException, SessionExpiredException, MalformedURLException { @@ -777,7 +776,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { request, requestType); /* Find an existing application for this request. */ - Application application = getExistingApplication(request, + VaadinSession application = getExistingApplication(request, requestCanCreateApplication); if (application != null) { @@ -811,7 +810,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { } } - private void closeApplication(Application application, + private void closeApplication(VaadinSession application, PortletSession session) { if (application == null) { return; @@ -821,9 +820,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants { application.removeFromSession(); } - private Application createAndRegisterApplication(PortletRequest request) + private VaadinSession createAndRegisterApplication(PortletRequest request) throws PortletException { - Application newApplication = createApplication(request); + VaadinSession newApplication = createApplication(request); try { ServletPortletHelper.checkUiProviders(newApplication); @@ -845,9 +844,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants { return newApplication; } - protected PortletApplicationContext2 createApplication( + protected VaadinPortletSession createApplication( PortletRequest request) throws PortletException { - PortletApplicationContext2 application = new PortletApplicationContext2(); + VaadinPortletSession application = new VaadinPortletSession(); try { ServletPortletHelper.initDefaultUIProvider(application, @@ -859,7 +858,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { return application; } - private Application getExistingApplication(PortletRequest request, + private VaadinSession getExistingApplication(PortletRequest request, boolean allowSessionCreation) throws MalformedURLException, SessionExpiredException { @@ -870,7 +869,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { throw new SessionExpiredException(); } - Application application = Application + VaadinSession application = VaadinSession .getForSession(new WrappedPortletSession(session)); if (application == null) { return null; @@ -884,7 +883,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { } private void handleServiceException(WrappedPortletRequest request, - WrappedPortletResponse response, Application application, + WrappedPortletResponse response, VaadinSession application, Throwable e) throws IOException, PortletException { // TODO Check that this error handler is working when running inside a // portlet diff --git a/server/src/com/vaadin/server/PortletApplicationContext2.java b/server/src/com/vaadin/server/VaadinPortletSession.java similarity index 99% rename from server/src/com/vaadin/server/PortletApplicationContext2.java rename to server/src/com/vaadin/server/VaadinPortletSession.java index ff23d12f4c..8d1ae84fca 100644 --- a/server/src/com/vaadin/server/PortletApplicationContext2.java +++ b/server/src/com/vaadin/server/VaadinPortletSession.java @@ -41,7 +41,6 @@ import javax.portlet.StateAwareResponse; import javax.servlet.http.HttpSessionBindingListener; import javax.xml.namespace.QName; -import com.vaadin.Application; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; @@ -54,7 +53,7 @@ import com.vaadin.util.CurrentInstance; * @author peholmst */ @SuppressWarnings("serial") -public class PortletApplicationContext2 extends Application { +public class VaadinPortletSession extends VaadinSession { private final Set portletListeners = new LinkedHashSet(); diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index eb21096c9b..d2e04da2e9 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -44,11 +44,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import com.vaadin.Application; -import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.DefaultApplicationConfiguration; import com.vaadin.server.AbstractCommunicationManager.Callback; import com.vaadin.server.ServletPortletHelper.ApplicationClassException; +import com.vaadin.server.VaadinSession.ApplicationStartEvent; import com.vaadin.shared.ApplicationConstants; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; @@ -285,7 +284,7 @@ public class VaadinServlet extends HttpServlet implements Constants { return; } - Application application = null; + VaadinSession application = null; boolean applicationRunning = false; try { @@ -312,13 +311,13 @@ public class VaadinServlet extends HttpServlet implements Constants { if (application == null) { return; } - Application.setCurrent(application); + VaadinSession.setCurrent(application); /* * Get or create a WebApplicationContext and an ApplicationManager * for the session */ - ServletApplicationContext webApplicationContext = (ServletApplicationContext) application; + VaadinServletSession webApplicationContext = (VaadinServletSession) application; CommunicationManager applicationManager = (CommunicationManager) webApplicationContext .getApplicationManager(); @@ -575,7 +574,7 @@ public class VaadinServlet extends HttpServlet implements Constants { * @throws ServletException * @throws SessionExpiredException */ - private Application findApplicationInstance(HttpServletRequest request, + private VaadinSession findApplicationInstance(HttpServletRequest request, RequestType requestType) throws MalformedURLException, ServletException, SessionExpiredException { @@ -583,7 +582,7 @@ public class VaadinServlet extends HttpServlet implements Constants { request, requestType); /* Find an existing application for this request. */ - Application application = getExistingApplication(request, + VaadinSession application = getExistingApplication(request, requestCanCreateApplication); if (application != null) { @@ -626,9 +625,9 @@ public class VaadinServlet extends HttpServlet implements Constants { } - private Application createAndRegisterApplication(HttpServletRequest request) + private VaadinSession createAndRegisterApplication(HttpServletRequest request) throws ServletException, MalformedURLException { - Application newApplication = createApplication(request); + VaadinSession newApplication = createApplication(request); try { ServletPortletHelper.checkUiProviders(newApplication); @@ -722,9 +721,9 @@ public class VaadinServlet extends HttpServlet implements Constants { * @throws ServletException * @throws MalformedURLException */ - protected ServletApplicationContext createApplication( + protected VaadinServletSession createApplication( HttpServletRequest request) throws ServletException { - ServletApplicationContext newApplication = new ServletApplicationContext(); + VaadinServletSession newApplication = new VaadinServletSession(); try { ServletPortletHelper.initDefaultUIProvider(newApplication, @@ -737,7 +736,7 @@ public class VaadinServlet extends HttpServlet implements Constants { } private void handleServiceException(WrappedHttpServletRequest request, - WrappedHttpServletResponse response, Application application, + WrappedHttpServletResponse response, VaadinSession application, Throwable e) throws IOException, ServletException { // if this was an UIDL request, response UIDL back to client if (getRequestType(request) == RequestType.UIDL) { @@ -1270,7 +1269,7 @@ public class VaadinServlet extends HttpServlet implements Constants { * @throws InstantiationException * @throws SessionExpiredException */ - protected Application getExistingApplication(HttpServletRequest request, + protected VaadinSession getExistingApplication(HttpServletRequest request, boolean allowSessionCreation) throws MalformedURLException, SessionExpiredException { @@ -1280,7 +1279,7 @@ public class VaadinServlet extends HttpServlet implements Constants { throw new SessionExpiredException(); } - Application sessionApplication = getApplicationContext(session); + VaadinSession sessionApplication = getApplicationContext(session); if (sessionApplication == null) { return null; @@ -1307,7 +1306,7 @@ public class VaadinServlet extends HttpServlet implements Constants { * if the writing failed due to input/output error. */ private void endApplication(HttpServletRequest request, - HttpServletResponse response, Application application) + HttpServletResponse response, VaadinSession application) throws IOException { String logoutUrl = application.getLogoutURL(); @@ -1362,7 +1361,7 @@ public class VaadinServlet extends HttpServlet implements Constants { && (request.getParameter(URL_PARAMETER_REPAINT_ALL).equals("1")); } - private void closeApplication(Application application, HttpSession session) { + private void closeApplication(VaadinSession application, HttpSession session) { if (application == null) { return; } @@ -1373,8 +1372,8 @@ public class VaadinServlet extends HttpServlet implements Constants { } } - protected Application getApplicationContext(final HttpSession session) { - Application sessionApplication = Application + protected VaadinSession getApplicationContext(final HttpSession session) { + VaadinSession sessionApplication = VaadinSession .getForSession(new WrappedHttpSession(session)); return sessionApplication; } @@ -1399,11 +1398,11 @@ public class VaadinServlet extends HttpServlet implements Constants { * mananger implementation. * * @deprecated Instead of overriding this method, override - * {@link ServletApplicationContext} implementation via + * {@link VaadinServletSession} implementation via * {@link VaadinServlet#getApplicationContext(HttpSession)} * method and in that customized implementation return your * CommunicationManager in - * {@link ServletApplicationContext#getApplicationManager(Application, VaadinServlet)} + * {@link VaadinServletSession#getApplicationManager(VaadinSession, VaadinServlet)} * method. * * @param application @@ -1411,7 +1410,7 @@ public class VaadinServlet extends HttpServlet implements Constants { */ @Deprecated public CommunicationManager createCommunicationManager( - Application application) { + VaadinSession application) { return new CommunicationManager(application); } diff --git a/server/src/com/vaadin/server/ServletApplicationContext.java b/server/src/com/vaadin/server/VaadinServletSession.java similarity index 97% rename from server/src/com/vaadin/server/ServletApplicationContext.java rename to server/src/com/vaadin/server/VaadinServletSession.java index 0945de6cb5..72b744da72 100644 --- a/server/src/com/vaadin/server/ServletApplicationContext.java +++ b/server/src/com/vaadin/server/VaadinServletSession.java @@ -23,7 +23,6 @@ import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; -import com.vaadin.Application; import com.vaadin.util.CurrentInstance; /** @@ -36,7 +35,7 @@ import com.vaadin.util.CurrentInstance; * @since 3.1 */ @SuppressWarnings("serial") -public class ServletApplicationContext extends Application { +public class VaadinServletSession extends VaadinSession { private transient boolean reinitializingSession = false; diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/server/VaadinSession.java similarity index 96% rename from server/src/com/vaadin/Application.java rename to server/src/com/vaadin/server/VaadinSession.java index 6d37fbd5ae..10532559f0 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin; +package com.vaadin.server; import java.io.IOException; import java.io.Serializable; @@ -41,28 +41,7 @@ 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.AbstractCommunicationManager; -import com.vaadin.server.AbstractErrorMessage; -import com.vaadin.server.ApplicationConfiguration; -import com.vaadin.server.BootstrapFragmentResponse; -import com.vaadin.server.BootstrapListener; -import com.vaadin.server.BootstrapPageResponse; -import com.vaadin.server.BootstrapResponse; -import com.vaadin.server.ChangeVariablesErrorEvent; -import com.vaadin.server.ClientConnector; -import com.vaadin.server.CombinedRequest; -import com.vaadin.server.DeploymentConfiguration; -import com.vaadin.server.GlobalResourceHandler; -import com.vaadin.server.RequestHandler; -import com.vaadin.server.Terminal; -import com.vaadin.server.UIProvider; -import com.vaadin.server.VaadinServlet; -import com.vaadin.server.VariableOwner; -import com.vaadin.server.WebBrowser; -import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedRequest.BrowserDetails; -import com.vaadin.server.WrappedResponse; -import com.vaadin.server.WrappedSession; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; @@ -124,7 +103,7 @@ import com.vaadin.util.ReflectTools; * @since 3.0 */ @SuppressWarnings("serial") -public class Application implements Terminal.ErrorListener, +public class VaadinSession implements Terminal.ErrorListener, HttpSessionBindingListener, Serializable { /** @@ -175,7 +154,7 @@ public class Application implements Terminal.ErrorListener, * @return the URL the application should respond to or * null if the URL is not defined. * - * @see Application#getURL() + * @see VaadinSession#getURL() */ public URL getApplicationUrl() { return applicationUrl; @@ -195,14 +174,14 @@ public class Application implements Terminal.ErrorListener, * * @return the communication manager for this application. * - * @see Application#getCommunicationManager + * @see VaadinSession#getCommunicationManager */ public AbstractCommunicationManager getCommunicationManager() { return communicationManager; } } - private final static Logger logger = Logger.getLogger(Application.class + private final static Logger logger = Logger.getLogger(VaadinSession.class .getName()); /** @@ -371,10 +350,10 @@ public class Application implements Terminal.ErrorListener, } } - public static Application getForSession(WrappedSession session) { - Object attribute = session.getAttribute(Application.class.getName()); - if (attribute instanceof Application) { - Application application = (Application) attribute; + public static VaadinSession getForSession(WrappedSession session) { + Object attribute = session.getAttribute(VaadinSession.class.getName()); + if (attribute instanceof VaadinSession) { + VaadinSession application = (VaadinSession) attribute; application.session = session; return application; } @@ -385,11 +364,11 @@ public class Application implements Terminal.ErrorListener, public void removeFromSession() { assert (getForSession(session) == this); - session.setAttribute(Application.class.getName(), null); + session.setAttribute(VaadinSession.class.getName(), null); } public void storeInSession(WrappedSession session) { - session.setAttribute(Application.class.getName(), this); + session.setAttribute(VaadinSession.class.getName(), this); this.session = session; } @@ -479,7 +458,7 @@ public class Application implements Terminal.ErrorListener, * Window detach event. * * This event is sent each time a window is removed from the application - * with {@link com.vaadin.Application#removeWindow(Window)}. + * with {@link com.vaadin.server.VaadinSession#removeWindow(Window)}. */ public static class WindowDetachEvent extends EventObject { @@ -493,7 +472,7 @@ public class Application implements Terminal.ErrorListener, * @param window * the Detached window. */ - public WindowDetachEvent(Application application, Window window) { + public WindowDetachEvent(VaadinSession application, Window window) { super(application); this.window = window; } @@ -512,8 +491,8 @@ public class Application implements Terminal.ErrorListener, * * @return the Application. */ - public Application getApplication() { - return (Application) getSource(); + public VaadinSession getApplication() { + return (VaadinSession) getSource(); } } @@ -521,7 +500,7 @@ public class Application implements Terminal.ErrorListener, * Window attach event. * * This event is sent each time a window is attached tothe application with - * {@link com.vaadin.Application#addWindow(Window)}. + * {@link com.vaadin.server.VaadinSession#addWindow(Window)}. */ public static class WindowAttachEvent extends EventObject { @@ -535,7 +514,7 @@ public class Application implements Terminal.ErrorListener, * @param window * the Attached window. */ - public WindowAttachEvent(Application application, Window window) { + public WindowAttachEvent(VaadinSession application, Window window) { super(application); this.window = window; } @@ -554,8 +533,8 @@ public class Application implements Terminal.ErrorListener, * * @return the Application. */ - public Application getApplication() { - return (Application) getSource(); + public VaadinSession getApplication() { + return (VaadinSession) getSource(); } } @@ -729,7 +708,7 @@ public class Application implements Terminal.ErrorListener, * critical situations that can occur. *

* Customize by overriding the static - * {@link Application#getSystemMessages()} and returning + * {@link VaadinSession#getSystemMessages()} and returning * {@link CustomizedSystemMessages}. *

*

@@ -1362,7 +1341,7 @@ public class Application implements Terminal.ErrorListener, * Subclasses of Application may override this method to provide custom * logic for choosing what kind of UI to use. *

- * The default implementation in {@link Application} uses the + * The default implementation in {@link VaadinSession} uses the * {@value #UI_PARAMETER} parameter from web.xml for finding the name of the * UI class. If {@link DeploymentConfiguration#getClassLoader()} does not * return null, the returned {@link ClassLoader} is used for @@ -1588,12 +1567,12 @@ public class Application implements Terminal.ErrorListener, * @return the current application instance if available, otherwise * null * - * @see #setCurrent(Application) + * @see #setCurrent(VaadinSession) * * @since 7.0 */ - public static Application getCurrent() { - return CurrentInstance.get(Application.class); + public static VaadinSession getCurrent() { + return CurrentInstance.get(VaadinSession.class); } /** @@ -1613,8 +1592,8 @@ public class Application implements Terminal.ErrorListener, * * @since 7.0 */ - public static void setCurrent(Application application) { - CurrentInstance.setInheritable(Application.class, application); + public static void setCurrent(VaadinSession application) { + CurrentInstance.setInheritable(VaadinSession.class, application); } /** @@ -1808,7 +1787,7 @@ public class Application implements Terminal.ErrorListener, } private static final Logger getLogger() { - return Logger.getLogger(Application.class.getName()); + return Logger.getLogger(VaadinSession.class.getName()); } /** diff --git a/server/src/com/vaadin/server/WrappedHttpServletRequest.java b/server/src/com/vaadin/server/WrappedHttpServletRequest.java index 05d9b13736..4221551601 100644 --- a/server/src/com/vaadin/server/WrappedHttpServletRequest.java +++ b/server/src/com/vaadin/server/WrappedHttpServletRequest.java @@ -19,7 +19,6 @@ package com.vaadin.server; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; -import com.vaadin.Application; /** * Wrapper for {@link HttpServletRequest}. @@ -89,7 +88,7 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper @Override public WebBrowser getWebBrowser() { - return Application.getCurrent().getBrowser(); + return VaadinSession.getCurrent().getBrowser(); } }; } diff --git a/server/src/com/vaadin/server/WrappedPortletRequest.java b/server/src/com/vaadin/server/WrappedPortletRequest.java index dffbebb379..65099add76 100644 --- a/server/src/com/vaadin/server/WrappedPortletRequest.java +++ b/server/src/com/vaadin/server/WrappedPortletRequest.java @@ -25,7 +25,6 @@ import javax.portlet.ClientDataRequest; import javax.portlet.PortletRequest; import javax.portlet.ResourceRequest; -import com.vaadin.Application; import com.vaadin.shared.ApplicationConstants; /** @@ -151,7 +150,7 @@ public class WrappedPortletRequest implements WrappedRequest { @Override public WebBrowser getWebBrowser() { - PortletApplicationContext2 context = (PortletApplicationContext2) Application + VaadinPortletSession context = (VaadinPortletSession) VaadinSession .getCurrent(); return context.getBrowser(); } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 37ca9f1a03..e6cc80f1cf 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -27,7 +27,6 @@ import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.vaadin.Application; import com.vaadin.event.ActionManager; import com.vaadin.event.EventRouter; import com.vaadin.event.MethodEventSource; @@ -38,6 +37,7 @@ import com.vaadin.server.ComponentSizeValidator; import com.vaadin.server.ErrorMessage; import com.vaadin.server.Resource; import com.vaadin.server.Terminal; +import com.vaadin.server.VaadinSession; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentState; import com.vaadin.shared.ui.ComponentStateUtil; @@ -259,7 +259,7 @@ public abstract class AbstractComponent extends AbstractClientConnector if (parent != null) { return parent.getLocale(); } - final Application app = getApplication(); + final VaadinSession app = getApplication(); if (app != null) { return app.getLocale(); } @@ -616,7 +616,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ protected void focus() { if (this instanceof Focusable) { - final Application app = getApplication(); + final VaadinSession app = getApplication(); if (app != null) { getUI().setFocusedComponent((Focusable) this); delayedFocus = false; @@ -646,7 +646,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @see #attach() */ @Override - public Application getApplication() { + public VaadinSession getApplication() { // Just make method inherited from Component interface public return super.getApplication(); } diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index 5bd1d53b86..812edbb8d2 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -21,12 +21,12 @@ import java.util.EventListener; import java.util.EventObject; import java.util.Locale; -import com.vaadin.Application; import com.vaadin.event.FieldEvents; import com.vaadin.server.ClientConnector; import com.vaadin.server.ErrorMessage; import com.vaadin.server.Resource; import com.vaadin.server.Sizeable; +import com.vaadin.server.VaadinSession; import com.vaadin.server.VariableOwner; /** @@ -532,7 +532,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { *

* Getting a null value is often a problem in constructors of regular * components and in the initializers of custom composite components. A - * standard workaround is to use {@link Application#getCurrent()} to + * standard workaround is to use {@link VaadinSession#getCurrent()} to * retrieve the application instance that the current request relates to. * Another way is to move the problematic initialization to * {@link #attach()}, as described in the documentation of the method. @@ -541,7 +541,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * @return the parent application of the component or null. * @see #attach() */ - public Application getApplication(); + public VaadinSession getApplication(); /** * {@inheritDoc} diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index 61846eab4e..1d0c5c41b6 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -24,10 +24,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import com.vaadin.Application; import com.vaadin.server.ConnectorResource; import com.vaadin.server.DownloadStream; import com.vaadin.server.RequestHandler; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedResponse; import com.vaadin.shared.ApplicationConstants; @@ -83,7 +83,7 @@ public class LoginForm extends CustomComponent { private final RequestHandler requestHandler = new RequestHandler() { @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { String requestPathInfo = request.getRequestPathInfo(); diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 7389a898eb..e2d79454f6 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -27,7 +27,6 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; @@ -42,6 +41,7 @@ import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; import com.vaadin.server.VaadinServlet; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedRequest.BrowserDetails; import com.vaadin.shared.EventId; @@ -66,9 +66,9 @@ import com.vaadin.util.ReflectTools; *

* When a new UI instance is needed, typically because the user opens a URL in a * browser window which points to {@link VaadinServlet}, - * {@link Application#getUIForRequest(WrappedRequest)} is invoked to get a UI. + * {@link VaadinSession#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. + * {@value VaadinSession#UI_PARAMETER} parameter from web.xml. *

*

* After a UI has been created by the application, it is initialized using @@ -80,7 +80,7 @@ import com.vaadin.util.ReflectTools; *

* * @see #init(WrappedRequest) - * @see Application#createUI(WrappedRequest) + * @see VaadinSession#createUI(WrappedRequest) * * @since 7.0 */ @@ -135,7 +135,7 @@ public abstract class UI extends AbstractComponentContainer implements * The name also determines the URL that can be used for direct access * to a window. All windows can be accessed through * {@code http://host:port/app/win} where {@code http://host:port/app} - * is the application URL (as returned by {@link Application#getURL()} + * is the application URL (as returned by {@link VaadinSession#getURL()} * and {@code win} is the window name. *

*

@@ -155,7 +155,7 @@ public abstract class UI extends AbstractComponentContainer implements * The name also determines the URL that can be used for direct access * to a window. All windows can be accessed through * {@code http://host:port/app/win} where {@code http://host:port/app} - * is the application URL (as returned by {@link Application#getURL()} + * is the application URL (as returned by {@link VaadinSession#getURL()} * and {@code win} is the window name. *

*

@@ -193,7 +193,7 @@ public abstract class UI extends AbstractComponentContainer implements * to an application */ public URL getURL() { - Application application = getApplication(); + VaadinSession application = getApplication(); if (application == null) { return null; } @@ -424,7 +424,7 @@ public abstract class UI extends AbstractComponentContainer implements /** * The application to which this UI belongs */ - private Application application; + private VaadinSession application; /** * List of windows in this UI. @@ -442,7 +442,7 @@ public abstract class UI extends AbstractComponentContainer implements * which a request originates. A negative value indicates that the UI id has * not yet been assigned by the Application. * - * @see Application#nextUIId + * @see VaadinSession#nextUIId */ private int uiId = -1; @@ -564,7 +564,7 @@ public abstract class UI extends AbstractComponentContainer implements } @Override - public Application getApplication() { + public VaadinSession getApplication() { return application; } @@ -684,7 +684,7 @@ public abstract class UI extends AbstractComponentContainer implements * * @see #getApplication() */ - public void setApplication(Application application) { + public void setApplication(VaadinSession application) { if ((application == null) == (this.application == null)) { throw new IllegalStateException("Application has already been set"); } else { @@ -703,7 +703,7 @@ public abstract class UI extends AbstractComponentContainer implements * Gets the id of the UI, used to identify this UI within its application * when processing requests. The UI id should be present in every request to * the server that originates from this UI. - * {@link Application#getUIForRequest(WrappedRequest)} uses this id to find + * {@link VaadinSession#getUIForRequest(WrappedRequest)} uses this id to find * the route to which the request belongs. * * @return @@ -716,7 +716,7 @@ public abstract class UI extends AbstractComponentContainer implements * Adds a window as a subwindow inside this UI. To open a new browser window * or tab, you should instead use {@link open(Resource)} with an url * pointing to this application and ensure - * {@link Application#createUI(WrappedRequest)} returns an appropriate UI + * {@link VaadinSession#createUI(WrappedRequest)} returns an appropriate UI * for the request. * * @param window @@ -1294,7 +1294,7 @@ public abstract class UI extends AbstractComponentContainer implements * heartbeat for this UI. * * @see #heartbeat() - * @see Application#closeInactiveUIs() + * @see VaadinSession#closeInactiveUIs() * * @return The time the last heartbeat request occurred. */ diff --git a/server/tests/src/com/vaadin/tests/VaadinClasses.java b/server/tests/src/com/vaadin/tests/VaadinClasses.java index 15e1283e47..b30ddcee7e 100644 --- a/server/tests/src/com/vaadin/tests/VaadinClasses.java +++ b/server/tests/src/com/vaadin/tests/VaadinClasses.java @@ -15,7 +15,7 @@ import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; -import com.vaadin.Application; +import com.vaadin.server.VaadinSession; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.CustomComponent; @@ -144,7 +144,7 @@ public class VaadinClasses { String basePackage, String[] ignoredPackages) throws IOException { List> classes = new ArrayList>(); String basePackageDirName = "/" + basePackage.replace('.', '/'); - URL location = Application.class.getResource(basePackageDirName); + URL location = VaadinSession.class.getResource(basePackageDirName); if (location.getProtocol().equals("file")) { try { File f = new File(location.toURI()); diff --git a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java index 6393d61981..66160907b2 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java @@ -19,9 +19,9 @@ import java.util.Locale; import junit.framework.TestCase; -import com.vaadin.Application; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.DefaultConverterFactory; +import com.vaadin.server.VaadinSession; import com.vaadin.ui.TextField; public class ConverterFactory extends TestCase { @@ -65,14 +65,14 @@ public class ConverterFactory extends TestCase { } public void testApplicationConverterFactoryInBackgroundThread() { - Application.setCurrent(null); - final Application appWithCustomIntegerConverter = new Application(); + VaadinSession.setCurrent(null); + final VaadinSession appWithCustomIntegerConverter = new VaadinSession(); appWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); TextField tf = new TextField("", "123") { @Override - public Application getApplication() { + public VaadinSession getApplication() { return appWithCustomIntegerConverter; }; }; @@ -83,10 +83,10 @@ public class ConverterFactory extends TestCase { } public void testApplicationConverterFactoryForDetachedComponent() { - final Application appWithCustomIntegerConverter = new Application(); + final VaadinSession appWithCustomIntegerConverter = new VaadinSession(); appWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); - Application.setCurrent(appWithCustomIntegerConverter); + VaadinSession.setCurrent(appWithCustomIntegerConverter); TextField tf = new TextField("", "123"); tf.setConverter(Integer.class); @@ -96,14 +96,14 @@ public class ConverterFactory extends TestCase { } public void testApplicationConverterFactoryForDifferentThanCurrentApplication() { - final Application fieldAppWithCustomIntegerConverter = new Application(); + final VaadinSession fieldAppWithCustomIntegerConverter = new VaadinSession(); fieldAppWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); - Application.setCurrent(new Application()); + VaadinSession.setCurrent(new VaadinSession()); TextField tf = new TextField("", "123") { @Override - public Application getApplication() { + public VaadinSession getApplication() { return fieldAppWithCustomIntegerConverter; } }; diff --git a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java b/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java index 775348fb5c..e286e7231e 100644 --- a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java +++ b/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java @@ -4,9 +4,9 @@ import junit.framework.TestCase; import org.easymock.EasyMock; -import com.vaadin.Application; import com.vaadin.server.CommunicationManager; import com.vaadin.server.StreamVariable; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.ui.UI; import com.vaadin.ui.Upload; @@ -21,7 +21,7 @@ public class TestStreamVariableMapping extends TestCase { @Override protected void setUp() throws Exception { - final Application application = new Application(); + final VaadinSession application = new VaadinSession(); final UI uI = new UI() { @Override protected void init(WrappedRequest request) { @@ -30,7 +30,7 @@ public class TestStreamVariableMapping extends TestCase { } @Override - public Application getApplication() { + public VaadinSession getApplication() { return application; } }; @@ -66,7 +66,7 @@ public class TestStreamVariableMapping extends TestCase { } private CommunicationManager createCommunicationManager() { - return new CommunicationManager(new Application()); + return new CommunicationManager(new VaadinSession()); } } diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java index 57af748247..d372b96339 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java @@ -4,10 +4,10 @@ import java.util.Locale; import junit.framework.TestCase; -import com.vaadin.Application; import com.vaadin.data.util.MethodProperty; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.StringToIntegerConverter; +import com.vaadin.server.VaadinSession; import com.vaadin.tests.data.bean.Address; import com.vaadin.tests.data.bean.Country; import com.vaadin.tests.data.bean.Person; @@ -186,11 +186,11 @@ public class AbstractFieldValueConversions extends TestCase { } public void testNumberDoubleConverterChange() { - final Application a = new Application(); - Application.setCurrent(a); + final VaadinSession a = new VaadinSession(); + VaadinSession.setCurrent(a); TextField tf = new TextField() { @Override - public Application getApplication() { + public VaadinSession getApplication() { return a; } }; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java index 25430fc9a5..a1b6541ee0 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java @@ -5,8 +5,8 @@ import java.util.Locale; import junit.framework.TestCase; -import com.vaadin.Application; import com.vaadin.data.util.MethodProperty; +import com.vaadin.server.VaadinSession; import com.vaadin.tests.data.bean.Address; import com.vaadin.tests.data.bean.Country; import com.vaadin.tests.data.bean.Person; @@ -26,8 +26,8 @@ public class DefaultConverterFactory extends TestCase { } public void testDefaultNumberConversion() { - Application app = new Application(); - Application.setCurrent(app); + VaadinSession app = new VaadinSession(); + VaadinSession.setCurrent(app); TextField tf = new TextField(); tf.setLocale(new Locale("en", "US")); tf.setPropertyDataSource(new MethodProperty(paulaBean, diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index 18567b62f0..b498bbe73f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -4,10 +4,10 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; -import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.util.AbstractProperty; import com.vaadin.data.util.converter.Converter.ConversionException; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.ui.AbstractField; import com.vaadin.ui.UI; @@ -18,7 +18,7 @@ public class RemoveListenersOnDetach { int numReadOnlyChanges = 0; AbstractField field = new AbstractField() { - final private Application application = new Application() { + final private VaadinSession application = new VaadinSession() { }; private UI uI = new UI() { @@ -29,7 +29,7 @@ public class RemoveListenersOnDetach { } @Override - public Application getApplication() { + public VaadinSession getApplication() { return application; } @@ -59,7 +59,7 @@ public class RemoveListenersOnDetach { }; @Override - public Application getApplication() { + public VaadinSession getApplication() { return application; }; }; diff --git a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java b/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java index 48279c7c88..22cd450af7 100644 --- a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java +++ b/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java @@ -17,9 +17,9 @@ package com.vaadin.tests.server.component.label; import junit.framework.TestCase; -import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.util.MethodProperty; +import com.vaadin.server.VaadinSession; import com.vaadin.tests.data.bean.Person; import com.vaadin.ui.Label; @@ -37,7 +37,7 @@ public class LabelConverters extends TestCase { } public void testIntegerDataSource() { - Application.setCurrent(new Application()); + VaadinSession.setCurrent(new VaadinSession()); Label l = new Label("Foo"); Property ds = new MethodProperty(Person.createTestPerson1(), "age"); 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 aef35084f8..acc2ed3b14 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,13 +8,13 @@ import junit.framework.TestCase; import org.easymock.EasyMock; -import com.vaadin.Application; -import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.DefaultApplicationConfiguration; import com.vaadin.server.ApplicationConfiguration; import com.vaadin.server.DefaultUIProvider; import com.vaadin.server.DeploymentConfiguration; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; +import com.vaadin.server.VaadinSession.ApplicationStartEvent; import com.vaadin.ui.UI; public class CustomUIClassLoader extends TestCase { @@ -53,7 +53,7 @@ public class CustomUIClassLoader extends TestCase { * if thrown */ public void testWithNullClassLoader() throws Exception { - Application application = createStubApplication(); + VaadinSession application = createStubApplication(); application.start(new ApplicationStartEvent(null, createConfigurationMock(), null)); @@ -66,7 +66,7 @@ public class CustomUIClassLoader extends TestCase { private static ApplicationConfiguration createConfigurationMock() { Properties properties = new Properties(); - properties.put(Application.UI_PARAMETER, MyUI.class.getName()); + properties.put(VaadinSession.UI_PARAMETER, MyUI.class.getName()); return new DefaultApplicationConfiguration(CustomUIClassLoader.class, properties); } @@ -97,7 +97,7 @@ public class CustomUIClassLoader extends TestCase { public void testWithClassLoader() throws Exception { LoggingClassLoader loggingClassLoader = new LoggingClassLoader(); - Application application = createStubApplication(); + VaadinSession application = createStubApplication(); application.start(new ApplicationStartEvent(null, createConfigurationMock(), null)); @@ -112,8 +112,8 @@ public class CustomUIClassLoader extends TestCase { } - private Application createStubApplication() { - return new Application() { + private VaadinSession createStubApplication() { + return new VaadinSession() { @Override public ApplicationConfiguration getConfiguration() { return createConfigurationMock(); diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java index 0fb0765c9f..bab7ca2c8c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java @@ -5,7 +5,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; -import com.vaadin.Application; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -14,7 +14,7 @@ import com.vaadin.ui.Window; public class AttachDetachWindow { - private Application testApp = new Application(); + private VaadinSession testApp = new VaadinSession(); private interface TestContainer { public boolean attachCalled(); @@ -23,7 +23,7 @@ public class AttachDetachWindow { public TestContent getTestContent(); - public Application getApplication(); + public VaadinSession getApplication(); } private class TestWindow extends Window implements TestContainer { diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index 34c1cc1fce..4f37a9b505 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -29,13 +29,13 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.server.AbstractUIProvider; import com.vaadin.server.ApplicationConfiguration; import com.vaadin.server.LegacyVaadinServlet; -import com.vaadin.server.ServletApplicationContext; +import com.vaadin.server.VaadinServletSession; import com.vaadin.server.UIProvider; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedHttpServletRequest; import com.vaadin.server.WrappedRequest; import com.vaadin.tests.components.TestBase; @@ -113,17 +113,17 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } @Override - protected ServletApplicationContext createApplication( + protected VaadinServletSession createApplication( HttpServletRequest request) throws ServletException { try { final Class classToRun = getClassToRun(); if (UI.class.isAssignableFrom(classToRun)) { - ServletApplicationContext application = new ServletApplicationContext(); + VaadinServletSession application = new VaadinServletSession(); application.addUIProvider(new AbstractUIProvider() { @Override public Class getUIClass( - Application application, WrappedRequest request) { + VaadinSession application, WrappedRequest request) { return (Class) classToRun; } }); @@ -131,7 +131,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } else if (LegacyApplication.class.isAssignableFrom(classToRun)) { return super.createApplication(request); } else if (UIProvider.class.isAssignableFrom(classToRun)) { - ServletApplicationContext application = new ServletApplicationContext(); + VaadinServletSession application = new VaadinServletSession(); application .addUIProvider((UIProvider) classToRun.newInstance()); return application; diff --git a/uitest/src/com/vaadin/tests/ModalWindow.java b/uitest/src/com/vaadin/tests/ModalWindow.java index 558989e069..7c9e60c943 100644 --- a/uitest/src/com/vaadin/tests/ModalWindow.java +++ b/uitest/src/com/vaadin/tests/ModalWindow.java @@ -31,7 +31,7 @@ import com.vaadin.ui.Window; * * @author Vaadin Ltd. * @since 4.0.1 - * @see com.vaadin.Application + * @see com.vaadin.server.VaadinSession * @see com.vaadin.ui.Window * @see com.vaadin.ui.Label */ diff --git a/uitest/src/com/vaadin/tests/Parameters.java b/uitest/src/com/vaadin/tests/Parameters.java index 901b0a6dd7..01270456c8 100644 --- a/uitest/src/com/vaadin/tests/Parameters.java +++ b/uitest/src/com/vaadin/tests/Parameters.java @@ -21,10 +21,10 @@ import java.net.URL; import java.util.Iterator; import java.util.Map; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedResponse; import com.vaadin.ui.Label; @@ -57,7 +57,7 @@ public class Parameters extends com.vaadin.LegacyApplication setMainWindow(main); // This class acts both as URI handler and parameter handler - Application.getCurrent().addRequestHandler(this); + VaadinSession.getCurrent().addRequestHandler(this); final VerticalLayout layout = new VerticalLayout(); final Label info = new Label("To test URI and Parameter Handlers, " @@ -107,7 +107,7 @@ public class Parameters extends com.vaadin.LegacyApplication } @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { context.setValue("Context not available"); diff --git a/uitest/src/com/vaadin/tests/TestBench.java b/uitest/src/com/vaadin/tests/TestBench.java index d5b603db39..098ce4af29 100644 --- a/uitest/src/com/vaadin/tests/TestBench.java +++ b/uitest/src/com/vaadin/tests/TestBench.java @@ -312,7 +312,7 @@ public class TestBench extends com.vaadin.LegacyApplication final Class c = Class.forName(p); if (c.getSuperclass() != null) { if ((c.getSuperclass() - .equals(com.vaadin.Application.class))) { + .equals(com.vaadin.server.VaadinSession.class))) { classes.add(c); } else if ((c.getSuperclass() .equals(com.vaadin.ui.CustomComponent.class))) { diff --git a/uitest/src/com/vaadin/tests/TreeFilesystem.java b/uitest/src/com/vaadin/tests/TreeFilesystem.java index 096952c74c..3d1705381e 100644 --- a/uitest/src/com/vaadin/tests/TreeFilesystem.java +++ b/uitest/src/com/vaadin/tests/TreeFilesystem.java @@ -18,9 +18,9 @@ package com.vaadin.tests; import java.io.File; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.data.Item; +import com.vaadin.server.VaadinSession; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.util.SampleDirectory; import com.vaadin.ui.Label; @@ -64,7 +64,7 @@ public class TreeFilesystem extends com.vaadin.LegacyApplication // Get sample directory final File sampleDir = SampleDirectory.getDirectory( - Application.getCurrent(), main); + VaadinSession.getCurrent(), main); // populate tree's root node with example directory if (sampleDir != null) { populateNode(sampleDir.getAbsolutePath(), null); diff --git a/uitest/src/com/vaadin/tests/TreeFilesystemContainer.java b/uitest/src/com/vaadin/tests/TreeFilesystemContainer.java index baf73b4383..b61a7a53a5 100644 --- a/uitest/src/com/vaadin/tests/TreeFilesystemContainer.java +++ b/uitest/src/com/vaadin/tests/TreeFilesystemContainer.java @@ -18,10 +18,10 @@ package com.vaadin.tests; import java.io.File; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.data.util.FilesystemContainer; import com.vaadin.data.util.FilesystemContainer.FileItem; +import com.vaadin.server.VaadinSession; import com.vaadin.tests.util.SampleDirectory; import com.vaadin.ui.Component.Event; import com.vaadin.ui.Component.Listener; @@ -80,7 +80,7 @@ public class TreeFilesystemContainer extends // Get sample directory final File sampleDir = SampleDirectory.getDirectory( - Application.getCurrent(), w); + VaadinSession.getCurrent(), w); // Populate tree with FilesystemContainer final FilesystemContainer fsc = new FilesystemContainer(sampleDir, true); filesystem.setContainerDataSource(fsc); diff --git a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java index 1eda9e54fe..3adb284f1b 100644 --- a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java @@ -1,8 +1,8 @@ package com.vaadin.tests.application; -import com.vaadin.Application; import com.vaadin.server.DownloadStream; import com.vaadin.server.PaintException; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.integration.FlagSeResource; @@ -14,7 +14,7 @@ import com.vaadin.ui.UI; import com.vaadin.ui.UI.LegacyWindow; public class ThreadLocalInstances extends AbstractTestCase { - private static final Application staticInitApplication = Application + private static final VaadinSession staticInitApplication = VaadinSession .getCurrent(); private static final UI staticInitRoot = UI.getCurrent(); @@ -87,10 +87,10 @@ public class ThreadLocalInstances extends AbstractTestCase { } private void reportCurrentStatus(String phase) { - reportStatus(phase, Application.getCurrent(), UI.getCurrent()); + reportStatus(phase, VaadinSession.getCurrent(), UI.getCurrent()); } - private void reportStatus(String phase, Application application, UI uI) { + private void reportStatus(String phase, VaadinSession application, UI uI) { log.log(getState(application, this) + " app in " + phase); log.log(getState(uI, mainWindow) + " root in " + phase); } diff --git a/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java index 96ebe1345f..72e0a215a7 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java @@ -1,6 +1,6 @@ package com.vaadin.tests.applicationcontext; -import com.vaadin.server.ServletApplicationContext; +import com.vaadin.server.VaadinServletSession; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; @@ -32,7 +32,7 @@ public class ChangeSessionId extends AbstractTestCase { loginButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { - ServletApplicationContext context = ((ServletApplicationContext) getContext()); + VaadinServletSession context = ((VaadinServletSession) getContext()); String oldSessionId = context.getHttpSession().getId(); context.reinitializeSession(); @@ -55,7 +55,7 @@ public class ChangeSessionId extends AbstractTestCase { } protected String getSessionId() { - return ((ServletApplicationContext) getContext()).getHttpSession().getId(); + return ((VaadinServletSession) getContext()).getHttpSession().getId(); } @Override diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestCase.java b/uitest/src/com/vaadin/tests/components/AbstractTestCase.java index 5dc5fd7128..356b130433 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestCase.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestCase.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components; -import com.vaadin.Application; import com.vaadin.LegacyApplication; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WebBrowser; public abstract class AbstractTestCase extends LegacyApplication { @@ -11,7 +11,7 @@ public abstract class AbstractTestCase extends LegacyApplication { protected abstract Integer getTicketNumber(); protected WebBrowser getBrowser() { - WebBrowser webBrowser = Application.getCurrent().getBrowser(); + WebBrowser webBrowser = VaadinSession.getCurrent().getBrowser(); return webBrowser; } diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUIProvider.java b/uitest/src/com/vaadin/tests/components/AbstractTestUIProvider.java index 4311cd6a0f..db388405a8 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUIProvider.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUIProvider.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components; -import com.vaadin.Application; import com.vaadin.server.AbstractUIProvider; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WebBrowser; public abstract class AbstractTestUIProvider extends AbstractUIProvider { @@ -10,7 +10,7 @@ public abstract class AbstractTestUIProvider extends AbstractUIProvider { protected abstract Integer getTicketNumber(); protected WebBrowser getBrowser() { - WebBrowser webBrowser = Application.getCurrent().getBrowser(); + WebBrowser webBrowser = VaadinSession.getCurrent().getBrowser(); return webBrowser; } } diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java index 327ed0f86b..2eef498aff 100644 --- a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java +++ b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java @@ -4,11 +4,11 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; -import com.vaadin.Application; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.AbstractField; @@ -55,7 +55,7 @@ public abstract class AbstractComponentDataBindingTest extends TestBase } protected void updateLocale(Locale locale) { - Application.getCurrent().setLocale(locale); + VaadinSession.getCurrent().setLocale(locale); for (Component c : fields) { removeComponent(c); } diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java index b141dc0990..a3ca2420f7 100644 --- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java +++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.ui; -import com.vaadin.Application; import com.vaadin.server.ExternalResource; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractTestUIProvider; @@ -20,13 +20,13 @@ public class LazyInitUIs extends AbstractTestUIProvider { } @Override - public UI createInstance(Application application, Class type, + public UI createInstance(VaadinSession application, Class type, WrappedRequest request) { return getUI(request); } @Override - public Class getUIClass(Application application, + public Class getUIClass(VaadinSession application, WrappedRequest request) { return getUI(request).getClass(); } @@ -52,13 +52,13 @@ public class LazyInitUIs extends AbstractTestUIProvider { addComponent(getRequestInfo("NormalUI", request)); Link lazyCreateLink = new Link("Open lazyCreate UI", - new ExternalResource(Application.getCurrent() + new ExternalResource(VaadinSession.getCurrent() .getURL() + "?lazyCreate#lazyCreate")); lazyCreateLink.setTargetName("_blank"); addComponent(lazyCreateLink); Link lazyInitLink = new Link("Open eagerInit UI", - new ExternalResource(Application.getCurrent() + new ExternalResource(VaadinSession.getCurrent() .getURL() + "?eagerInit#eagerInit")); lazyInitLink.setTargetName("_blank"); addComponent(lazyInitLink); diff --git a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java index 9a66e9ad0a..19c85a729d 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java +++ b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components.ui; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import com.vaadin.Application; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.tests.components.AbstractTestUIProvider; import com.vaadin.ui.Label; @@ -11,12 +11,12 @@ import com.vaadin.ui.UI; public class UIsInMultipleTabs extends AbstractTestUIProvider { // No cleanup -> will leak, but shouldn't matter for tests - private static ConcurrentHashMap numberOfUIsOpened = new ConcurrentHashMap(); + private static ConcurrentHashMap numberOfUIsOpened = new ConcurrentHashMap(); public static class TabUI extends UI { @Override protected void init(WrappedRequest request) { - Application application = Application.getCurrent(); + VaadinSession application = VaadinSession.getCurrent(); AtomicInteger count = numberOfUIsOpened.get(application); if (count == null) { numberOfUIsOpened.putIfAbsent(application, new AtomicInteger()); @@ -32,7 +32,7 @@ public class UIsInMultipleTabs extends AbstractTestUIProvider { } @Override - public Class getUIClass(Application application, + public Class getUIClass(VaadinSession application, WrappedRequest request) { return TabUI.class; } diff --git a/uitest/src/com/vaadin/tests/integration/JSR286PortletApplication.java b/uitest/src/com/vaadin/tests/integration/JSR286PortletApplication.java index a296d912bc..f3c7f009c8 100644 --- a/uitest/src/com/vaadin/tests/integration/JSR286PortletApplication.java +++ b/uitest/src/com/vaadin/tests/integration/JSR286PortletApplication.java @@ -21,8 +21,8 @@ import javax.portlet.WindowState; import com.vaadin.LegacyApplication; import com.vaadin.annotations.StyleSheet; import com.vaadin.server.ExternalResource; -import com.vaadin.server.PortletApplicationContext2; -import com.vaadin.server.PortletApplicationContext2.PortletListener; +import com.vaadin.server.VaadinPortletSession; +import com.vaadin.server.VaadinPortletSession.PortletListener; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Embedded; import com.vaadin.ui.Label; @@ -87,8 +87,8 @@ public class JSR286PortletApplication extends LegacyApplication { }); main.addComponent(upload); - if (getContext() instanceof PortletApplicationContext2) { - PortletApplicationContext2 ctx = (PortletApplicationContext2) getContext(); + if (getContext() instanceof VaadinPortletSession) { + VaadinPortletSession ctx = (VaadinPortletSession) getContext(); ctx.addPortletListener(new DemoPortletListener()); } else { getMainWindow().showNotification("Not inited via Portal!", diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index 05da2506e8..f9309d87b2 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -16,8 +16,8 @@ package com.vaadin.tests.minitutorials.v7a1; -import com.vaadin.Application; import com.vaadin.server.AbstractUIProvider; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WebBrowser; import com.vaadin.server.WrappedRequest; import com.vaadin.ui.Label; @@ -34,7 +34,7 @@ import com.vaadin.ui.UI; public class DifferentFeaturesForDifferentClients extends AbstractUIProvider { @Override - public Class getUIClass(Application application, + public Class getUIClass(VaadinSession application, WrappedRequest request) { // could also use browser version etc. if (request.getHeader("user-agent").contains("mobile")) { @@ -47,7 +47,7 @@ public class DifferentFeaturesForDifferentClients extends AbstractUIProvider { // Must override as default implementation isn't allowed to // instantiate our non-public classes @Override - public UI createInstance(Application application, Class type, + public UI createInstance(VaadinSession application, Class type, WrappedRequest request) { try { return type.newInstance(); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java index 4fd9c1187b..d78cdd9ad5 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java @@ -7,9 +7,9 @@ import java.net.URL; import javax.imageio.ImageIO; -import com.vaadin.Application; import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedResponse; import com.vaadin.tests.components.AbstractTestUI; @@ -56,7 +56,7 @@ class DynamicImageRequestHandler implements RequestHandler { public static final String IMAGE_URL = "myimage.png"; @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { String pathInfo = request.getRequestPathInfo(); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java index e0f53935c7..147ea2a919 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java @@ -16,7 +16,7 @@ package com.vaadin.tests.minitutorials.v7a1; -import com.vaadin.Application; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -41,7 +41,7 @@ public class FindCurrentUI extends UI { @Override public void buttonClick(ClickEvent event) { String msg = "Running in "; - msg += Application.getCurrent().isProductionMode() ? "production" + msg += VaadinSession.getCurrent().isProductionMode() ? "production" : "debug"; Notification.show(msg); } diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1589.java b/uitest/src/com/vaadin/tests/tickets/Ticket1589.java index 580aa3f7a6..4e90ae0e9e 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket1589.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket1589.java @@ -10,11 +10,11 @@ import java.util.Date; import javax.imageio.ImageIO; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.server.DownloadStream; import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedResponse; import com.vaadin.ui.Link; @@ -29,7 +29,7 @@ public class Ticket1589 extends LegacyApplication { MyDynamicResource res = new MyDynamicResource(); - Application.getCurrent().addRequestHandler(res); + VaadinSession.getCurrent().addRequestHandler(res); w.addComponent(new Link( "Test (without Content-Disposition, should suggest generatedFile.png when saving, browser default for actual disposition)", @@ -52,7 +52,7 @@ class MyDynamicResource implements RequestHandler { * stream that contains the response from the server. */ @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { String relativeUri = request.getRequestPathInfo(); diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1921.java b/uitest/src/com/vaadin/tests/tickets/Ticket1921.java index 165f4a8d0d..6f525a1bfc 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket1921.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket1921.java @@ -3,9 +3,9 @@ package com.vaadin.tests.tickets; import java.io.IOException; import java.util.Map; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.server.RequestHandler; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedResponse; import com.vaadin.ui.Button; @@ -43,7 +43,7 @@ public class Ticket1921 extends LegacyApplication implements newState(); - Application.getCurrent().addRequestHandler(this); + VaadinSession.getCurrent().addRequestHandler(this); } public void newState() { @@ -95,7 +95,7 @@ public class Ticket1921 extends LegacyApplication implements } @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { Map parameters = request.getParameterMap(); diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2292.java b/uitest/src/com/vaadin/tests/tickets/Ticket2292.java index 34f24276e5..0f663d78f5 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2292.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2292.java @@ -9,11 +9,11 @@ import java.io.IOException; import javax.imageio.ImageIO; -import com.vaadin.Application; import com.vaadin.LegacyApplication; import com.vaadin.server.DownloadStream; import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.server.WrappedResponse; import com.vaadin.ui.Button; @@ -45,11 +45,11 @@ public class Ticket2292 extends com.vaadin.LegacyApplication Link l = new Link("l", icon); main.addComponent(l); - Application.getCurrent().addRequestHandler(this); + VaadinSession.getCurrent().addRequestHandler(this); } @Override - public boolean handleRequest(Application application, + public boolean handleRequest(VaadinSession application, WrappedRequest request, WrappedResponse response) throws IOException { String relativeUri = request.getRequestPathInfo(); diff --git a/uitest/src/com/vaadin/tests/util/SampleDirectory.java b/uitest/src/com/vaadin/tests/util/SampleDirectory.java index 7304f1cab8..be98de67cc 100644 --- a/uitest/src/com/vaadin/tests/util/SampleDirectory.java +++ b/uitest/src/com/vaadin/tests/util/SampleDirectory.java @@ -18,8 +18,8 @@ package com.vaadin.tests.util; import java.io.File; -import com.vaadin.Application; import com.vaadin.server.SystemError; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedRequest; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; @@ -43,7 +43,7 @@ public class SampleDirectory { * @param application * @return file pointing to sample directory */ - public static File getDirectory(Application application, UI uI) { + public static File getDirectory(VaadinSession application, UI uI) { String errorMessage = "Access to application " + "context base directory failed, " + "possible security constraint with Application " -- 2.39.5