Coverage Report - org.mule.transport.multicast.MulticastConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
MulticastConnector
0%
0/17
N/A
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport.multicast;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.construct.FlowConstruct;
 11  
 import org.mule.api.endpoint.InboundEndpoint;
 12  
 import org.mule.api.lifecycle.InitialisationException;
 13  
 import org.mule.transport.udp.UdpConnector;
 14  
 
 15  
 /**
 16  
  * <code>MulticastConnector</code> can dispatch mule events using ip multicasting
 17  
  */
 18  
 public class MulticastConnector extends UdpConnector
 19  
 {
 20  
 
 21  
     public static final String MULTICAST = "multicast";
 22  0
     private boolean loopback = false;
 23  0
     private int timeToLive = INT_VALUE_NOT_SET;
 24  
 
 25  
     public String getProtocol()
 26  
     {
 27  0
         return MULTICAST;
 28  
     }
 29  
 
 30  
     public MulticastConnector(MuleContext context)
 31  
     {
 32  0
         super(context);
 33  0
     }
 34  
 
 35  
     @Override
 36  
     protected void doInitialise() throws InitialisationException
 37  
     {
 38  0
         socketFactory = new MulticastSocketFactory();
 39  0
         dispatcherSocketsPool.setFactory(socketFactory);
 40  0
         dispatcherSocketsPool.setTestOnBorrow(false);
 41  0
         dispatcherSocketsPool.setTestOnReturn(true);
 42  
         //For clarity, note that the max active value does not need to be 1 since you can have multiple
 43  
         //Multicast sockets bound to a single port
 44  
         //dispatcherSocketsPool.setMaxActive(1);
 45  0
     }
 46  
 
 47  
     public boolean isLoopback()
 48  
     {
 49  0
         return loopback;
 50  
     }
 51  
 
 52  
     public void setLoopback(boolean loopback)
 53  
     {
 54  0
         this.loopback = loopback;
 55  0
     }
 56  
 
 57  
 
 58  
     public int getTimeToLive()
 59  
     {
 60  0
         return timeToLive;
 61  
     }
 62  
 
 63  
     public void setTimeToLive(int timeToLive)
 64  
     {
 65  0
         this.timeToLive = timeToLive;
 66  0
     }
 67  
 
 68  
 
 69  
     @Override
 70  
     protected Object getReceiverKey(FlowConstruct flowConstruct, InboundEndpoint endpoint)
 71  
     {
 72  
         //you can have multiple Multicast sockets bound to a single port,
 73  
         // so store listeners with the service name too
 74  0
         return endpoint.getEndpointURI().getAddress() + "/" + flowConstruct.getName();
 75  
     }
 76  
 }