这一步主要做了三件事:创建Action的代理,封装结果集Result,设置值栈。
实际上是通过调用DefaultActionProxyFactory的createActionProxy方法来创建的Action的代理
public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) {
// 创建ActionInvocation负责迭代和执行Action
ActionInvocation inv = new DefaultActionInvocation(extraContext, true);
// 放入容器中
container.inject(inv);
// 调用这个重载的createActionProxy方法
return createActionProxy(inv, namespace, actionName, methodName, executeResult, cleanupContext);
}
在方法返回的时候调用重载的createActionProxy方法,进入源码看一下:
public ActionProxy createActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, boolean executeResult, boolean cleanupContext) {
DefaultActionProxy proxy = new DefaultActionProxy(inv, namespace, actionName, methodName, executeResult, cleanupContext);
container.inject(proxy);
// 这里,proxy开始准备
proxy.prepare();
return proxy;
}
看这里:proxy.prepare();,proxy开始准备,继续跟源码:
protected void prepare() {
String profileKey = "create DefaultActionProxy: ";
try {
UtilTimerStack.push(profileKey);
config = configuration.getRuntimeConfiguration().getActionConfig(namespace, actionName);
if (config == null && unknownHandlerManager.hasUnknownHandlers()) {
config = unknownHandlerManager.handleUnknownAction(namespace, actionName);
}
if (config == null) {
throw new ConfigurationException(getErrorMessage());
}
resolveMethod();
if (!config.isAllowedMethod(method)) {
throw new ConfigurationException("Invalid method: " + method + " for action " + actionName);
}
// 关键:开始初始化invocation
invocation.init(this);
} finally {
UtilTimerStack.pop(profileKey);
}
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-78438-11.html
去不了只能舔屏了