1 |
| package org.jboss.cache.loader; |
2 |
| |
3 |
| import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig; |
4 |
| |
5 |
| import java.util.Properties; |
6 |
| |
7 |
| public class AsyncCacheLoaderConfig extends IndividualCacheLoaderConfig |
8 |
| { |
9 |
| |
10 |
| |
11 |
| |
12 |
| private static final long serialVersionUID = 5038037589485991681L; |
13 |
| |
14 |
| private int batchSize = 100; |
15 |
| private boolean returnOld = true; |
16 |
| private int queueSize = 0; |
17 |
| private boolean useAsyncPut = true; |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
0
| public AsyncCacheLoaderConfig()
|
23 |
| { |
24 |
0
| setClassName(AsyncCacheLoader.class.getName());
|
25 |
| } |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
21
| AsyncCacheLoaderConfig(IndividualCacheLoaderConfig base)
|
33 |
| { |
34 |
21
| setClassName(AsyncCacheLoader.class.getName());
|
35 |
21
| populateFromBaseConfig(base);
|
36 |
| } |
37 |
| |
38 |
80
| public int getBatchSize()
|
39 |
| { |
40 |
80
| return batchSize;
|
41 |
| } |
42 |
| |
43 |
0
| public void setBatchSize(int batchSize)
|
44 |
| { |
45 |
0
| testImmutability("batchSize");
|
46 |
0
| this.batchSize = batchSize;
|
47 |
| } |
48 |
| |
49 |
22
| public int getQueueSize()
|
50 |
| { |
51 |
22
| return queueSize;
|
52 |
| } |
53 |
| |
54 |
0
| public void setQueueSize(int queueSize)
|
55 |
| { |
56 |
0
| testImmutability("queueSize");
|
57 |
0
| this.queueSize = queueSize;
|
58 |
| } |
59 |
| |
60 |
67
| public boolean getReturnOld()
|
61 |
| { |
62 |
67
| return returnOld;
|
63 |
| } |
64 |
| |
65 |
0
| public void setReturnOld(boolean returnOld)
|
66 |
| { |
67 |
0
| testImmutability("returnOld");
|
68 |
0
| this.returnOld = returnOld;
|
69 |
| } |
70 |
| |
71 |
69
| public boolean getUseAsyncPut()
|
72 |
| { |
73 |
69
| return useAsyncPut;
|
74 |
| } |
75 |
| |
76 |
0
| public void setUseAsyncPut(boolean useAsyncPut)
|
77 |
| { |
78 |
0
| testImmutability("useAsyncPut");
|
79 |
0
| this.useAsyncPut = useAsyncPut;
|
80 |
| } |
81 |
| |
82 |
21
| public void setProperties(Properties props)
|
83 |
| { |
84 |
21
| super.setProperties(props);
|
85 |
21
| String s;
|
86 |
| |
87 |
21
| s = props.getProperty("cache.async.batchSize");
|
88 |
21
| if (s != null)
|
89 |
| { |
90 |
0
| batchSize = Integer.parseInt(s);
|
91 |
| } |
92 |
21
| if (batchSize <= 0)
|
93 |
| { |
94 |
0
| throw new IllegalArgumentException("Invalid size: " + batchSize);
|
95 |
| } |
96 |
| |
97 |
21
| s = props.getProperty("cache.async.returnOld");
|
98 |
21
| if (s != null)
|
99 |
| { |
100 |
1
| returnOld = Boolean.valueOf(s);
|
101 |
| } |
102 |
| |
103 |
21
| s = props.getProperty("cache.async.queueSize");
|
104 |
21
| if (s != null)
|
105 |
| { |
106 |
1
| queueSize = Integer.parseInt(s);
|
107 |
| } |
108 |
| |
109 |
21
| s = props.getProperty("cache.async.put");
|
110 |
21
| if (s != null)
|
111 |
| { |
112 |
1
| useAsyncPut = Boolean.valueOf(s);
|
113 |
| } |
114 |
| } |
115 |
| |
116 |
0
| public boolean equals(Object obj)
|
117 |
| { |
118 |
0
| if (obj instanceof AsyncCacheLoaderConfig && equalsExcludingProperties(obj))
|
119 |
| { |
120 |
0
| AsyncCacheLoaderConfig other = (AsyncCacheLoaderConfig) obj;
|
121 |
0
| return (batchSize == other.batchSize)
|
122 |
| && (queueSize == other.queueSize) |
123 |
| && (returnOld == other.returnOld) |
124 |
| && (useAsyncPut == other.useAsyncPut); |
125 |
| } |
126 |
0
| return false;
|
127 |
| } |
128 |
| |
129 |
0
| public int hashCode()
|
130 |
| { |
131 |
0
| int result = hashCodeExcludingProperties();
|
132 |
0
| result = 31 * result + batchSize;
|
133 |
0
| result = 31 * result + queueSize;
|
134 |
0
| result = 31 * result + (returnOld ? 0 : 1);
|
135 |
0
| result = 31 * result + (useAsyncPut ? 0 : 1);
|
136 |
0
| return result;
|
137 |
| } |
138 |
| |
139 |
| |
140 |
| } |