import com.vaadin.terminal.Terminal;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.URIHandler;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.terminal.WrappedResponse;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback;
import com.vaadin.ui.Root;
/**
public abstract class AbstractApplicationServlet extends HttpServlet implements
Constants {
+ private static class AbstractApplicationServletWrapper implements Callback {
+
+ private final AbstractApplicationServlet servlet;
+
+ public AbstractApplicationServletWrapper(
+ AbstractApplicationServlet servlet) {
+ this.servlet = servlet;
+ }
+
+ public void criticalNotification(WrappedRequest request,
+ WrappedResponse response, String cap, String msg,
+ String details, String outOfSyncURL) throws IOException {
+ servlet.criticalNotification(((WrappedHttpServletRequest) request)
+ .getHttpServletRequest(),
+ ((WrappedHttpServletResponse) response)
+ .getHttpServletResponse(), cap, msg, details,
+ outOfSyncURL);
+ }
+
+ public String getRequestPathInfo(WrappedRequest request) {
+ return servlet
+ .getRequestPathInfo(((WrappedHttpServletRequest) request)
+ .getHttpServletRequest());
+ }
+
+ public InputStream getThemeResourceAsStream(String themeName,
+ String resource) throws IOException {
+ return servlet.getServletContext().getResourceAsStream(
+ "/" + AbstractApplicationServlet.THEME_DIRECTORY_PATH
+ + themeName + "/" + resource);
+ }
+
+ }
+
// TODO Move some (all?) of the constants to a separate interface (shared
// with portlet)
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
+ AbstractApplicationServletWrapper servletWrapper = new AbstractApplicationServletWrapper(
+ this);
RequestType requestType = getRequestType(request);
if (!ensureCookiesEnabled(requestType, request, response)) {
} else if (requestType == RequestType.UIDL) {
// Handles AJAX UIDL requests
Root root = applicationManager.getApplicationRoot(request,
- this, application, null);
+ this, servletWrapper, application, null);
applicationManager.handleUidlRequest(request, response, this,
- root);
+ servletWrapper, root);
return;
}
// Finds the root within the application
Root root = getApplicationRoot(request, applicationManager,
- application);
+ servletWrapper, application);
if (root == null) {
throw new ServletException(ERROR_NO_WINDOW_FOUND);
}
* the HTTP Request.
* @param application
* the Application to query for root.
+ * @param servletWrapper
* @return Root matching the given URI or null if not found.
* @throws ServletException
* if an exception has occurred that interferes with the
* servlet's normal operation.
*/
protected Root getApplicationRoot(HttpServletRequest request,
- CommunicationManager applicationManager, Application application)
- throws ServletException {
+ CommunicationManager applicationManager, Callback servletWrapper,
+ Application application) throws ServletException {
//
// // Finds the window where the request is handled
Root assumedRoot = null;
// }
//
return applicationManager.getApplicationRoot(request, this,
- application, assumedRoot);
+ servletWrapper, application, assumedRoot);
}
/**
package com.vaadin.terminal.gwt.server;
import java.io.IOException;
-import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.vaadin.terminal.Paintable;
import com.vaadin.terminal.StreamVariable;
import com.vaadin.terminal.VariableOwner;
-import com.vaadin.terminal.WrappedRequest;
-import com.vaadin.terminal.WrappedResponse;
import com.vaadin.ui.Component;
import com.vaadin.ui.Root;
@SuppressWarnings("serial")
public class CommunicationManager extends AbstractCommunicationManager {
- private static class AbstractApplicationServletWrapper implements Callback {
-
- private final AbstractApplicationServlet servlet;
-
- public AbstractApplicationServletWrapper(
- AbstractApplicationServlet servlet) {
- this.servlet = servlet;
- }
-
- public void criticalNotification(WrappedRequest request,
- WrappedResponse response, String cap, String msg,
- String details, String outOfSyncURL) throws IOException {
- servlet.criticalNotification(((WrappedHttpServletRequest) request)
- .getHttpServletRequest(),
- ((WrappedHttpServletResponse) response)
- .getHttpServletResponse(), cap, msg, details,
- outOfSyncURL);
- }
-
- public String getRequestPathInfo(WrappedRequest request) {
- return servlet
- .getRequestPathInfo(((WrappedHttpServletRequest) request)
- .getHttpServletRequest());
- }
-
- public InputStream getThemeResourceAsStream(String themeName,
- String resource) throws IOException {
- return servlet.getServletContext().getResourceAsStream(
- "/" + AbstractApplicationServlet.THEME_DIRECTORY_PATH
- + themeName + "/" + resource);
- }
-
- }
-
/**
* @deprecated use {@link #CommunicationManager(Application)} instead
* @param application
* @param request
* @param response
* @param applicationServlet
+ * @param callback
* @param window
* target window of the UIDL request, can be null if window not
* found
*/
public void handleUidlRequest(HttpServletRequest request,
HttpServletResponse response,
- AbstractApplicationServlet applicationServlet, Root root)
- throws IOException, ServletException,
+ AbstractApplicationServlet applicationServlet, Callback callback,
+ Root root) throws IOException, ServletException,
InvalidUIDLSecurityKeyException {
doHandleUidlRequest(new WrappedHttpServletRequest(request,
applicationServlet), new WrappedHttpServletResponse(response),
- new AbstractApplicationServletWrapper(applicationServlet), root);
+ callback, root);
}
/**
* @param assumedRoot
* if the window has been already resolved once, this parameter
* must contain the window.
+ * @param callback
* @return Window matching the given URI or null if not found.
* @throws ServletException
* if an exception has occurred that interferes with the
* servlet's normal operation.
*/
Root getApplicationRoot(HttpServletRequest request,
- AbstractApplicationServlet applicationServlet,
+ AbstractApplicationServlet applicationServlet, Callback callback,
Application application, Root assumedRoot) throws ServletException {
return doGetApplicationWindow(new WrappedHttpServletRequest(request,
- applicationServlet), new AbstractApplicationServletWrapper(
- applicationServlet), application, assumedRoot);
+ applicationServlet), callback, application, assumedRoot);
}
@Override