01: // RequestFilter.java
02: // $Id: RequestFilter.java,v 1.7 1998/01/22 14:36:09 bmahe Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.www.protocol.http;
07:
08: /**
09: * The request filter interface.
10: * Filters allow application wide request enhancement before they are being
11: * actually emited on the wire.
12: * <p>Once registered to the HttpManager, a request filter will be invoked
13: * <em>before</em> the request is actualy sent to the wire, and right
14: * <em>after</em> the reply headers are available, <em>only</em> if its
15: * current scope matches the request URL.
16: */
17:
18: public interface RequestFilter {
19:
20: /**
21: * The request pre-processing hook.
22: * Before each request is launched, all filters will be called back through
23: * this method. They will generally set up additional request header
24: * fields to enhance the request.
25: * @param request The request that is about to be launched.
26: * @return An instance of Reply if the filter could handle the request,
27: * or <strong>null</strong> if processing should continue normally.
28: * @exception HttpException If the filter is supposed to fulfill the
29: * request, but some error happened during that processing.
30: */
31:
32: public Reply ingoingFilter(Request request) throws HttpException;
33:
34: /**
35: * The request post-processing hook.
36: * After each request has been replied to by the target server (be it a
37: * proxy or the actual origin server), each filter's outgoingFilter
38: * method is called.
39: * <p>It gets the original request, and the actual reply as a parameter,
40: * and should return whatever reply it wants the caller to get.
41: * @param request The original (handled) request.
42: * @param reply The reply, as emited by the target server, or constructed
43: * by some other filter.
44: * @exception HttpException If the reply emitted by the server is not
45: * a valid HTTP reply.
46: */
47:
48: public Reply outgoingFilter(Request request, Reply reply)
49: throws HttpException;
50:
51: /**
52: * An exception occured while talking to target server.
53: * This method is triggered by the HttpManager, when the target server
54: * (which can be a proxy for that request) was not reachable, or some
55: * network error occured while emitting the request or reading the reply
56: * headers.
57: * @param request The request whose processing triggered the exception.
58: * @param ex The exception that was triggered.
59: * @return A boolean, <strong>true</strong> if that filter did influence
60: * the target server used to fulfill the request, and it has fixed the
61: * problem in such a way that the request should be retried.
62: */
63:
64: public boolean exceptionFilter(Request request, HttpException ex);
65:
66: /**
67: * Synchronized any pending state into stable storage.
68: * If the filter maintains some in-memory cached state, this method
69: * should ensure that cached data are saved to stable storage.
70: */
71:
72: public void sync();
73:
74: }
|