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