|
楼主 |
发表于 2005-4-6 13:22:38
|
显示全部楼层
- /*
- * 创建日期 2005-3-31
- *
- */
- package com.bupticet.strutsinterceptor;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.Action;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.springframework.web.struts.DelegatingActionProxy;
- /**
- * <p>Title: InterceptorActionProxy</p>
- *
- * <p>Description: 拦截器代理Action类</p>
- *
- * <p>Copyright: Copyright (c)北京邮电大学网络教育技术研究所[[url]www.buticet.com][/url] 2005</p>
- *
- * <p>Company: 北京邮电大学网络教育技术研究所[[url]www.buticet.com][/url] </p>
- *
- * @author LJ-silver E-mail:LJ-silver@163.com
- * @version 1.0
- */
- public class InterceptorActionProxy extends DelegatingActionProxy {
-
- static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(InterceptorActionProxy.class);
- /**
- * Pass the execute call on to the Spring-managed delegate Action.
- * @see #getDelegateAction
- */
- public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- Action delegateAction = getDelegateAction(mapping);
- ActionForward forward = null;
- List interceptorList = InterceptorConfig.getInterceptorList(request);
- int size = interceptorList.size();
- if(size > 0){
- ActionInterceptor[] interceptorArray = InterceptorConfig.getInterceptor(interceptorList);
- try{
- for(int i = 0;i<size;i++){
- forward = interceptorArray[i].beforeAction(mapping, form, request, response);
- if(forward!=null){
- return forward;
- }
- }
- forward = delegateAction.execute(mapping, form, request, response);
- for(int i = 0;i<size;i++){
- interceptorArray[i].afterAction(mapping, form, request, response);
- }
-
- }catch(Exception e){
- e.printStackTrace();
- logger.error("In execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response), Exception Occured ! Info :" + e.getLocalizedMessage());
- for(int i = 0;i<size;i++){
- forward = interceptorArray[i].throwsAction(mapping, form, request, response,e);
- if(forward!=null){
- return forward;
- }
- }
- }
- }else{
- forward = delegateAction.execute(mapping, form, request, response);
- }
- return forward;
- }
- }
复制代码 |
|