1 10 11 package org.mule.routing; 12 13 import org.mule.config.i18n.Message; 14 import org.mule.config.i18n.Messages; 15 import org.mule.impl.MuleEvent; 16 import org.mule.impl.MuleMessage; 17 import org.mule.umo.UMOEvent; 18 import org.mule.umo.UMOMessage; 19 import org.mule.umo.UMOSession; 20 import org.mule.umo.provider.UMOMessageDispatcher; 21 import org.mule.umo.routing.ComponentRoutingException; 22 import org.mule.umo.routing.RoutingException; 23 24 33 34 public class ForwardingCatchAllStrategy extends AbstractCatchAllStrategy 35 { 36 private boolean sendTransformed = false; 37 38 public UMOMessage catchMessage(UMOMessage message, UMOSession session, boolean synchronous) 39 throws RoutingException 40 { 41 if (getEndpoint() == null) 42 { 43 throw new ComponentRoutingException(new Message(Messages.NO_CATCH_ALL_ENDPOINT_SET), message, 44 getEndpoint(), session.getComponent()); 45 } 46 try 47 { 48 UMOMessageDispatcher dispatcher = getEndpoint().getConnector().getDispatcher(getEndpoint()); 49 50 if (sendTransformed && getEndpoint().getTransformer() != null) 51 { 52 Object payload = message.getPayload(); 53 payload = getEndpoint().getTransformer().transform(payload); 54 message = new MuleMessage(payload, message); 55 } 56 UMOEvent newEvent = new MuleEvent(message, getEndpoint(), session, synchronous); 57 58 if (synchronous) 59 { 60 UMOMessage result = dispatcher.send(newEvent); 61 if (statistics != null) 62 { 63 statistics.incrementRoutedMessage(getEndpoint()); 64 } 65 return result; 66 } 67 else 68 { 69 dispatcher.dispatch(newEvent); 70 if (statistics != null) 71 { 72 statistics.incrementRoutedMessage(getEndpoint()); 73 } 74 return null; 75 } 76 } 77 catch (Exception e) 78 { 79 throw new RoutingException(message, getEndpoint(), e); 80 81 } 82 } 83 84 public boolean isSendTransformed() 85 { 86 return sendTransformed; 87 } 88 89 public void setSendTransformed(boolean sendTransformed) 90 { 91 this.sendTransformed = sendTransformed; 92 } 93 } 94 | Popular Tags |