1 package org.apache.commons.jcs3.utils.discovery;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public final class UDPDiscoveryAttributes
29 implements Cloneable
30 {
31
32 private String serviceName;
33
34
35 private String serviceAddress;
36
37
38 private int servicePort;
39
40
41
42
43 private boolean isDark;
44
45
46 private static final String DEFAULT_UDP_DISCOVERY_ADDRESS = "228.4.5.6";
47
48
49 private static final int DEFAULT_UDP_DISCOVERY_PORT = 5678;
50
51
52 private String udpDiscoveryAddr = DEFAULT_UDP_DISCOVERY_ADDRESS;
53
54
55 private String udpDiscoveryInterface;
56
57
58 private int udpDiscoveryPort = DEFAULT_UDP_DISCOVERY_PORT;
59
60
61 private int udpTTL;
62
63
64 private static final int DEFAULT_SEND_DELAY_SEC = 60;
65
66
67 private int sendDelaySec = DEFAULT_SEND_DELAY_SEC;
68
69
70 private static final int DEFAULT_MAX_IDLE_TIME_SEC = 180;
71
72
73 private int maxIdleTimeSec = DEFAULT_MAX_IDLE_TIME_SEC;
74
75
76
77
78 public void setServiceName( final String serviceName )
79 {
80 this.serviceName = serviceName;
81 }
82
83
84
85
86 public String getServiceName()
87 {
88 return serviceName;
89 }
90
91
92
93
94 public void setServiceAddress( final String serviceAddress )
95 {
96 this.serviceAddress = serviceAddress;
97 }
98
99
100
101
102 public String getServiceAddress()
103 {
104 return serviceAddress;
105 }
106
107
108
109
110 public void setServicePort( final int servicePort )
111 {
112 this.servicePort = servicePort;
113 }
114
115
116
117
118 public int getServicePort()
119 {
120 return servicePort;
121 }
122
123
124
125
126 public void setUdpDiscoveryAddr( final String udpDiscoveryAddr )
127 {
128 this.udpDiscoveryAddr = udpDiscoveryAddr;
129 }
130
131
132
133
134 public String getUdpDiscoveryAddr()
135 {
136 return udpDiscoveryAddr;
137 }
138
139
140
141
142 public void setUdpDiscoveryInterface( final String udpDiscoveryInterface )
143 {
144 this.udpDiscoveryInterface = udpDiscoveryInterface;
145 }
146
147
148
149
150 public String getUdpDiscoveryInterface()
151 {
152 return udpDiscoveryInterface;
153 }
154
155
156
157
158 public void setUdpDiscoveryPort( final int udpDiscoveryPort )
159 {
160 this.udpDiscoveryPort = udpDiscoveryPort;
161 }
162
163
164
165
166 public int getUdpTTL()
167 {
168 return udpTTL;
169 }
170
171
172
173
174 public void setUdpTTL( final int udpTTL )
175 {
176 this.udpTTL = udpTTL;
177 }
178
179
180
181
182 public int getUdpDiscoveryPort()
183 {
184 return udpDiscoveryPort;
185 }
186
187
188
189
190 public void setSendDelaySec( final int sendDelaySec )
191 {
192 this.sendDelaySec = sendDelaySec;
193 }
194
195
196
197
198 public int getSendDelaySec()
199 {
200 return sendDelaySec;
201 }
202
203
204
205
206 public void setMaxIdleTimeSec( final int maxIdleTimeSec )
207 {
208 this.maxIdleTimeSec = maxIdleTimeSec;
209 }
210
211
212
213
214 public int getMaxIdleTimeSec()
215 {
216 return maxIdleTimeSec;
217 }
218
219
220
221
222 public boolean isDark()
223 {
224 return isDark;
225 }
226
227
228
229
230 public void setDark( final boolean isDark )
231 {
232 this.isDark = isDark;
233 }
234
235
236 @Override
237 public UDPDiscoveryAttributes clone()
238 {
239 final UDPDiscoveryAttributes attributes = new UDPDiscoveryAttributes();
240 attributes.setSendDelaySec( this.getSendDelaySec() );
241 attributes.setMaxIdleTimeSec( this.getMaxIdleTimeSec() );
242 attributes.setServiceName( this.getServiceName() );
243 attributes.setServicePort( this.getServicePort() );
244 attributes.setUdpDiscoveryAddr( this.getUdpDiscoveryAddr() );
245 attributes.setUdpDiscoveryPort( this.getUdpDiscoveryPort() );
246 attributes.setDark( this.isDark() );
247 return attributes;
248 }
249
250
251
252
253 @Override
254 public String toString()
255 {
256 final StringBuilder buf = new StringBuilder();
257 buf.append( "\n UDPDiscoveryAttributes" );
258 buf.append( "\n ServiceName = [" + getServiceName() + "]" );
259 buf.append( "\n ServiceAddress = [" + getServiceAddress() + "]" );
260 buf.append( "\n ServicePort = [" + getServicePort() + "]" );
261 buf.append( "\n UdpDiscoveryAddr = [" + getUdpDiscoveryAddr() + "]" );
262 buf.append( "\n UdpDiscoveryPort = [" + getUdpDiscoveryPort() + "]" );
263 buf.append( "\n SendDelaySec = [" + getSendDelaySec() + "]" );
264 buf.append( "\n MaxIdleTimeSec = [" + getMaxIdleTimeSec() + "]" );
265 buf.append( "\n IsDark = [" + isDark() + "]" );
266 return buf.toString();
267 }
268 }