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  
  * $Id: DefaultWorkListener.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.work;
 12  
 
 13  
 import javax.resource.spi.work.WorkEvent;
 14  
 import javax.resource.spi.work.WorkListener;
 15  
 
 16  
 import org.apache.commons.logging.Log;
 17  
 import org.apache.commons.logging.LogFactory;
 18  
 
 19  
 /**
 20  
  * Default exception Handler used when executing work in the work manager
 21  
  */
 22  0
 public class DefaultWorkListener implements WorkListener
 23  
 {
 24  
 
 25  
     /**
 26  
      * logger used by this class
 27  
      */
 28  0
     protected transient Log logger = LogFactory.getLog(getClass());
 29  
 
 30  
     public void workAccepted(WorkEvent event)
 31  
     {
 32  0
         handleWorkException(event, "workAccepted");
 33  0
     }
 34  
 
 35  
     public void workRejected(WorkEvent event)
 36  
     {
 37  0
         handleWorkException(event, "workRejected");
 38  0
     }
 39  
 
 40  
     public void workStarted(WorkEvent event)
 41  
     {
 42  0
         handleWorkException(event, "workStarted");
 43  0
     }
 44  
 
 45  
     public void workCompleted(WorkEvent event)
 46  
     {
 47  0
         handleWorkException(event, "workCompleted");
 48  0
     }
 49  
 
 50  
     protected void handleWorkException(WorkEvent event, String type)
 51  
     {
 52  
         Throwable e;
 53  
 
 54  0
         if (event != null && event.getException() != null)
 55  
         {
 56  0
             e = event.getException();
 57  
         }
 58  
         else
 59  
         {
 60  0
             return;
 61  
         }
 62  
 
 63  0
         if (event.getException().getCause() != null)
 64  
         {
 65  0
             e = event.getException().getCause();
 66  
         }
 67  
 
 68  0
         logger.error("Work caused exception on '" + type + "'. Work being executed was: "
 69  
                      + event.getWork().toString());
 70  0
         logger.error(e);
 71  0
     }
 72  
 }