1 55 56 package org.jboss.axis; 57 58 import org.jboss.axis.handlers.BasicHandler; 59 import org.jboss.axis.utils.Messages; 60 import org.jboss.logging.Logger; 61 62 import javax.xml.namespace.QName ; 63 import java.util.Enumeration ; 64 import java.util.Hashtable ; 65 66 73 public class FaultableHandler extends BasicHandler 74 { 75 private static Logger log = Logger.getLogger(FaultableHandler.class.getName()); 76 77 protected Handler workHandler; 78 79 84 public FaultableHandler(Handler workHandler) 85 { 86 this.workHandler = workHandler; 87 } 88 89 public void init() 90 { 91 workHandler.init(); 92 } 93 94 public void cleanup() 95 { 96 workHandler.cleanup(); 97 } 98 99 105 public void invoke(MessageContext msgContext) throws AxisFault 106 { 107 log.debug("Enter: FaultableHandler::invoke"); 108 try 109 { 110 workHandler.invoke(msgContext); 111 } 112 catch (Exception e) 113 { 114 log.info(Messages.getMessage("toAxisFault00"), e); 115 AxisFault fault = AxisFault.makeFault(e); 116 117 119 125 129 Handler faultHandler = null; 130 131 Hashtable options = getOptions(); 132 if (options != null) 133 { 134 Enumeration en = options.keys(); 135 while (en.hasMoreElements()) 136 { 137 String s = (String )en.nextElement(); 138 if (s.equals("fault-" + fault.getFaultCode().getLocalPart())) 139 { 140 faultHandler = (Handler)options.get(s); 141 } 142 } 143 } 144 145 if (faultHandler != null) 146 { 147 153 faultHandler.invoke(msgContext); 154 } 155 else 156 { 157 throw fault; 158 } 159 } 160 log.debug("Exit: FaultableHandler::invoke"); 161 } 162 163 166 public void onFault(MessageContext msgContext) 167 { 168 log.debug("Enter: FaultableHandler::onFault"); 169 workHandler.onFault(msgContext); 170 log.debug("Exit: FaultableHandler::onFault"); 171 } 172 173 public boolean canHandleBlock(QName qname) 174 { 175 return (workHandler.canHandleBlock(qname)); 176 } 177 } 178 179 ; 180 | Popular Tags |