1 16 17 package org.springframework.web.struts; 18 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 22 import org.apache.struts.action.Action; 23 import org.apache.struts.action.ActionForm; 24 import org.apache.struts.action.ActionForward; 25 import org.apache.struts.action.ActionMapping; 26 import org.apache.struts.action.ActionServlet; 27 import org.apache.struts.config.ModuleConfig; 28 29 import org.springframework.beans.BeansException; 30 import org.springframework.web.context.WebApplicationContext; 31 32 95 public class DelegatingActionProxy extends Action { 96 97 101 public ActionForward execute( 102 ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 103 throws Exception { 104 105 Action delegateAction = getDelegateAction(mapping); 106 return delegateAction.execute(mapping, form, request, response); 107 } 108 109 119 protected Action getDelegateAction(ActionMapping mapping) throws BeansException { 120 WebApplicationContext wac = getWebApplicationContext(getServlet(), mapping.getModuleConfig()); 121 String beanName = determineActionBeanName(mapping); 122 return (Action) wac.getBean(beanName, Action.class); 123 } 124 125 136 protected WebApplicationContext getWebApplicationContext( 137 ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException { 138 139 return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, moduleConfig); 140 } 141 142 153 protected String determineActionBeanName(ActionMapping mapping) { 154 return DelegatingActionUtils.determineActionBeanName(mapping); 155 } 156 157 } 158 | Popular Tags |