DelegatingActionProxy

来源:互联网 发布:招商加盟网络推广方案 编辑:程序博客网 时间:2024/05/02 02:43
public class DelegatingActionProxy extends Action {
    public ActionForward execute(
            ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        Action delegateAction = getDelegateAction(mapping);//得到action实例
        return delegateAction.execute(mapping, form, request, response);

    }


 protected Action getDelegateAction(ActionMapping mapping) throws BeansException {
        WebApplicationContext wac = getWebApplicationContext(getServlet(), mapping.getModuleConfig());//得到spring容器
        String beanName = determineActionBeanName(mapping);//根据传来的mapping 在得到beanName(prefax + path)看下面方法的代码。
//
在服务器开启服务时会进行一些初始化的工作。其中重要的一份工作就是初始化ModuleConfig。ModuleConfig是和struts配置文件相对应的,说的具体点是和<struts-config>对应的。一个配置文件对应一个moduleconfig。
//用来标志和区分ModuleConfig类,同时在使用上面的config类初始化相应的资源以后,也是通过这个prefix来区分所属的不同的web模块。
 

 protected String prefix


        return (Action) wac.getBean(beanName, Action.class);
    }

 
    protected WebApplicationContext getWebApplicationContext(
            ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {

        return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, moduleConfig);
    }

 
    protected String determineActionBeanName(ActionMapping mapping) {
        return DelegatingActionUtils.determineActionBeanName(mapping);
    }


}

0 0
原创粉丝点击