1 10 11 package org.mule.impl; 12 13 import org.mule.impl.model.AbstractComponent; 14 import org.mule.management.stats.ComponentStatistics; 15 import org.mule.umo.UMOComponent; 16 import org.mule.umo.UMOEvent; 17 import org.mule.umo.UMOMessage; 18 import org.mule.umo.endpoint.UMOEndpoint; 19 import org.mule.umo.endpoint.UMOImmutableEndpoint; 20 21 29 public class DefaultComponentExceptionStrategy extends DefaultExceptionStrategy 30 { 31 34 protected UMOComponent component; 35 36 protected ComponentStatistics statistics; 37 38 public DefaultComponentExceptionStrategy() 39 { 40 super(); 41 } 42 43 49 public DefaultComponentExceptionStrategy(UMOComponent component) 50 { 51 super(); 52 setComponent(component); 53 } 54 55 58 public UMOComponent getComponent() 59 { 60 return component; 61 } 62 63 protected void defaultHandler(Throwable t) 64 { 65 if (component == null) 69 { 70 UMOEvent event = RequestContext.getEvent(); 71 if (event == null) 72 { logger.fatal("The Default Component Exception Strategy has been invoked but there is no current event on the context"); 74 logger.fatal("The error is: " + t.getMessage(), t); 75 } 76 else 77 { 78 setComponent(event.getComponent()); 79 } 80 } 81 82 if (statistics != null) 83 { 84 statistics.incExecutionError(); 85 } 86 87 if (component != null) 88 { 89 logger.error("Caught exception in Exception Strategy for: " + component.getDescriptor().getName() 90 + ": " + t, t); 91 } 92 super.defaultHandler(t); 93 94 } 95 96 protected void logFatal(UMOMessage message, Throwable t) 97 { 98 super.logFatal(message, t); 99 if (statistics != null) 100 { 101 statistics.incFatalError(); 102 } 103 } 104 105 protected void routeException(UMOMessage message, UMOImmutableEndpoint failedEndpoint, Throwable t) 106 { 107 UMOEndpoint ep = getEndpoint(t); 108 if (ep != null) 109 { 110 super.routeException(message, failedEndpoint, t); 111 if (statistics != null) 112 { 113 statistics.getOutboundRouterStat().incrementRoutedMessage(ep); 114 } 115 } 116 } 117 118 public void setComponent(UMOComponent component) 119 { 120 this.component = component; 121 if (component instanceof AbstractComponent) 122 { 123 if (statistics != null) 124 { 125 this.statistics = ((AbstractComponent)component).getStatistics(); 126 } 127 } 128 } 129 } 130 | Popular Tags |