1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
19 package org.apache.catalina.core;
20
21
22 import java.io.IOException;
23
24 import javax.servlet.ServletException;
25 import javax.servlet.http.HttpServletResponse;
26
27 import org.apache.catalina.CometEvent;
28 import org.apache.catalina.Host;
29 import org.apache.catalina.connector.Request;
30 import org.apache.catalina.connector.Response;
31 import org.apache.catalina.util.StringManager;
32 import org.apache.catalina.valves.ValveBase;
33
34
35 /**
36 * Valve that implements the default basic behavior for the
37 * <code>StandardEngine</code> container implementation.
38 * <p>
39 * <b>USAGE CONSTRAINT</b>: This implementation is likely to be useful only
40 * when processing HTTP requests.
41 *
42 * @author Craig R. McClanahan
43 * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
44 */
45
46 final class StandardEngineValve
47 extends ValveBase {
48
49
50 // ----------------------------------------------------- Instance Variables
51
52
53 /**
54 * The descriptive information related to this implementation.
55 */
56 private static final String info =
57 "org.apache.catalina.core.StandardEngineValve/1.0";
58
59
60 /**
61 * The string manager for this package.
62 */
63 private static final StringManager sm =
64 StringManager.getManager(Constants.Package);
65
66
67 // ------------------------------------------------------------- Properties
68
69
70 /**
71 * Return descriptive information about this Valve implementation.
72 */
73 public String getInfo() {
74
75 return (info);
76
77 }
78
79
80 // --------------------------------------------------------- Public Methods
81
82
83 /**
84 * Select the appropriate child Host to process this request,
85 * based on the requested server name. If no matching Host can
86 * be found, return an appropriate HTTP error.
87 *
88 * @param request Request to be processed
89 * @param response Response to be produced
90 * @param valveContext Valve context used to forward to the next Valve
91 *
92 * @exception IOException if an input/output error occurred
93 * @exception ServletException if a servlet error occurred
94 */
95 public final void invoke(Request request, Response response)
96 throws IOException, ServletException {
97
98 // Select the Host to be used for this Request
99 Host host = request.getHost();
100 if (host == null) {
101 response.sendError
102 (HttpServletResponse.SC_BAD_REQUEST,
103 sm.getString("standardEngine.noHost",
104 request.getServerName()));
105 return;
106 }
107
108 // Ask this Host to process this request
109 host.getPipeline().getFirst().invoke(request, response);
110
111 }
112
113
114 /**
115 * Process Comet event.
116 *
117 * @param request Request to be processed
118 * @param response Response to be produced
119 * @param valveContext Valve context used to forward to the next Valve
120 *
121 * @exception IOException if an input/output error occurred
122 * @exception ServletException if a servlet error occurred
123 */
124 public final void event(Request request, Response response, CometEvent event)
125 throws IOException, ServletException {
126
127 // Ask this Host to process this request
128 request.getHost().getPipeline().getFirst().event(request, response, event);
129
130 }
131
132 }