Coverage Report - org.mule.impl.DefaultExceptionStrategy
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultExceptionStrategy
0%
0/20
0%
0/2
1.4
 
 1  
 /*
 2  
  * $Id: DefaultExceptionStrategy.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.impl;
 12  
 
 13  
 import org.mule.impl.message.ExceptionPayload;
 14  
 import org.mule.providers.NullPayload;
 15  
 import org.mule.umo.UMOMessage;
 16  
 import org.mule.umo.endpoint.UMOImmutableEndpoint;
 17  
 import org.mule.util.ObjectUtils;
 18  
 
 19  
 /**
 20  
  * <code>DefaultExceptionStrategy</code> provides a default exception handling
 21  
  * strategy. The class final thus to change exception handling behaviour the user
 22  
  * must reimplemented the ExceptionListener Interface
 23  
  */
 24  
 
 25  0
 public class DefaultExceptionStrategy extends AbstractExceptionListener
 26  
 {
 27  
     public void handleMessagingException(UMOMessage message, Throwable t)
 28  
     {
 29  0
         defaultHandler(t);
 30  0
         routeException(message, null, t);
 31  0
     }
 32  
 
 33  
     public void handleRoutingException(UMOMessage message, UMOImmutableEndpoint endpoint, Throwable t)
 34  
     {
 35  0
         defaultHandler(t);
 36  0
         routeException(message, endpoint, t);
 37  0
     }
 38  
 
 39  
     public void handleLifecycleException(Object component, Throwable t)
 40  
     {
 41  
         // Do nothing special here. Overriding implmentations may want alter the
 42  
         // behaviour
 43  0
         handleStandardException(t);
 44  0
         logger.error("The object that failed was: \n" + ObjectUtils.toString(component, "null"));
 45  0
     }
 46  
 
 47  
     public void handleStandardException(Throwable t)
 48  
     {
 49  0
         markTransactionForRollback();
 50  
         // Attempt to send the exception details to an endpoint if one is set
 51  0
         if (RequestContext.getEventContext() != null)
 52  
         {
 53  0
             handleMessagingException(RequestContext.getEventContext().getMessage(), t);
 54  
         }
 55  
         else
 56  
         {
 57  0
             logger.info("There is no current event available, routing Null message with the exception");
 58  0
             handleMessagingException(new MuleMessage(NullPayload.getInstance()), t);
 59  
         }
 60  0
     }
 61  
 
 62  
     protected void defaultHandler(Throwable t)
 63  
     {
 64  0
         logException(t);
 65  0
         if (RequestContext.getEvent() != null)
 66  
         {
 67  0
             RequestContext.setExceptionPayload(new ExceptionPayload(t));
 68  
         }
 69  0
     }
 70  
 }