Coverage Report - org.mule.umo.manager.DefaultWorkListener
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultWorkListener
56%
10/18
33%
2/6
1.6
 
 1  
 /*
 2  
  * $Id: DefaultWorkListener.java 7963 2007-08-21 08:53:15Z 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.umo.manager;
 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  2296
 public class DefaultWorkListener implements WorkListener
 23  
 {
 24  
 
 25  
     /**
 26  
      * logger used by this class
 27  
      */
 28  2296
     protected transient Log logger = LogFactory.getLog(getClass());
 29  
 
 30  
     public void workAccepted(WorkEvent event)
 31  
     {
 32  44
         handleWorkException(event, "workAccepted");
 33  44
     }
 34  
 
 35  
     public void workRejected(WorkEvent event)
 36  
     {
 37  0
         handleWorkException(event, "workRejected");
 38  0
     }
 39  
 
 40  
     public void workStarted(WorkEvent event)
 41  
     {
 42  44
         handleWorkException(event, "workStarted");
 43  44
     }
 44  
 
 45  
     public void workCompleted(WorkEvent event)
 46  
     {
 47  44
         handleWorkException(event, "workCompleted");
 48  44
     }
 49  
 
 50  
     protected void handleWorkException(WorkEvent event, String type)
 51  
     {
 52  
         Throwable e;
 53  
 
 54  132
         if (event != null && event.getException() != null)
 55  
         {
 56  0
             e = event.getException();
 57  
         }
 58  
         else
 59  
         {
 60  132
             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  
 }