protected abstract BootstrapHandler createBootstrapHandler();
+ /**
+ * Handles a request by passing it to each registered {@link RequestHandler}
+ * in turn until one produces a response. This method is used for requests
+ * that have not been handled by any specific functionality in the terminal
+ * implementation (e.g. {@link VaadinServlet}).
+ * <p>
+ * The request handlers are invoked in the revere order in which they were
+ * added to the session until a response has been produced. This means that
+ * the most recently added handler is used first and the first request
+ * handler that was added to the application is invoked towards the end
+ * unless any previous handler has already produced a response.
+ * </p>
+ *
+ * @param request
+ * the wrapped request to get information from
+ * @param response
+ * the response to which data can be written
+ * @return returns <code>true</code> if a {@link RequestHandler} has
+ * produced a response and <code>false</code> if no response has
+ * been written.
+ * @throws IOException
+ * if a handler throws an exception
+ *
+ * @see VaadinSession#addRequestHandler(RequestHandler)
+ * @see RequestHandler
+ *
+ * @since 7.0
+ */
protected boolean handleApplicationRequest(WrappedRequest request,
WrappedResponse response) throws IOException {
- return application.handleRequest(request, response);
+ // Use a copy to avoid ConcurrentModificationException
+ for (RequestHandler handler : new ArrayList<RequestHandler>(
+ application.getRequestHandlers())) {
+ if (handler.handleRequest(application, request, response)) {
+ return true;
+ }
+ }
+ // If not handled
+ return false;
}
public void handleBrowserDetailsRequest(WrappedRequest request,
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
try {
- Class<? extends UI> uiClass = application.getUIClass(request);
+ Class<? extends UI> uiClass = session.getUIClass(request);
BootstrapContext context = createContext(request, response,
- application, uiClass);
+ session, uiClass);
setupMainDiv(context);
BootstrapFragmentResponse fragmentResponse = context
.getBootstrapResponse();
- application.modifyBootstrapResponse(fragmentResponse);
+ session.modifyBootstrapResponse(fragmentResponse);
String html = getBootstrapHtml(context);
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String requestPath = request.getRequestPathInfo();
String uiId = matcher.group(1);
String cid = matcher.group(2);
String key = matcher.group(3);
- UI ui = application.getUIById(Integer.parseInt(uiId));
+ UI ui = session.getUIById(Integer.parseInt(uiId));
if (ui == null) {
return error(request, response,
"Ignoring connector request for no-existent root "
"");
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String pathInfo = request.getRequestPathInfo();
+ " is not a valid global resource path");
}
- UI ui = application.getUIById(Integer.parseInt(uiid));
+ UI ui = session.getUIById(Integer.parseInt(uiid));
if (ui == null) {
return error(request, response, "No UI found for id " + uiid);
}
protected BootstrapHandler createBootstrapHandler() {
return new BootstrapHandler() {
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
PortletRequest portletRequest = WrappedPortletRequest.cast(
request).getPortletRequest();
if (portletRequest instanceof RenderRequest) {
- return super.handleRequest(application, request, response);
+ return super.handleRequest(session, request, response);
} else {
return false;
}
/**
* Handler for producing a response to non-UIDL requests. Handlers can be added
- * to applications using {@link VaadinSession#addRequestHandler(RequestHandler)}
+ * to vaadin sessions using
+ * {@link VaadinSession#addRequestHandler(RequestHandler)}
*/
public interface RequestHandler extends Serializable {
* return <code>false</code> to indicate that no more request handlers
* should be invoked for the request.
*
- * @param application
- * The application to which the request belongs
+ * @param session
+ * The session for the request
* @param request
* The request to handle
* @param response
* handlers should be called, otherwise false
* @throws IOException
*/
- boolean handleRequest(VaadinSession application, WrappedRequest request,
+ boolean handleRequest(VaadinSession session, WrappedRequest request,
WrappedResponse response) throws IOException;
}
public static final String FORCE_LOAD_COOKIE = "vaadinforceload=1";
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
package com.vaadin.server;
-import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EventObject;
throw new RuntimeException("No UI provider found for request");
}
- /**
- * Handles a request by passing it to each registered {@link RequestHandler}
- * in turn until one produces a response. This method is used for requests
- * that have not been handled by any specific functionality in the terminal
- * implementation (e.g. {@link VaadinServlet}).
- * <p>
- * The request handlers are invoked in the revere order in which they were
- * added to the application until a response has been produced. This means
- * that the most recently added handler is used first and the first request
- * handler that was added to the application is invoked towards the end
- * unless any previous handler has already produced a response.
- * </p>
- *
- * @param request
- * the wrapped request to get information from
- * @param response
- * the response to which data can be written
- * @return returns <code>true</code> if a {@link RequestHandler} has
- * produced a response and <code>false</code> if no response has
- * been written.
- * @throws IOException
- *
- * @see #addRequestHandler(RequestHandler)
- * @see RequestHandler
- *
- * @since 7.0
- */
- @Deprecated
- public boolean handleRequest(WrappedRequest request,
- WrappedResponse response) throws IOException {
- // Use a copy to avoid ConcurrentModificationException
- for (RequestHandler handler : new ArrayList<RequestHandler>(
- requestHandlers)) {
- if (handler.handleRequest(this, request, response)) {
- return true;
- }
- }
- // If not handled
- return false;
- }
-
/**
* Adds a request handler to this session. Request handlers can be added to
* provide responses to requests that are not handled by the default
* @param handler
* the request handler to add
*
- * @see #handleRequest(WrappedRequest, WrappedResponse)
* @see #removeRequestHandler(RequestHandler)
*
* @since 7.0
* @return a collection of request handlers, with the iteration order
* according to the order they would be invoked
*
- * @see #handleRequest(WrappedRequest, WrappedResponse)
* @see #addRequestHandler(RequestHandler)
* @see #removeRequestHandler(RequestHandler)
*
private final RequestHandler requestHandler = new RequestHandler() {
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String requestPathInfo = request.getRequestPathInfo();
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
context.setValue("Context not available");
public static final String IMAGE_URL = "myimage.png";
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String pathInfo = request.getRequestPathInfo();
* stream that contains the response from the server.
*/
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String relativeUri = request.getRequestPathInfo();
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
Map<String, String[]> parameters = request.getParameterMap();
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String relativeUri = request.getRequestPathInfo();