Tomcat4 Valve执行顺序
来源:岁月联盟
时间:2012-03-05
3.1 ContainerBase 的invoke()
1
public void invoke(Request request, Response response)
2
throws IOException, ServletException {
3
pipeline.invoke(request, response);
4
}
3.2 DefaultPipeLine的invoke()
1
public void invoke(Request request, Response response)
2
throws IOException, ServletException {
3
4
// Invoke the first Valve in this pipeline for this request
5
(new StandardPipelineValveContext()).invokeNext(request, response);
6
7
}
3.3StandardPipelineValveContext为DefaultPipeLine的内部类.invokeNext()
view sourceprint?
01
protected class StandardPipelineValveContext
02
implements ValveContext {
03
04
// ------------------------------------------------- Instance Variables
05
protected int stage = 0;
06
07
// --------------------------------------------------------- Properties
08
/**
09
* Return descriptive information about this ValveContext
10
* implementation.
11
*/
12
public String getInfo() {
13
return info;
14
}
15
16
// ----------------------------------------------------- Public Methods
17
public void invokeNext(Request request, Response response)
18
throws IOException, ServletException {
19
20
int subscript = stage;
21
stage = stage + 1;
22
23
// Invoke the requested Valve for the current request thread
24
if (subscript < valves.length) {
25
valves[subscript].invoke(request, response, this);
26
} else if ((subscript == valves.length) && (basic != null)) {
27
basic.invoke(request, response, this);
28
} else {
29
throw new ServletException
30
(sm.getString("standardPipeline.noValve"));
31
}
32
}
33
}
4.Valve调用顺序:basicValve先执行,先add的后执行
上一篇:从硬盘安装fedora
下一篇:centos上搭建VSftp