1 10 11 package org.mule.umo.manager; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 16 import javax.resource.spi.work.WorkEvent ; 17 import javax.resource.spi.work.WorkListener ; 18 19 25 public class DefaultWorkListener implements WorkListener 26 { 27 28 31 protected transient Log logger = LogFactory.getLog(getClass()); 32 33 public void workAccepted(WorkEvent event) 34 { 35 handleWorkException(event, "workAccepted"); 36 } 37 38 public void workRejected(WorkEvent event) 39 { 40 handleWorkException(event, "workRejected"); 41 } 42 43 public void workStarted(WorkEvent event) 44 { 45 handleWorkException(event, "workStarted"); 46 } 47 48 public void workCompleted(WorkEvent event) 49 { 50 handleWorkException(event, "workCompleted"); 51 } 52 53 protected void handleWorkException(WorkEvent event, String type) 54 { 55 Throwable e; 56 57 if (event != null && event.getException() != null) 58 { 59 e = event.getException(); 60 } 61 else 62 { 63 return; 64 } 65 66 if (event.getException().getCause() != null) 67 { 68 e = event.getException().getCause(); 69 } 70 71 logger.error("Work caused exception on '" + type + "'. Work being executed was: " 72 + event.getWork().toString()); 73 logger.error(e); 74 } 75 } 76 | Popular Tags |