1 10 11 package org.mule.impl; 12 13 import org.apache.commons.lang.ObjectUtils; 14 import org.mule.impl.message.ExceptionPayload; 15 import org.mule.umo.UMOMessage; 16 import org.mule.umo.endpoint.UMOImmutableEndpoint; 17 import org.mule.providers.NullPayload; 18 19 27 28 public class DefaultExceptionStrategy extends AbstractExceptionListener 29 { 30 public void handleMessagingException(UMOMessage message, Throwable t) 31 { 32 defaultHandler(t); 33 routeException(message, null, t); 34 } 35 36 public void handleRoutingException(UMOMessage message, UMOImmutableEndpoint endpoint, Throwable t) 37 { 38 defaultHandler(t); 39 routeException(message, endpoint, t); 40 } 41 42 public void handleLifecycleException(Object component, Throwable t) 43 { 44 handleStandardException(t); 47 logger.error("The object that failed was: \n" + ObjectUtils.toString(component, "null")); 48 } 49 50 public void handleStandardException(Throwable t) 51 { 52 defaultHandler(t); 53 markTransactionForRollback(); 54 if (RequestContext.getEventContext() != null) 56 { 57 handleMessagingException(RequestContext.getEventContext().getMessage(), t); 58 } 59 else 60 { 61 logger.info("There is no current event available, routing Null message with the exception"); 62 handleMessagingException(new MuleMessage(new NullPayload()), t); 63 } 64 } 65 66 protected void defaultHandler(Throwable t) 67 { 68 logException(t); 69 if (RequestContext.getEvent() != null) 70 { 71 RequestContext.setExceptionPayload(new ExceptionPayload(t)); 72 } 73 } 74 } 75 | Popular Tags |