1 16 17 package org.apache.axis ; 18 19 import org.apache.axis.components.logger.LogFactory; 20 import org.apache.axis.handlers.BasicHandler; 21 import org.apache.axis.utils.Messages; 22 import org.apache.commons.logging.Log; 23 24 import javax.xml.namespace.QName ; 25 import java.util.Enumeration ; 26 import java.util.Hashtable ; 27 28 36 public class FaultableHandler extends BasicHandler { 37 41 protected static Log log = 42 LogFactory.getLog(FaultableHandler.class.getName()); 43 44 51 protected static Log entLog = 52 LogFactory.getLog(Constants.ENTERPRISE_LOG_CATEGORY); 53 54 58 protected Handler workHandler ; 59 60 65 public FaultableHandler(Handler workHandler) 66 { 67 this.workHandler = workHandler; 68 } 69 70 public void init() { 71 workHandler.init(); 72 } 73 74 public void cleanup() { 75 workHandler.cleanup(); 76 } 77 78 87 public void invoke(MessageContext msgContext) throws AxisFault { 88 log.debug("Enter: FaultableHandler::invoke"); 89 try { 90 workHandler.invoke( msgContext ); 91 } 92 catch( Exception e ) { 93 entLog.info(Messages.getMessage("toAxisFault00"), e ); 94 AxisFault fault = AxisFault.makeFault(e); 95 96 98 104 108 Handler faultHandler = null; 109 110 Hashtable options = getOptions(); 111 if (options != null) { 112 Enumeration enumeration = options.keys(); 113 while (enumeration.hasMoreElements()) { 114 String s = (String ) enumeration.nextElement(); 115 if (s.equals("fault-" + fault.getFaultCode().getLocalPart())) { 116 faultHandler = (Handler)options.get(s); 117 } 118 } 119 } 120 121 if ( faultHandler != null ) { 122 128 faultHandler.invoke( msgContext ); 129 } else { 130 throw fault; 131 } 132 } 133 log.debug("Exit: FaultableHandler::invoke"); 134 } 135 136 141 public void onFault(MessageContext msgContext) { 142 log.debug("Enter: FaultableHandler::onFault"); 143 workHandler.onFault( msgContext ); 144 log.debug("Exit: FaultableHandler::onFault"); 145 } 146 147 public boolean canHandleBlock(QName qname) { 148 return( workHandler.canHandleBlock(qname) ); 149 } 150 }; 151 | Popular Tags |