Coverage Report - org.mule.umo.manager.DefaultWorkListener
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultWorkListener
0%
0/18
0%
0/2
1.6
 
 1  
 /*
 2  
  * $Id: DefaultWorkListener.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.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  
  * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
 23  
  * @version $Revision: 7976 $
 24  
  */
 25  0
 public class DefaultWorkListener implements WorkListener
 26  
 {
 27  
 
 28  
     /**
 29  
      * logger used by this class
 30  
      */
 31  0
     protected transient Log logger = LogFactory.getLog(getClass());
 32  
 
 33  
     public void workAccepted(WorkEvent event)
 34  
     {
 35  0
         handleWorkException(event, "workAccepted");
 36  0
     }
 37  
 
 38  
     public void workRejected(WorkEvent event)
 39  
     {
 40  0
         handleWorkException(event, "workRejected");
 41  0
     }
 42  
 
 43  
     public void workStarted(WorkEvent event)
 44  
     {
 45  0
         handleWorkException(event, "workStarted");
 46  0
     }
 47  
 
 48  
     public void workCompleted(WorkEvent event)
 49  
     {
 50  0
         handleWorkException(event, "workCompleted");
 51  0
     }
 52  
 
 53  
     protected void handleWorkException(WorkEvent event, String type)
 54  
     {
 55  
         Throwable e;
 56  
 
 57  0
         if (event != null && event.getException() != null)
 58  
         {
 59  0
             e = event.getException();
 60  
         }
 61  
         else
 62  
         {
 63  0
             return;
 64  
         }
 65  
 
 66  0
         if (event.getException().getCause() != null)
 67  
         {
 68  0
             e = event.getException().getCause();
 69  
         }
 70  
 
 71  0
         logger.error("Work caused exception on '" + type + "'. Work being executed was: "
 72  
                      + event.getWork().toString());
 73  0
         logger.error(e);
 74  0
     }
 75  
 }