interceptorchainimpl.java
来自「一个轻量级的MVC框架实例」· Java 代码 · 共 34 行
JAVA
34 行
package com.javaeedev.lightweight.mvc;
/**
* Used for holds an interceptor chain.
*
* @author Xuefeng
*/
class InterceptorChainImpl implements InterceptorChain {
private final Interceptor[] interceptors;
private int index = 0;
private ModelAndView mv = null;
InterceptorChainImpl(Interceptor[] interceptors) {
this.interceptors = interceptors;
}
ModelAndView getModelAndView() {
return mv;
}
public void doInterceptor(Action action) throws Exception {
if(index==interceptors.length)
mv = action.execute();
else {
// must update index first, otherwise will cause stack overflow:
index++;
interceptors[index-1].intercept(action, this);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?