Coverage Report - org.mule.routing.outbound.MulticastingRouter
 
Classes in this File Line Coverage Branch Coverage Complexity
MulticastingRouter
0%
0/25
0%
0/8
11
 
 1  
 /*
 2  
  * $Id: MulticastingRouter.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.outbound;
 12  
 
 13  
 import org.mule.config.i18n.CoreMessages;
 14  
 import org.mule.umo.UMOException;
 15  
 import org.mule.umo.UMOMessage;
 16  
 import org.mule.umo.UMOSession;
 17  
 import org.mule.umo.endpoint.UMOEndpoint;
 18  
 import org.mule.umo.routing.CouldNotRouteOutboundMessageException;
 19  
 import org.mule.umo.routing.RoutePathNotFoundException;
 20  
 import org.mule.umo.routing.RoutingException;
 21  
 
 22  
 /**
 23  
  * <code>MulticastingRouter</code> will broadcast the current message to every
 24  
  * endpoint registed with the router.
 25  
  * 
 26  
  * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
 27  
  * @version $Revision: 7976 $
 28  
  */
 29  
 
 30  0
 public class MulticastingRouter extends FilteringOutboundRouter
 31  
 {
 32  
 
 33  
     public UMOMessage route(UMOMessage message, UMOSession session, boolean synchronous)
 34  
         throws RoutingException
 35  
     {
 36  0
         UMOMessage result = null;
 37  0
         if (endpoints == null || endpoints.size() == 0)
 38  
         {
 39  0
             throw new RoutePathNotFoundException(CoreMessages.noEndpointsForRouter(), message, null);
 40  
         }
 41  0
         if (enableCorrelation != ENABLE_CORRELATION_NEVER)
 42  
         {
 43  0
             boolean correlationSet = message.getCorrelationId() != null;
 44  0
             if (correlationSet && (enableCorrelation == ENABLE_CORRELATION_IF_NOT_SET))
 45  
             {
 46  0
                 logger.debug("CorrelationId is already set, not setting Correlation group size");
 47  
             }
 48  
             else
 49  
             {
 50  
                 // the correlationId will be set by the AbstractOutboundRouter
 51  0
                 message.setCorrelationGroupSize(endpoints.size());
 52  
             }
 53  
         }
 54  
 
 55  
         try
 56  
         {
 57  
             UMOEndpoint endpoint;
 58  0
             synchronized (endpoints)
 59  
             {
 60  0
                 for (int i = 0; i < endpoints.size(); i++)
 61  
                 {
 62  0
                     endpoint = (UMOEndpoint) endpoints.get(i);
 63  0
                     if (synchronous)
 64  
                     {
 65  
                         // Were we have multiple outbound endpoints
 66  0
                         if (result == null)
 67  
                         {
 68  0
                             result = send(session, message, endpoint);
 69  
                         }
 70  
                         else
 71  
                         {
 72  0
                             String def = (String) endpoint.getProperties().get("default");
 73  0
                             if (def != null)
 74  
                             {
 75  0
                                 result = send(session, message, endpoint);
 76  
                             }
 77  
                             else
 78  
                             {
 79  0
                                 send(session, message, endpoint);
 80  
                             }
 81  
                         }
 82  
                     }
 83  
                     else
 84  
                     {
 85  0
                         dispatch(session, message, endpoint);
 86  
                     }
 87  
                 }
 88  0
             }
 89  
         }
 90  0
         catch (UMOException e)
 91  
         {
 92  0
             throw new CouldNotRouteOutboundMessageException(message, (UMOEndpoint) endpoints.get(0), e);
 93  0
         }
 94  0
         return result;
 95  
     }
 96  
 }