1 16 17 package org.apache.struts.chain.servlet; 18 19 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.http.HttpServletResponse ; 22 import org.apache.commons.chain.Context; 23 import org.apache.commons.chain.web.servlet.ServletWebContext; 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 import org.apache.struts.chain.AbstractExceptionHandler; 27 import org.apache.struts.chain.Constants; 28 import org.apache.struts.chain.util.ClassUtils; 29 import org.apache.struts.action.ActionForm; 30 import org.apache.struts.action.ActionMapping; 31 import org.apache.struts.config.ActionConfig; 32 import org.apache.struts.config.ExceptionConfig; 33 import org.apache.struts.config.ForwardConfig; 34 import org.apache.struts.config.ModuleConfig; 35 36 37 42 43 public class ExceptionHandler extends AbstractExceptionHandler { 44 45 46 48 49 private String actionFormKey = Constants.ACTION_FORM_KEY; 50 51 private static final Log log = LogFactory.getLog(ExceptionHandler.class); 52 53 54 56 57 62 public String getActionFormKey() { 63 64 return (this.actionFormKey); 65 66 } 67 68 69 76 public void setActionFormKey(String actionFormKey) { 77 78 this.actionFormKey = actionFormKey; 79 80 } 81 82 83 85 86 protected ForwardConfig handle(Context context, 87 Exception exception, 88 ExceptionConfig exceptionConfig, 89 ActionConfig actionConfig, 90 ModuleConfig moduleConfig) 91 throws Exception { 92 93 ServletWebContext swcontext = (ServletWebContext) context; 95 ActionForm actionForm = (ActionForm) 96 swcontext.get(getActionFormKey()); 97 HttpServletRequest request = swcontext.getRequest(); 98 HttpServletResponse response = swcontext.getResponse(); 99 100 org.apache.struts.action.ExceptionHandler handler = 102 (org.apache.struts.action.ExceptionHandler) 103 ClassUtils.getApplicationInstance(exceptionConfig.getHandler()); 104 return (handler.execute(exception, 105 exceptionConfig, 106 (ActionMapping) actionConfig, 107 actionForm, 108 request, 109 response)); 110 111 } 112 113 114 } 115 | Popular Tags |