aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-06 13:34:36 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-06 17:07:47 +0300
commitb9ff0e2cee370f0b489f36a13ec2a98f3cdccf96 (patch)
tree883b4e503ee04b18aeae8d067be4a3ec6ccd2a90
parentc1e1b2022990e8d00d3510fb14953b1a4a510af7 (diff)
downloadvaadin-framework-b9ff0e2cee370f0b489f36a13ec2a98f3cdccf96.tar.gz
vaadin-framework-b9ff0e2cee370f0b489f36a13ec2a98f3cdccf96.zip
Remove 'Application' from RequestHandler API (#9402)
-rw-r--r--server/src/com/vaadin/server/AbstractCommunicationManager.java38
-rw-r--r--server/src/com/vaadin/server/BootstrapHandler.java8
-rw-r--r--server/src/com/vaadin/server/ConnectorResourceHandler.java4
-rw-r--r--server/src/com/vaadin/server/GlobalResourceHandler.java4
-rw-r--r--server/src/com/vaadin/server/PortletCommunicationManager.java4
-rw-r--r--server/src/com/vaadin/server/RequestHandler.java9
-rw-r--r--server/src/com/vaadin/server/UnsupportedBrowserHandler.java2
-rw-r--r--server/src/com/vaadin/server/VaadinSession.java45
-rw-r--r--server/src/com/vaadin/ui/LoginForm.java2
-rw-r--r--uitest/src/com/vaadin/tests/Parameters.java2
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java2
-rw-r--r--uitest/src/com/vaadin/tests/tickets/Ticket1589.java2
-rw-r--r--uitest/src/com/vaadin/tests/tickets/Ticket1921.java2
-rw-r--r--uitest/src/com/vaadin/tests/tickets/Ticket2292.java2
14 files changed, 59 insertions, 67 deletions
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java
index 008b3e74ab..5b4a334660 100644
--- a/server/src/com/vaadin/server/AbstractCommunicationManager.java
+++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java
@@ -2386,9 +2386,45 @@ public abstract class AbstractCommunicationManager implements Serializable {
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,
diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java
index 29792d710a..491830fb81 100644
--- a/server/src/com/vaadin/server/BootstrapHandler.java
+++ b/server/src/com/vaadin/server/BootstrapHandler.java
@@ -103,20 +103,20 @@ public abstract class BootstrapHandler implements RequestHandler {
}
@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);
diff --git a/server/src/com/vaadin/server/ConnectorResourceHandler.java b/server/src/com/vaadin/server/ConnectorResourceHandler.java
index 6702fb140f..50e5377e8d 100644
--- a/server/src/com/vaadin/server/ConnectorResourceHandler.java
+++ b/server/src/com/vaadin/server/ConnectorResourceHandler.java
@@ -24,7 +24,7 @@ public class ConnectorResourceHandler implements RequestHandler {
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String requestPath = request.getRequestPathInfo();
@@ -36,7 +36,7 @@ public class ConnectorResourceHandler implements RequestHandler {
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 "
diff --git a/server/src/com/vaadin/server/GlobalResourceHandler.java b/server/src/com/vaadin/server/GlobalResourceHandler.java
index 03dab9817d..33a965369d 100644
--- a/server/src/com/vaadin/server/GlobalResourceHandler.java
+++ b/server/src/com/vaadin/server/GlobalResourceHandler.java
@@ -65,7 +65,7 @@ public class GlobalResourceHandler implements RequestHandler {
"");
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String pathInfo = request.getRequestPathInfo();
@@ -90,7 +90,7 @@ public class GlobalResourceHandler implements RequestHandler {
+ " 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);
}
diff --git a/server/src/com/vaadin/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java
index f238fa4925..e8904c71bd 100644
--- a/server/src/com/vaadin/server/PortletCommunicationManager.java
+++ b/server/src/com/vaadin/server/PortletCommunicationManager.java
@@ -48,13 +48,13 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
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;
}
diff --git a/server/src/com/vaadin/server/RequestHandler.java b/server/src/com/vaadin/server/RequestHandler.java
index 66e20dafbe..c2409af2d7 100644
--- a/server/src/com/vaadin/server/RequestHandler.java
+++ b/server/src/com/vaadin/server/RequestHandler.java
@@ -21,7 +21,8 @@ import java.io.Serializable;
/**
* 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 {
@@ -30,8 +31,8 @@ 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
@@ -40,7 +41,7 @@ public interface RequestHandler extends Serializable {
* handlers should be called, otherwise false
* @throws IOException
*/
- boolean handleRequest(VaadinSession application, WrappedRequest request,
+ boolean handleRequest(VaadinSession session, WrappedRequest request,
WrappedResponse response) throws IOException;
}
diff --git a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
index f84c2ec5dc..38ac14b2d2 100644
--- a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
+++ b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
@@ -34,7 +34,7 @@ public class UnsupportedBrowserHandler implements RequestHandler {
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 {
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index 05b6aed96a..094f3501d7 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -16,11 +16,9 @@
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;
@@ -755,47 +753,6 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
}
/**
- * Handles a request by passing it to each registered {@link RequestHandler}
- * in turn until one produces a response. This method is used for requests
- * that have not been handled by any specific functionality in the terminal
- * implementation (e.g. {@link 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
* functionality of the framework.
@@ -807,7 +764,6 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
* @param handler
* the request handler to add
*
- * @see #handleRequest(WrappedRequest, WrappedResponse)
* @see #removeRequestHandler(RequestHandler)
*
* @since 7.0
@@ -836,7 +792,6 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
* @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)
*
diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java
index f597908b8c..2e372e8512 100644
--- a/server/src/com/vaadin/ui/LoginForm.java
+++ b/server/src/com/vaadin/ui/LoginForm.java
@@ -83,7 +83,7 @@ public class LoginForm extends CustomComponent {
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();
diff --git a/uitest/src/com/vaadin/tests/Parameters.java b/uitest/src/com/vaadin/tests/Parameters.java
index f57c0aece6..056427d685 100644
--- a/uitest/src/com/vaadin/tests/Parameters.java
+++ b/uitest/src/com/vaadin/tests/Parameters.java
@@ -106,7 +106,7 @@ public class Parameters extends com.vaadin.Application implements
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
context.setValue("Context not available");
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java
index 632eda2491..e17d7c2a34 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java
@@ -56,7 +56,7 @@ class DynamicImageRequestHandler implements RequestHandler {
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();
diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1589.java b/uitest/src/com/vaadin/tests/tickets/Ticket1589.java
index 82cfa2b3ec..327b5b57d0 100644
--- a/uitest/src/com/vaadin/tests/tickets/Ticket1589.java
+++ b/uitest/src/com/vaadin/tests/tickets/Ticket1589.java
@@ -52,7 +52,7 @@ class MyDynamicResource implements RequestHandler {
* 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();
diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1921.java b/uitest/src/com/vaadin/tests/tickets/Ticket1921.java
index 3f2529db5f..b33484da23 100644
--- a/uitest/src/com/vaadin/tests/tickets/Ticket1921.java
+++ b/uitest/src/com/vaadin/tests/tickets/Ticket1921.java
@@ -94,7 +94,7 @@ public class Ticket1921 extends Application implements RequestHandler {
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
Map<String, String[]> parameters = request.getParameterMap();
diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2292.java b/uitest/src/com/vaadin/tests/tickets/Ticket2292.java
index 839c175866..6a831d1cfd 100644
--- a/uitest/src/com/vaadin/tests/tickets/Ticket2292.java
+++ b/uitest/src/com/vaadin/tests/tickets/Ticket2292.java
@@ -48,7 +48,7 @@ public class Ticket2292 extends com.vaadin.Application implements
}
@Override
- public boolean handleRequest(VaadinSession application,
+ public boolean handleRequest(VaadinSession session,
WrappedRequest request, WrappedResponse response)
throws IOException {
String relativeUri = request.getRequestPathInfo();