1 package org.apache.commons.jcs.auxiliary.remote;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheAttributes;
23 import org.apache.commons.jcs.auxiliary.remote.behavior.ICommonRemoteCacheAttributes;
24 import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
25 import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType;
26
27
28
29
30 public class CommonRemoteCacheAttributes
31 extends AbstractAuxiliaryCacheAttributes
32 implements ICommonRemoteCacheAttributes
33 {
34
35 private static final long serialVersionUID = -1555143736942374000L;
36
37
38 private String remoteServiceName = IRemoteCacheConstants.REMOTE_CACHE_SERVICE_VAL;
39
40
41 private RemoteLocation location;
42
43
44 private String clusterServers = "";
45
46
47 private RemoteType remoteType = RemoteType.LOCAL;
48
49
50 private boolean removeUponRemotePut = true;
51
52
53 private boolean getOnly = false;
54
55
56 private boolean localClusterConsistency = false;
57
58
59 private int rmiSocketFactoryTimeoutMillis = DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT_MILLIS;
60
61
62 public CommonRemoteCacheAttributes()
63 {
64 super();
65 }
66
67
68
69
70
71
72 @Override
73 public String getRemoteTypeName()
74 {
75 return remoteType != null ? remoteType.toString() : RemoteType.LOCAL.toString();
76 }
77
78
79
80
81
82
83 @Override
84 public void setRemoteTypeName( String s )
85 {
86 RemoteType rt = RemoteType.valueOf(s);
87 if (rt != null)
88 {
89 this.remoteType = rt;
90 }
91 }
92
93
94
95
96
97
98 @Override
99 public RemoteType getRemoteType()
100 {
101 return remoteType;
102 }
103
104
105
106
107
108
109 @Override
110 public void setRemoteType( RemoteType p )
111 {
112 this.remoteType = p;
113 }
114
115
116
117
118
119
120 @Override
121 public String getRemoteServiceName()
122 {
123 return this.remoteServiceName;
124 }
125
126
127
128
129
130
131 @Override
132 public void setRemoteServiceName( String s )
133 {
134 this.remoteServiceName = s;
135 }
136
137
138
139
140
141
142 @Override
143 public void setRemoteLocation( RemoteLocation location )
144 {
145 this.location = location;
146 }
147
148
149
150
151
152
153
154 @Override
155 public void setRemoteLocation( String host, int port )
156 {
157 this.location = new RemoteLocation(host, port);
158 }
159
160
161
162
163
164
165 @Override
166 public RemoteLocation getRemoteLocation()
167 {
168 return this.location;
169 }
170
171
172
173
174
175
176 @Override
177 public String getClusterServers()
178 {
179 return this.clusterServers;
180 }
181
182
183
184
185
186
187 @Override
188 public void setClusterServers( String s )
189 {
190 this.clusterServers = s;
191 }
192
193
194
195
196
197
198 @Override
199 public boolean getRemoveUponRemotePut()
200 {
201 return this.removeUponRemotePut;
202 }
203
204
205
206
207
208
209 @Override
210 public void setRemoveUponRemotePut( boolean r )
211 {
212 this.removeUponRemotePut = r;
213 }
214
215
216
217
218
219
220 @Override
221 public boolean getGetOnly()
222 {
223 return this.getOnly;
224 }
225
226
227
228
229
230 @Override
231 public void setGetOnly( boolean r )
232 {
233 this.getOnly = r;
234 }
235
236
237
238
239
240
241 @Override
242 public boolean isLocalClusterConsistency()
243 {
244 return localClusterConsistency;
245 }
246
247
248
249
250
251
252 @Override
253 public void setLocalClusterConsistency( boolean r )
254 {
255 this.localClusterConsistency = r;
256 }
257
258
259
260
261 @Override
262 public void setRmiSocketFactoryTimeoutMillis( int rmiSocketFactoryTimeoutMillis )
263 {
264 this.rmiSocketFactoryTimeoutMillis = rmiSocketFactoryTimeoutMillis;
265 }
266
267
268
269
270 @Override
271 public int getRmiSocketFactoryTimeoutMillis()
272 {
273 return rmiSocketFactoryTimeoutMillis;
274 }
275
276
277
278
279 @Override
280 public String toString()
281 {
282 StringBuilder buf = new StringBuilder();
283 buf.append( "\n RemoteCacheAttributes " );
284 if (this.location != null)
285 {
286 buf.append( "\n remoteHost = [" + this.location.getHost() + "]" );
287 buf.append( "\n remotePort = [" + this.location.getPort() + "]" );
288 }
289 buf.append( "\n cacheName = [" + getCacheName() + "]" );
290 buf.append( "\n remoteType = [" + remoteType + "]" );
291 buf.append( "\n removeUponRemotePut = [" + this.removeUponRemotePut + "]" );
292 buf.append( "\n getOnly = [" + getOnly + "]" );
293 return buf.toString();
294 }
295 }