diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-20 14:55:11 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-20 14:55:11 +0300 |
commit | 23e77a833df4845c0c0011dde13e6fc5db901a1c (patch) | |
tree | d79921013013622292abfa4737d27cc2608443d1 | |
parent | e223589aae4ee77043ba156961a663b73ad3d8cb (diff) | |
download | vaadin-framework-23e77a833df4845c0c0011dde13e6fc5db901a1c.tar.gz vaadin-framework-23e77a833df4845c0c0011dde13e6fc5db901a1c.zip |
Remove a bunch of internal "application" references (#9402)
7 files changed, 122 insertions, 149 deletions
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index b7d0b98ab8..07959b1558 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -2406,7 +2406,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * * @since 7.0 */ - protected boolean handleApplicationRequest(WrappedRequest request, + protected boolean handleOtherRequest(WrappedRequest request, WrappedResponse response) throws IOException { // Use a copy to avoid ConcurrentModificationException for (RequestHandler handler : new ArrayList<RequestHandler>( diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java index 42d03274bb..44aca14fe3 100644 --- a/server/src/com/vaadin/server/GAEVaadinServlet.java +++ b/server/src/com/vaadin/server/GAEVaadinServlet.java @@ -190,7 +190,7 @@ public class GAEVaadinServlet extends VaadinServlet { return; } - if (requestType == RequestType.APPLICATION_RESOURCE) { + if (requestType == RequestType.APP) { // no locking needed, let superclass handle getApplicationContext(request, MemcacheServiceFactory.getMemcacheService()); diff --git a/server/src/com/vaadin/server/ServletPortletHelper.java b/server/src/com/vaadin/server/ServletPortletHelper.java index 3f2674392c..6b686c59c3 100644 --- a/server/src/com/vaadin/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/server/ServletPortletHelper.java @@ -108,7 +108,7 @@ class ServletPortletHelper implements Serializable { return hasPathPrefix(request, ApplicationConstants.UIDL_REQUEST_PATH); } - public static boolean isApplicationResourceRequest(WrappedRequest request) { + public static boolean isAppRequest(WrappedRequest request) { return hasPathPrefix(request, ApplicationConstants.APP_REQUEST_PATH); } diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index 074c2aa9cc..2027431f0b 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -183,8 +183,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { RequestType requestType = getRequestType(request); if (requestType == RequestType.RENDER) { // In most cases the first request is a render request that - // renders the HTML fragment. This should create an application - // instance. + // renders the HTML fragment. This should create a Vaadin + // session unless there is already one. return true; } else if (requestType == RequestType.EVENT) { // A portlet can also be sent an event even though it has not @@ -461,7 +461,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { */ @Deprecated protected enum RequestType { - FILE_UPLOAD, UIDL, RENDER, STATIC_FILE, APPLICATION_RESOURCE, DUMMY, EVENT, ACTION, UNKNOWN, BROWSER_DETAILS, CONNECTOR_RESOURCE, HEARTBEAT; + FILE_UPLOAD, UIDL, RENDER, STATIC_FILE, APP, DUMMY, EVENT, ACTION, UNKNOWN, BROWSER_DETAILS, CONNECTOR_RESOURCE, HEARTBEAT; } /** @@ -486,9 +486,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { } else if (ServletPortletHelper .isConnectorResourceRequest(wrappedRequest)) { return RequestType.CONNECTOR_RESOURCE; - } else if (ServletPortletHelper - .isApplicationResourceRequest(wrappedRequest)) { - return RequestType.APPLICATION_RESOURCE; + } else if (ServletPortletHelper.isAppRequest(wrappedRequest)) { + return RequestType.APP; } else if (ServletPortletHelper.isHeartbeatRequest(wrappedRequest)) { return RequestType.HEARTBEAT; } else if (isDummyRequest(resourceRequest)) { @@ -564,53 +563,46 @@ public class VaadinPortlet extends GenericPortlet implements Constants { serveStaticResources((ResourceRequest) request, (ResourceResponse) response); } else { - VaadinSession application = null; - boolean applicationRunning = false; + VaadinPortletSession vaadinSession = null; + boolean sessionProcessed = false; try { // TODO What about PARAM_UNLOADBURST & // redirectToApplication?? - /* Find out which application this request is related to */ - application = getVaadinService().findVaadinSession( - wrappedRequest); - if (application == null) { + vaadinSession = (VaadinPortletSession) getVaadinService() + .findVaadinSession(wrappedRequest); + if (vaadinSession == null) { return; } - VaadinSession.setCurrent(application); + VaadinSession.setCurrent(vaadinSession); request.setAttribute(VaadinSession.class.getName(), - application); + vaadinSession); - /* - * Get or create an application context and an application - * manager for the session - */ - VaadinPortletSession applicationContext = (VaadinPortletSession) application; - - PortletCommunicationManager applicationManager = (PortletCommunicationManager) applicationContext - .getApplicationManager(); + PortletCommunicationManager communicationManager = (PortletCommunicationManager) vaadinSession + .getCommunicationManager(); if (requestType == RequestType.CONNECTOR_RESOURCE) { - applicationManager.serveConnectorResource( + communicationManager.serveConnectorResource( wrappedRequest, wrappedResponse); return; } else if (requestType == RequestType.HEARTBEAT) { - applicationManager.handleHeartbeatRequest( - wrappedRequest, wrappedResponse, application); + communicationManager.handleHeartbeatRequest( + wrappedRequest, wrappedResponse, vaadinSession); return; } /* Update browser information from request */ - applicationContext.getBrowser().updateRequestDetails( + vaadinSession.getBrowser().updateRequestDetails( wrappedRequest); - applicationRunning = true; + sessionProcessed = true; /* Notify listeners */ - // Finds the window within the application + // Finds the right UI UI uI = null; - application.getLock().lock(); + vaadinSession.getLock().lock(); try { switch (requestType) { case RENDER: @@ -618,7 +610,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { // Both action requests and render requests are ok // without a UI as they render the initial HTML // and then do a second request - uI = application.getUIForRequest(wrappedRequest); + uI = vaadinSession.getUIForRequest(wrappedRequest); break; case BROWSER_DETAILS: // Should not try to find a UI here as the @@ -627,34 +619,33 @@ public class VaadinPortlet extends GenericPortlet implements Constants { case FILE_UPLOAD: // no window break; - case APPLICATION_RESOURCE: - // use main window - should not need any window - // UI = application.getUI(); + case APP: + // Not related to any UI break; default: - uI = application.getUIForRequest(wrappedRequest); + uI = vaadinSession.getUIForRequest(wrappedRequest); } // if window not found, not a problem - use null } finally { - application.getLock().unlock(); + vaadinSession.getLock().unlock(); } // TODO Should this happen before or after the transaction // starts? if (request instanceof RenderRequest) { - applicationContext.firePortletRenderRequest(uI, + vaadinSession.firePortletRenderRequest(uI, (RenderRequest) request, (RenderResponse) response); } else if (request instanceof ActionRequest) { - applicationContext.firePortletActionRequest(uI, + vaadinSession.firePortletActionRequest(uI, (ActionRequest) request, (ActionResponse) response); } else if (request instanceof EventRequest) { - applicationContext.firePortletEventRequest(uI, + vaadinSession.firePortletEventRequest(uI, (EventRequest) request, (EventResponse) response); } else if (request instanceof ResourceRequest) { - applicationContext.firePortletResourceRequest(uI, + vaadinSession.firePortletResourceRequest(uI, (ResourceRequest) request, (ResourceResponse) response); } @@ -663,22 +654,22 @@ public class VaadinPortlet extends GenericPortlet implements Constants { if (requestType == RequestType.FILE_UPLOAD) { // UI is resolved in handleFileUpload by // PortletCommunicationManager - applicationManager.handleFileUpload(application, + communicationManager.handleFileUpload(vaadinSession, wrappedRequest, wrappedResponse); return; } else if (requestType == RequestType.BROWSER_DETAILS) { - applicationManager.handleBrowserDetailsRequest( - wrappedRequest, wrappedResponse, application); + communicationManager.handleBrowserDetailsRequest( + wrappedRequest, wrappedResponse, vaadinSession); return; } else if (requestType == RequestType.UIDL) { // Handles AJAX UIDL requests - applicationManager.handleUidlRequest(wrappedRequest, + communicationManager.handleUidlRequest(wrappedRequest, wrappedResponse, portletWrapper, uI); return; } else { handleOtherRequest(wrappedRequest, wrappedResponse, - requestType, application, applicationContext, - applicationManager); + requestType, vaadinSession, + communicationManager); } } catch (final SessionExpiredException e) { // TODO Figure out a better way to deal with @@ -691,19 +682,15 @@ public class VaadinPortlet extends GenericPortlet implements Constants { .fine("General security exception, the security key was probably incorrect."); } catch (final Throwable e) { handleServiceException(wrappedRequest, wrappedResponse, - application, e); + vaadinSession, e); } finally { - if (applicationRunning) { - application.cleanupInactiveUIs(); + if (sessionProcessed) { + vaadinSession.cleanupInactiveUIs(); } - if (applicationRunning) { - application.cleanupInactiveUIs(); - } - - if (application != null) { - requestTimer.stop(application); + if (vaadinSession != null) { + requestTimer.stop(vaadinSession); } } } @@ -752,21 +739,20 @@ public class VaadinPortlet extends GenericPortlet implements Constants { * @param request * @param response * @param requestType - * @param application - * @param applicationContext - * @param applicationManager + * @param vaadinSession + * @param vaadinSession + * @param communicationManager * @throws PortletException * @throws IOException * @throws MalformedURLException */ private void handleOtherRequest(WrappedPortletRequest request, WrappedResponse response, RequestType requestType, - VaadinSession application, VaadinPortletSession applicationContext, - PortletCommunicationManager applicationManager) + VaadinSession vaadinSession, + PortletCommunicationManager communicationManager) throws PortletException, IOException, MalformedURLException { - if (requestType == RequestType.APPLICATION_RESOURCE - || requestType == RequestType.RENDER) { - if (!applicationManager.handleApplicationRequest(request, response)) { + if (requestType == RequestType.APP || requestType == RequestType.RENDER) { + if (!communicationManager.handleOtherRequest(request, response)) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found"); } @@ -846,15 +832,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { handleRequest(request, response); } - private void endApplication(PortletRequest request, - PortletResponse response, VaadinSession application) - throws IOException { - application.removeFromSession(); - // Do not send any redirects when running inside a portlet. - } - private void handleServiceException(WrappedPortletRequest request, - WrappedPortletResponse response, VaadinSession application, + WrappedPortletResponse response, VaadinSession vaadinSession, Throwable e) throws IOException, PortletException { // TODO Check that this error handler is working when running inside a // portlet @@ -865,9 +844,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants { criticalNotification(request, response, ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), null, ci.getInternalErrorURL()); - if (application != null) { - application.getErrorHandler() - .terminalError(new RequestError(e)); + if (vaadinSession != null) { + vaadinSession.getErrorHandler().terminalError( + new RequestError(e)); } else { throw new PortletException(e); } diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index eb5d838b72..4b176d5f67 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -89,7 +89,7 @@ public abstract class VaadinService implements Serializable { * returned folder is what is used for widgetsets and themes. * * The returned folder is usually the same as the context path and - * independent of the application. + * independent of e.g. the servlet mapping. * * @param request * the request for which the location should be determined @@ -120,15 +120,14 @@ public abstract class VaadinService implements Serializable { public abstract String getConfiguredTheme(WrappedRequest request); /** - * Checks whether the Vaadin application will be rendered on its own in the - * browser or whether it will be included into some other context. A - * standalone application may do things that might interfere with other - * parts of a page, e.g. changing the page title and requesting focus upon - * loading. + * Checks whether the UI will be rendered on its own in the browser or + * whether it will be included into some other context. A standalone UI may + * do things that might interfere with other parts of a page, e.g. changing + * the page title and requesting focus upon loading. * * @param request - * the request for which the application is loaded - * @return a boolean indicating whether the application should be standalone + * the request for which the UI is loaded + * @return a boolean indicating whether the UI should be standalone */ public abstract boolean isStandalone(WrappedRequest request); @@ -210,7 +209,7 @@ public abstract class VaadinService implements Serializable { public abstract SystemMessages getSystemMessages(); /** - * Returns application context base directory. + * Returns the context base directory. * * Typically an application is deployed in a such way that is has an * application directory. For web applications this directory is the root @@ -311,16 +310,16 @@ public abstract class VaadinService implements Serializable { public VaadinSession findVaadinSession(WrappedRequest request) throws ServiceException, SessionExpiredException { - boolean requestCanCreateApplication = requestCanCreateSession(request); + boolean requestCanCreateSession = requestCanCreateSession(request); - /* Find an existing application for this request. */ + /* Find an existing session for this request. */ VaadinSession session = getExistingSession(request, - requestCanCreateApplication); + requestCanCreateSession); if (session != null) { /* - * There is an existing application. We can use this as long as the - * user not specifically requested to close or restart it. + * There is an existing session. We can use this as long as the user + * not specifically requested to close or restart it. */ final boolean restartApplication = (request @@ -329,35 +328,35 @@ public abstract class VaadinService implements Serializable { .getParameter(URL_PARAMETER_CLOSE_APPLICATION) != null); if (restartApplication) { - closeApplication(session, request.getWrappedSession(false)); - return createAndRegisterApplication(request); + closeSession(session, request.getWrappedSession(false)); + return createAndRegisterSession(request); } else if (closeApplication) { - closeApplication(session, request.getWrappedSession(false)); + closeSession(session, request.getWrappedSession(false)); return null; } else { return session; } } - // No existing application was found + // No existing session was found - if (requestCanCreateApplication) { + if (requestCanCreateSession) { /* - * If the request is such that it should create a new application if - * one as not found, we do that. + * If the request is such that it should create a new session if one + * as not found, we do that. */ - return createAndRegisterApplication(request); + return createAndRegisterSession(request); } else { /* - * The application was not found and a new one should not be - * created. Assume the session has expired. + * The session was not found and a new one should not be created. + * Assume the session has expired. */ throw new SessionExpiredException(); } } - private VaadinSession createAndRegisterApplication(WrappedRequest request) + private VaadinSession createAndRegisterSession(WrappedRequest request) throws ServiceException { VaadinSession session = createVaadinSession(request); @@ -434,14 +433,14 @@ public abstract class VaadinService implements Serializable { ServletPortletHelper.checkUiProviders(session); } - private void closeApplication(VaadinSession application, + private void closeSession(VaadinSession vaadinSession, WrappedSession session) { - if (application == null) { + if (vaadinSession == null) { return; } if (session != null) { - application.removeFromSession(); + vaadinSession.removeFromSession(); } } @@ -455,13 +454,13 @@ public abstract class VaadinService implements Serializable { throw new SessionExpiredException(); } - VaadinSession sessionApplication = VaadinSession.getForSession(session); + VaadinSession vaadinSession = VaadinSession.getForSession(session); - if (sessionApplication == null) { + if (vaadinSession == null) { return null; } - return sessionApplication; + return vaadinSession; } /** diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 3c129c49a8..54709b41d1 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -154,8 +154,7 @@ public class VaadinServlet extends HttpServlet implements Constants { return true; } else if (requestType == RequestType.OTHER) { /* - * I.e URIs that are not application resources or static (theme) - * files. + * I.e URIs that are not RPC calls or static (theme) files. */ return true; } @@ -406,8 +405,8 @@ public class VaadinServlet extends HttpServlet implements Constants { return; } - VaadinSession application = null; - boolean applicationRunning = false; + VaadinServletSession vaadinSession = null; + boolean sessionProcessed = false; try { // If a duplicate "close application" URL is received for an @@ -428,59 +427,55 @@ public class VaadinServlet extends HttpServlet implements Constants { return; } - // Find out which application this request is related to - application = getVaadinService().findVaadinSession(request); - if (application == null) { + // Find out the Vaadin session this request is related to + vaadinSession = (VaadinServletSession) getVaadinService() + .findVaadinSession(request); + if (vaadinSession == null) { return; } - request.setAttribute(VaadinSession.class.getName(), application); - VaadinSession.setCurrent(application); + request.setAttribute(VaadinSession.class.getName(), vaadinSession); + VaadinSession.setCurrent(vaadinSession); - /* - * Get or create a WebApplicationContext and an ApplicationManager - * for the session - */ - VaadinServletSession webApplicationContext = (VaadinServletSession) application; - CommunicationManager applicationManager = (CommunicationManager) webApplicationContext - .getApplicationManager(); + CommunicationManager communicationManager = (CommunicationManager) vaadinSession + .getCommunicationManager(); if (requestType == RequestType.CONNECTOR_RESOURCE) { - applicationManager.serveConnectorResource(request, response); + communicationManager.serveConnectorResource(request, response); return; } else if (requestType == RequestType.HEARTBEAT) { - applicationManager.handleHeartbeatRequest(request, response, - application); + communicationManager.handleHeartbeatRequest(request, response, + vaadinSession); return; } /* Update browser information from the request */ - webApplicationContext.getBrowser().updateRequestDetails(request); + vaadinSession.getBrowser().updateRequestDetails(request); - applicationRunning = true; + sessionProcessed = true; /* Handle the request */ if (requestType == RequestType.FILE_UPLOAD) { // UI is resolved in communication manager - applicationManager.handleFileUpload(application, request, + communicationManager.handleFileUpload(vaadinSession, request, response); return; } else if (requestType == RequestType.UIDL) { - UI uI = application.getUIForRequest(request); + UI uI = vaadinSession.getUIForRequest(request); if (uI == null) { throw new ServletException(ERROR_NO_UI_FOUND); } // Handles AJAX UIDL requests - applicationManager.handleUidlRequest(request, response, + communicationManager.handleUidlRequest(request, response, servletWrapper, uI); return; } else if (requestType == RequestType.BROWSER_DETAILS) { // Browser details - not related to a specific UI - applicationManager.handleBrowserDetailsRequest(request, - response, application); + communicationManager.handleBrowserDetailsRequest(request, + response, vaadinSession); return; } - if (applicationManager.handleApplicationRequest(request, response)) { + if (communicationManager.handleOtherRequest(request, response)) { return; } // TODO Should return 404 error here and not do anything more @@ -491,17 +486,17 @@ public class VaadinServlet extends HttpServlet implements Constants { } catch (final GeneralSecurityException e) { handleServiceSecurityException(request, response); } catch (final Throwable e) { - handleServiceException(request, response, application, e); + handleServiceException(request, response, vaadinSession, e); } finally { - if (applicationRunning) { - application.cleanupInactiveUIs(); + if (sessionProcessed) { + vaadinSession.cleanupInactiveUIs(); } CurrentInstance.clearAll(); - if (application != null) { - requestTimer.stop(application); + if (vaadinSession != null) { + requestTimer.stop(vaadinSession); } } } @@ -571,9 +566,9 @@ public class VaadinServlet extends HttpServlet implements Constants { } /** - * Send a notification to client's application. Used to notify client of + * Send a notification to client-side widgetset. Used to notify client of * critical errors, session expiration and more. Server has no knowledge of - * what application client refers to. + * what UI client refers to. * * @param request * the HTTP request instance. @@ -711,7 +706,7 @@ public class VaadinServlet extends HttpServlet implements Constants { } private void handleServiceException(WrappedHttpServletRequest request, - WrappedHttpServletResponse response, VaadinSession application, + WrappedHttpServletResponse response, VaadinSession vaadinSession, Throwable e) throws IOException, ServletException { // if this was an UIDL request, response UIDL back to client if (getRequestType(request) == RequestType.UIDL) { @@ -719,9 +714,9 @@ public class VaadinServlet extends HttpServlet implements Constants { criticalNotification(request, response, ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), null, ci.getInternalErrorURL()); - if (application != null) { - application.getErrorHandler() - .terminalError(new RequestError(e)); + if (vaadinSession != null) { + vaadinSession.getErrorHandler().terminalError( + new RequestError(e)); } else { throw new ServletException(e); } @@ -1207,7 +1202,7 @@ public class VaadinServlet extends HttpServlet implements Constants { */ @Deprecated protected enum RequestType { - FILE_UPLOAD, BROWSER_DETAILS, UIDL, OTHER, STATIC_FILE, APPLICATION_RESOURCE, CONNECTOR_RESOURCE, HEARTBEAT; + FILE_UPLOAD, BROWSER_DETAILS, UIDL, OTHER, STATIC_FILE, APP, CONNECTOR_RESOURCE, HEARTBEAT; } /** @@ -1228,8 +1223,8 @@ public class VaadinServlet extends HttpServlet implements Constants { return RequestType.UIDL; } else if (isStaticResourceRequest(request)) { return RequestType.STATIC_FILE; - } else if (ServletPortletHelper.isApplicationResourceRequest(request)) { - return RequestType.APPLICATION_RESOURCE; + } else if (ServletPortletHelper.isAppRequest(request)) { + return RequestType.APP; } else if (ServletPortletHelper.isHeartbeatRequest(request)) { return RequestType.HEARTBEAT; } diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index 5acc1e0ca3..8fbc7af335 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -281,7 +281,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { * @deprecated might be refactored or removed before 7.0.0 */ @Deprecated - public AbstractCommunicationManager getApplicationManager() { + public AbstractCommunicationManager getCommunicationManager() { return communicationManager; } |