01: package org.mortbay.gwt;
02:
03: import java.io.IOException;
04: import java.lang.reflect.Method;
05:
06: import javax.servlet.ServletContext;
07: import javax.servlet.ServletException;
08: import javax.servlet.http.HttpServletRequest;
09: import javax.servlet.http.HttpServletResponse;
10:
11: import com.google.gwt.user.server.rpc.OpenRemoteServiceServlet;
12:
13: public class AsyncRemoteServiceServlet extends OpenRemoteServiceServlet {
14: public static final String PAYLOAD = "com.google.gwt.payload";
15:
16: /* ------------------------------------------------------------ */
17: /* (non-Javadoc)
18: * @see com.google.gwt.user.server.rpc.OpenRemoteServiceServlet#readPayloadAsUtf8(javax.servlet.http.HttpServletRequest)
19: */
20: protected String readPayloadAsUtf8(HttpServletRequest request)
21: throws IOException, ServletException {
22: String payload = (String) request.getAttribute(PAYLOAD);
23: if (payload == null) {
24: payload = super .readPayloadAsUtf8(request);
25: request.setAttribute(PAYLOAD, payload);
26: }
27: return payload;
28: }
29:
30: /* ------------------------------------------------------------ */
31: /* (non-Javadoc)
32: * @see com.google.gwt.user.server.rpc.OpenRemoteServiceServlet#respondWithFailure(javax.servlet.http.HttpServletResponse, java.lang.Throwable)
33: */
34: protected void respondWithFailure(HttpServletResponse response,
35: Throwable caught) {
36: throwIfRetyRequest(caught);
37: super .respondWithFailure(response, caught);
38: }
39:
40: protected void handleException(String responsePayload,
41: Throwable caught) {
42: throwIfRetyRequest(caught);
43: super .handleException(responsePayload, caught);
44: }
45:
46: protected void throwIfRetyRequest(Throwable caught) {
47: if (caught instanceof RuntimeException
48: && "org.mortbay.jetty.RetryRequest".equals(caught
49: .getClass().getName())) {
50: throw (RuntimeException) caught;
51: }
52: }
53:
54: }
|