Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Valve |
|
| 0.0;0 |
1 | package org.apache.turbine.pipeline; | |
2 | ||
3 | ||
4 | /* | |
5 | * Licensed to the Apache Software Foundation (ASF) under one | |
6 | * or more contributor license agreements. See the NOTICE file | |
7 | * distributed with this work for additional information | |
8 | * regarding copyright ownership. The ASF licenses this file | |
9 | * to you under the Apache License, Version 2.0 (the | |
10 | * "License"); you may not use this file except in compliance | |
11 | * with the License. You may obtain a copy of the License at | |
12 | * | |
13 | * http://www.apache.org/licenses/LICENSE-2.0 | |
14 | * | |
15 | * Unless required by applicable law or agreed to in writing, | |
16 | * software distributed under the License is distributed on an | |
17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
18 | * KIND, either express or implied. See the License for the | |
19 | * specific language governing permissions and limitations | |
20 | * under the License. | |
21 | */ | |
22 | ||
23 | ||
24 | import java.io.IOException; | |
25 | ||
26 | import org.apache.turbine.util.TurbineException; | |
27 | ||
28 | /** | |
29 | * <p>A <b>Valve</b> is a request processing component. A series of | |
30 | * Valves are generally associated with each other into a Pipeline. | |
31 | * The detailed contract for a Valve is included in the description of | |
32 | * the <code>invoke()</code> method below.</p> | |
33 | * | |
34 | * <b>HISTORICAL NOTE</b>: The "Valve" name was assigned to this concept | |
35 | * because a valve is what you use in a real world pipeline to control and/or | |
36 | * modify flows through it. | |
37 | * | |
38 | * @author Craig R. McClanahan | |
39 | * @author Gunnar Rjnning | |
40 | * @author Peter Donald | |
41 | * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a> | |
42 | * | |
43 | * @see #invoke(PipelineData, ValveContext) | |
44 | */ | |
45 | @FunctionalInterface | |
46 | public interface Valve | |
47 | { | |
48 | /** | |
49 | * <p>Perform request processing as required by this Valve.</p> | |
50 | * | |
51 | * <p>An individual Valve <b>MAY</b> perform the following actions, in | |
52 | * the specified order:</p> | |
53 | * <ul> | |
54 | * <li>Examine and/or modify the properties of the specified Request and | |
55 | * Response. | |
56 | * <li>Examine the properties of the specified Request, completely generate | |
57 | * the corresponding Response, and return control to the caller. | |
58 | * <li>Examine the properties of the specified Request and Response, wrap | |
59 | * either or both of these objects to supplement their functionality, | |
60 | * and pass them on. | |
61 | * <li>If the corresponding Response was not generated (and control was not | |
62 | * returned, call the next Valve in the pipeline (if there is one) by | |
63 | * executing <code>context.invokeNext()</code>. | |
64 | * <li>Examine, but not modify, the properties of the resulting Response | |
65 | * (which was created by a subsequently invoked Valve via a | |
66 | * call to <code>context.invokeNext()</code>). | |
67 | * </ul> | |
68 | * | |
69 | * <p>A Valve <b>MUST NOT</b> do any of the following things:</p> | |
70 | * <ul> | |
71 | * <li>Change request properties that have already been used to direct | |
72 | * the flow of processing control for this request. | |
73 | * <li>Create a completed Response <strong>AND</strong> pass this | |
74 | * Request and Response on to the next Valve in the pipeline. | |
75 | * <li>Consume bytes from the input stream associated with the Request, | |
76 | * unless it is completely generating the response, or wrapping the | |
77 | * request before passing it on. | |
78 | * <li>Modify the HTTP headers included with the Response after the | |
79 | * <code>invokeNext()</code> method has returned. | |
80 | * <li>Perform any actions on the output stream associated with the | |
81 | * specified Response after the <code>invokeNext()</code> method has | |
82 | * returned. | |
83 | * </ul> | |
84 | * | |
85 | * @param pipelineData The run-time information, including the servlet | |
86 | * request and response we are processing. | |
87 | * @param context The valve context used to invoke the next valve | |
88 | * in the current processing pipeline | |
89 | * | |
90 | * @throws IOException Thrown by a subsequent Valve. | |
91 | * @throws TurbineException Thrown by a subsequent Valve. | |
92 | */ | |
93 | void invoke(PipelineData pipelineData, ValveContext context) | |
94 | throws IOException, TurbineException; | |
95 | ||
96 | /** | |
97 | * Initialize the valve before using in a pipeline. | |
98 | * @throws Exception if initialization fails | |
99 | */ | |
100 | default void initialize() throws Exception | |
101 | { | |
102 | // empty | |
103 | } | |
104 | } |