1 package org.apache.commons.jcs.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
29 public final class UDPDiscoveryAttributes
30 implements Cloneable
31 {
32
33 private String serviceName;
34
35
36 private String serviceAddress;
37
38
39 private int servicePort;
40
41
42
43
44 private boolean isDark;
45
46
47 private static final String DEFAULT_UDP_DISCOVERY_ADDRESS = "228.4.5.6";
48
49
50 private static final int DEFAULT_UDP_DISCOVERY_PORT = 5678;
51
52
53 private String udpDiscoveryAddr = DEFAULT_UDP_DISCOVERY_ADDRESS;
54
55
56 private int udpDiscoveryPort = DEFAULT_UDP_DISCOVERY_PORT;
57
58
59 private static final int DEFAULT_SEND_DELAY_SEC = 60;
60
61
62 private int sendDelaySec = DEFAULT_SEND_DELAY_SEC;
63
64
65 private static final int DEFAULT_MAX_IDLE_TIME_SEC = 180;
66
67
68 private int maxIdleTimeSec = DEFAULT_MAX_IDLE_TIME_SEC;
69
70
71
72
73 public void setServiceName( String serviceName )
74 {
75 this.serviceName = serviceName;
76 }
77
78
79
80
81 public String getServiceName()
82 {
83 return serviceName;
84 }
85
86
87
88
89 public void setServiceAddress( String serviceAddress )
90 {
91 this.serviceAddress = serviceAddress;
92 }
93
94
95
96
97 public String getServiceAddress()
98 {
99 return serviceAddress;
100 }
101
102
103
104
105 public void setServicePort( int servicePort )
106 {
107 this.servicePort = servicePort;
108 }
109
110
111
112
113 public int getServicePort()
114 {
115 return servicePort;
116 }
117
118
119
120
121 public void setUdpDiscoveryAddr( String udpDiscoveryAddr )
122 {
123 this.udpDiscoveryAddr = udpDiscoveryAddr;
124 }
125
126
127
128
129 public String getUdpDiscoveryAddr()
130 {
131 return udpDiscoveryAddr;
132 }
133
134
135
136
137 public void setUdpDiscoveryPort( int udpDiscoveryPort )
138 {
139 this.udpDiscoveryPort = udpDiscoveryPort;
140 }
141
142
143
144
145 public int getUdpDiscoveryPort()
146 {
147 return udpDiscoveryPort;
148 }
149
150
151
152
153 public void setSendDelaySec( int sendDelaySec )
154 {
155 this.sendDelaySec = sendDelaySec;
156 }
157
158
159
160
161 public int getSendDelaySec()
162 {
163 return sendDelaySec;
164 }
165
166
167
168
169 public void setMaxIdleTimeSec( int maxIdleTimeSec )
170 {
171 this.maxIdleTimeSec = maxIdleTimeSec;
172 }
173
174
175
176
177 public int getMaxIdleTimeSec()
178 {
179 return maxIdleTimeSec;
180 }
181
182
183
184
185 public boolean isDark()
186 {
187 return isDark;
188 }
189
190
191
192
193 public void setDark( boolean isDark )
194 {
195 this.isDark = isDark;
196 }
197
198
199 @Override
200 public UDPDiscoveryAttributes clone()
201 {
202 UDPDiscoveryAttributes attributes = new UDPDiscoveryAttributes();
203 attributes.setSendDelaySec( this.getSendDelaySec() );
204 attributes.setMaxIdleTimeSec( this.getMaxIdleTimeSec() );
205 attributes.setServiceName( this.getServiceName() );
206 attributes.setServicePort( this.getServicePort() );
207 attributes.setUdpDiscoveryAddr( this.getUdpDiscoveryAddr() );
208 attributes.setUdpDiscoveryPort( this.getUdpDiscoveryPort() );
209 attributes.setDark( this.isDark() );
210 return attributes;
211 }
212
213
214
215
216 @Override
217 public String toString()
218 {
219 StringBuilder buf = new StringBuilder();
220 buf.append( "\n UDPDiscoveryAttributes" );
221 buf.append( "\n ServiceName = [" + getServiceName() + "]" );
222 buf.append( "\n ServiceAddress = [" + getServiceAddress() + "]" );
223 buf.append( "\n ServicePort = [" + getServicePort() + "]" );
224 buf.append( "\n UdpDiscoveryAddr = [" + getUdpDiscoveryAddr() + "]" );
225 buf.append( "\n UdpDiscoveryPort = [" + getUdpDiscoveryPort() + "]" );
226 buf.append( "\n SendDelaySec = [" + getSendDelaySec() + "]" );
227 buf.append( "\n MaxIdleTimeSec = [" + getMaxIdleTimeSec() + "]" );
228 buf.append( "\n IsDark = [" + isDark() + "]" );
229 return buf.toString();
230 }
231 }