1
2
3
4
5
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
17
18 public class MulticastConnector extends UdpConnector
19 {
20
21 public static final String MULTICAST = "multicast";
22 private boolean loopback = false;
23 private int timeToLive = INT_VALUE_NOT_SET;
24
25 public String getProtocol()
26 {
27 return MULTICAST;
28 }
29
30 public MulticastConnector(MuleContext context)
31 {
32 super(context);
33 }
34
35 @Override
36 protected void doInitialise() throws InitialisationException
37 {
38 socketFactory = new MulticastSocketFactory();
39 dispatcherSocketsPool.setFactory(socketFactory);
40 dispatcherSocketsPool.setTestOnBorrow(false);
41 dispatcherSocketsPool.setTestOnReturn(true);
42
43
44
45 }
46
47 public boolean isLoopback()
48 {
49 return loopback;
50 }
51
52 public void setLoopback(boolean loopback)
53 {
54 this.loopback = loopback;
55 }
56
57
58 public int getTimeToLive()
59 {
60 return timeToLive;
61 }
62
63 public void setTimeToLive(int timeToLive)
64 {
65 this.timeToLive = timeToLive;
66 }
67
68
69 @Override
70 protected Object getReceiverKey(FlowConstruct flowConstruct, InboundEndpoint endpoint)
71 {
72
73
74 return endpoint.getEndpointURI().getAddress() + "/" + flowConstruct.getName();
75 }
76 }