1
2
3 /*
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5 *
6 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
7 *
8 * Portions Copyright Apache Software Foundation.
9 *
10 * The contents of this file are subject to the terms of either the GNU
11 * General Public License Version 2 only ("GPL") or the Common Development
12 * and Distribution License("CDDL") (collectively, the "License"). You
13 * may not use this file except in compliance with the License. You can obtain
14 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
15 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
16 * language governing permissions and limitations under the License.
17 *
18 * When distributing the software, include this License Header Notice in each
19 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
20 * Sun designates this particular file as subject to the "Classpath" exception
21 * as provided by Sun in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the License
23 * Header, with the fields enclosed by brackets [] replaced by your own
24 * identifying information: "Portions Copyrighted [year]
25 * [name of copyright owner]"
26 *
27 * Contributor(s):
28 *
29 * If you wish your version of this file to be governed by only the CDDL or
30 * only the GPL Version 2, indicate your decision by adding "[Contributor]
31 * elects to include this software in this distribution under the [CDDL or GPL
32 * Version 2] license." If you don't indicate a single choice of license, a
33 * recipient has the option to distribute your version of this file under
34 * either the CDDL, the GPL Version 2 or to extend the choice of license to
35 * its licensees as provided above. However, if you add GPL Version 2 code
36 * and therefore, elected the GPL Version 2 license, then the option applies
37 * only if the new code is made subject to such option by the copyright
38 * holder.
39 */
40
41
42 package org.apache.catalina.core;
43
44
45 import java.io.IOException;
46 import javax.servlet.ServletException;
47 import org.apache.catalina.Request;
48 import org.apache.catalina.Response;
49 import org.apache.catalina.Valve;
50 import org.apache.catalina.ValveContext;
51 import org.apache.catalina.util.StringManager;
52
53
54 /**
55 * Standard implementation of a <code>ValveContext</code>.
56 *
57 * @author Craig R. McClanahan
58 * @author Remy Maucherat
59 *
60 * <IMPLEMENTATION-NOTE>
61 ???* This class is no longer used in PE 8.0. See bug 4665318
62 * @author Jean-Francois Arcand
63 * </IMPLEMENTATION-NOTE>
64 */
65
66 public final class StandardValveContext
67 implements ValveContext {
68
69
70 // ----------------------------------------------------- Instance Variables
71
72
73 /**
74 * The string manager for this package.
75 */
76 protected static final StringManager sm =
77 StringManager.getManager(Constants.Package);
78
79
80 protected String info =
81 "org.apache.catalina.core.StandardValveContext/1.0";
82 protected int stage = 0;
83 protected Valve basic = null;
84 protected Valve valves[] = null;
85
86
87 // ------------------------------------------------------------- Properties
88
89
90 /**
91 * Return descriptive information about this ValveContext
92 * implementation.
93 */
94 public String getInfo() {
95 return info;
96 }
97
98
99 // --------------------------------------------------------- Public Methods
100
101
102 /**
103 * Cause the <code>invoke()</code> method of the next Valve that is
104 * part of the Pipeline currently being processed (if any) to be
105 * executed, passing on the specified request and response objects
106 * plus this <code>ValveContext</code> instance. Exceptions thrown by
107 * a subsequently executed Valve (or a Filter or Servlet at the
108 * application level) will be passed on to our caller.
109 *
110 * If there are no more Valves to be executed, an appropriate
111 * ServletException will be thrown by this ValveContext.
112 *
113 * @param request The request currently being processed
114 * @param response The response currently being created
115 *
116 * @exception IOException if thrown by a subsequent Valve, Filter, or
117 * Servlet
118 * @exception ServletException if thrown by a subsequent Valve, Filter,
119 * or Servlet
120 * @exception ServletException if there are no further Valves
121 * configured in the Pipeline currently being processed
122 */
123 public final void invokeNext(Request request, Response response)
124 throws IOException, ServletException {
125
126 /** STARTS OF PE 4665318
127 int subscript = stage;
128 stage = stage + 1;
129
130 // Invoke the requested Valve for the current request thread
131 if (subscript < valves.length) {
132 valves[subscript].invoke(request, response, this);
133 } else if ((subscript == valves.length) && (basic != null)) {
134 basic.invoke(request, response, this);
135 } else {
136 throw new ServletException
137 (sm.getString("standardPipeline.noValve"));
138 }
139 */
140 // END OF PE 4665318
141 }
142
143
144 // -------------------------------------------------------- Package Methods
145
146
147 /**
148 * Reset state.
149 */
150 void set(Valve basic, Valve valves[]) {
151 stage = 0;
152 this.basic = basic;
153 this.valves = valves;
154 }
155
156
157 }
158