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