2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.server;
21 import java.io.IOException;
23 import javax.servlet.ServletException;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
27 import org.eclipse.jetty.util.annotation.ManagedAttribute;
28 import org.eclipse.jetty.util.annotation.ManagedObject;
29 import org.eclipse.jetty.util.annotation.ManagedOperation;
30 import org.eclipse.jetty.util.component.Destroyable;
31 import org.eclipse.jetty.util.component.LifeCycle;
33 /* ------------------------------------------------------------ */
34 /** A Jetty Server Handler.
36 * A Handler instance is required by a {@link Server} to handle incoming
37 * HTTP requests. A Handler may: <ul>
38 * <li>Completely generate the HTTP Response</li>
39 * <li>Examine/modify the request and call another Handler (see {@link HandlerWrapper}).
40 * <li>Pass the request to one or more other Handlers (see {@link HandlerCollection}).
43 * Handlers are passed the servlet API request and response object, but are
44 * not Servlets. The servlet container is implemented by handlers for
45 * context, security, session and servlet that modify the request object
46 * before passing it to the next stage of handling.
49 @ManagedObject("Jetty Handler")
50 public interface Handler extends LifeCycle, Destroyable
52 /* ------------------------------------------------------------ */
54 * @param target The target of the request - either a URI or a name.
55 * @param baseRequest The original unwrapped request object.
56 * @param request The request either as the {@link Request}
57 * object or a wrapper of that request. The {@link HttpChannel#getCurrentHttpChannel()}
58 * method can be used access the Request object if required.
59 * @param response The response as the {@link Response}
60 * object or a wrapper of that request. The {@link HttpChannel#getCurrentHttpChannel()}
61 * method can be used access the Response object if required.
63 * @throws ServletException
65 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
66 throws IOException, ServletException;
68 public void setServer(Server server);
70 @ManagedAttribute(value="the jetty server for this handler", readonly=true)
71 public Server getServer();
73 @ManagedOperation(value="destroy associated resources", impact="ACTION")
74 public void destroy();