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