Coverage Report - org.mule.context.notification.ExceptionNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
ExceptionNotification
0%
0/11
0%
0/2
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.context.notification;
 8  
 
 9  
 import org.apache.commons.lang.exception.ExceptionUtils;
 10  
 import org.mule.api.context.notification.ServerNotification;
 11  
 
 12  
 /**
 13  
  * This class is from Mule 2.2.5. It is modified so the ExceptionNotification has a
 14  
  * resourceId of the exception type. This is only here so we can avoid doing a hot
 15  
  * fix of Mule to run MMC. This will be removed in future releases of MMC.
 16  
  */
 17  
 public class ExceptionNotification extends ServerNotification
 18  
 {
 19  
     /**
 20  
      * Serial version.
 21  
      */
 22  
     private static final long serialVersionUID = -43091546451476239L;
 23  
     public static final int EXCEPTION_ACTION = EXCEPTION_EVENT_ACTION_START_RANGE + 1;
 24  
 
 25  
     static
 26  
     {
 27  0
         registerAction("exception", EXCEPTION_ACTION);
 28  0
     }
 29  
 
 30  
     private Throwable exception;
 31  
 
 32  
     public ExceptionNotification(Throwable exception)
 33  
     {
 34  0
         super(exception, EXCEPTION_ACTION, getExceptionCause(exception));
 35  0
         this.exception = exception;
 36  0
     }
 37  
 
 38  
     /**
 39  
      * Find the root cause of the exception as typically Mule wraps the exception in
 40  
      * something like a ServiceException and when we register a listener under a
 41  
      * particular resource ID we want to listen for this root cause, not the
 42  
      * ServiceException.
 43  
      * 
 44  
      * @param exception
 45  
      * @return
 46  
      */
 47  
     private static String getExceptionCause(Throwable exception)
 48  
     {
 49  0
         Throwable cause = ExceptionUtils.getRootCause(exception);
 50  0
         if (cause != null)
 51  
         {
 52  0
             return cause.getClass().getName();
 53  
         }
 54  
         else
 55  
         {
 56  0
             return null;
 57  
         }
 58  
     }
 59  
 
 60  
     public Throwable getException()
 61  
     {
 62  0
         return this.exception;
 63  
     }
 64  
 
 65  
     @Override
 66  
     public String getType()
 67  
     {
 68  0
         return TYPE_ERROR;
 69  
     }
 70  
 }