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 | 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 | |
|
43 | |
|
44 | |
|
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 | |
|
73 | |
|
74 | 0 | return endpoint.getEndpointURI().getAddress() + "/" + flowConstruct.getName(); |
75 | |
} |
76 | |
} |