Coverage Report - org.mule.routing.inbound.ForwardingConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
ForwardingConsumer
0%
0/15
0%
0/3
9
 
 1  
 /*
 2  
  * $Id: ForwardingConsumer.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.routing.inbound;
 12  
 
 13  
 import org.mule.impl.MuleEvent;
 14  
 import org.mule.impl.MuleMessage;
 15  
 import org.mule.umo.MessagingException;
 16  
 import org.mule.umo.UMOEvent;
 17  
 import org.mule.umo.UMOException;
 18  
 import org.mule.umo.UMOMessage;
 19  
 import org.mule.umo.routing.RoutingException;
 20  
 import org.mule.umo.routing.UMOOutboundRouterCollection;
 21  
 
 22  
 /**
 23  
  * <code>ForwardingConsumer</code> is used to forward an incoming event over
 24  
  * another transport without invoking a component. This can be used to implement a
 25  
  * bridge accross defferent transports.
 26  
  */
 27  0
 public class ForwardingConsumer extends SelectiveConsumer
 28  
 {
 29  
 
 30  
     public UMOEvent[] process(UMOEvent event) throws MessagingException
 31  
     {
 32  0
         if (super.process(event) != null)
 33  
         {
 34  0
             UMOOutboundRouterCollection router = event.getComponent().getDescriptor().getOutboundRouter();
 35  
 
 36  
             // Set the stopFurtherProcessing flag to true to inform the
 37  
             // InboundRouterCollection not to route these events to the component
 38  0
             event.setStopFurtherProcessing(true);
 39  
 
 40  0
             if (router == null)
 41  
             {
 42  0
                 logger.debug("Descriptor has no outbound router configured to forward to, continuing with normal processing");
 43  0
                 return new UMOEvent[]{event};
 44  
             }
 45  
             else
 46  
             {
 47  
                 try
 48  
                 {
 49  0
                     UMOMessage message = new MuleMessage(event.getTransformedMessage(), event.getMessage());
 50  
 
 51  0
                     UMOMessage response = router.route(message, event.getSession(), event.isSynchronous());
 52  
                     // TODO What's the correct behaviour for async endpoints?
 53  
                     // maybe let router.route() return a Future for the returned msg?
 54  0
                     if (response != null)
 55  
                     {
 56  0
                         return new UMOEvent[]{new MuleEvent(response, event)};
 57  
                     }
 58  
                     else
 59  
                     {
 60  0
                         return null;
 61  
                     }
 62  
 
 63  
                 }
 64  0
                 catch (UMOException e)
 65  
                 {
 66  0
                     throw new RoutingException(event.getMessage(), event.getEndpoint(), e);
 67  
                 }
 68  
             }
 69  
         }
 70  0
         return null;
 71  
     }
 72  
 }