01: //========================================================================
02: //Copyright 2006 Mort Bay Consulting Pty. Ltd.
03: //------------------------------------------------------------------------
04: //Licensed under the Apache License, Version 2.0 (the "License");
05: //you may not use this file except in compliance with the License.
06: //You may obtain a copy of the License at
07: //http://www.apache.org/licenses/LICENSE-2.0
08: //Unless required by applicable law or agreed to in writing, software
09: //distributed under the License is distributed on an "AS IS" BASIS,
10: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11: //See the License for the specific language governing permissions and
12: //limitations under the License.
13: //========================================================================
14:
15: package org.mortbay.jetty.handler;
16:
17: import java.io.IOException;
18:
19: import javax.servlet.ServletException;
20: import javax.servlet.http.HttpServletRequest;
21: import javax.servlet.http.HttpServletResponse;
22:
23: import org.mortbay.jetty.Handler;
24: import org.mortbay.jetty.HttpConnection;
25: import org.mortbay.jetty.Request;
26:
27: /* ------------------------------------------------------------ */
28: /** HandlerList.
29: * This extension of {@link org.mortbay.jetty.handler.HandlerCollection} will call
30: * each contained handler in turn until either an exception is thrown, the response
31: * is committed or a positive response status is set.
32: */
33: public class HandlerList extends HandlerCollection {
34: /* ------------------------------------------------------------ */
35: /*
36: * @see org.mortbay.jetty.EventHandler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
37: */
38: public void handle(String target, HttpServletRequest request,
39: HttpServletResponse response, int dispatch)
40: throws IOException, ServletException {
41: Handler[] handlers = getHandlers();
42:
43: if (handlers != null && isStarted()) {
44: Request base_request = HttpConnection
45: .getCurrentConnection().getRequest();
46: for (int i = 0; i < handlers.length; i++) {
47: handlers[i].handle(target, request, response, dispatch);
48: if (base_request.isHandled())
49: return;
50: }
51: }
52: }
53: }
|