Coverage Report - org.mule.work.DefaultWorkListener
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultWorkListener
0%
0/18
0%
0/6
1.6
 
 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.work;
 8  
 
 9  
 import javax.resource.spi.work.WorkEvent;
 10  
 import javax.resource.spi.work.WorkListener;
 11  
 
 12  
 import org.apache.commons.logging.Log;
 13  
 import org.apache.commons.logging.LogFactory;
 14  
 
 15  
 /**
 16  
  * Default exception Handler used when executing work in the work manager
 17  
  */
 18  0
 public class DefaultWorkListener implements WorkListener
 19  
 {
 20  
 
 21  
     /**
 22  
      * logger used by this class
 23  
      */
 24  0
     protected transient Log logger = LogFactory.getLog(getClass());
 25  
 
 26  
     public void workAccepted(WorkEvent event)
 27  
     {
 28  0
         handleWorkException(event, "workAccepted");
 29  0
     }
 30  
 
 31  
     public void workRejected(WorkEvent event)
 32  
     {
 33  0
         handleWorkException(event, "workRejected");
 34  0
     }
 35  
 
 36  
     public void workStarted(WorkEvent event)
 37  
     {
 38  0
         handleWorkException(event, "workStarted");
 39  0
     }
 40  
 
 41  
     public void workCompleted(WorkEvent event)
 42  
     {
 43  0
         handleWorkException(event, "workCompleted");
 44  0
     }
 45  
 
 46  
     protected void handleWorkException(WorkEvent event, String type)
 47  
     {
 48  
         Throwable e;
 49  
 
 50  0
         if (event != null && event.getException() != null)
 51  
         {
 52  0
             e = event.getException();
 53  
         }
 54  
         else
 55  
         {
 56  0
             return;
 57  
         }
 58  
 
 59  0
         if (event.getException().getCause() != null)
 60  
         {
 61  0
             e = event.getException().getCause();
 62  
         }
 63  
 
 64  0
         logger.error("Work caused exception on '" + type + "'. Work being executed was: "
 65  
                      + event.getWork().toString());
 66  0
         logger.error(e);
 67  0
     }
 68  
 }