KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > loader > AsynchCacheLoaderConfig


1 package org.jboss.cache.loader;
2
3 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
4
5 import java.util.Properties JavaDoc;
6
7 public class AsynchCacheLoaderConfig extends IndividualCacheLoaderConfig
8 {
9    /**
10     * The serialVersionUID
11     */

12    private static final long serialVersionUID = 5038037589485991681L;
13
14    private int batchSize = 100;
15    private int pollWait = 100;
16    private boolean returnOld = true;
17    private int queueSize = 0;
18    private boolean useAsyncPut = true;
19
20    /**
21     * Default constructor.
22     */

23    public AsynchCacheLoaderConfig()
24    {
25       setClassName(AsyncCacheLoader.class.getName());
26    }
27
28    /**
29     * For use by {@link AsynchCacheLoader}.
30     *
31     * @param base generic config object created by XML parsing.
32     */

33    AsynchCacheLoaderConfig(IndividualCacheLoaderConfig base)
34    {
35       setClassName(AsyncCacheLoader.class.getName());
36       populateFromBaseConfig(base);
37    }
38
39    public int getBatchSize()
40    {
41       return batchSize;
42    }
43
44    public void setBatchSize(int batchSize)
45    {
46       testImmutability("batchSize");
47       this.batchSize = batchSize;
48    }
49
50    public int getPollWait()
51    {
52       return pollWait;
53    }
54
55    public void setPollWait(int pollWait)
56    {
57       testImmutability("pollWait");
58       this.pollWait = pollWait;
59    }
60
61    public int getQueueSize()
62    {
63       return queueSize;
64    }
65
66    public void setQueueSize(int queueSize)
67    {
68       testImmutability("queueSize");
69       this.queueSize = queueSize;
70    }
71
72    public boolean getReturnOld()
73    {
74       return returnOld;
75    }
76
77    public void setReturnOld(boolean returnOld)
78    {
79       testImmutability("returnOld");
80       this.returnOld = returnOld;
81    }
82
83    public boolean getUseAsyncPut()
84    {
85       return useAsyncPut;
86    }
87
88    public void setUseAsyncPut(boolean useAsyncPut)
89    {
90       testImmutability("useAsyncPut");
91       this.useAsyncPut = useAsyncPut;
92    }
93
94    public void setProperties(Properties JavaDoc props)
95    {
96       super.setProperties(props);
97       String JavaDoc s;
98
99       s = props.getProperty("cache.async.batchSize");
100       if (s != null)
101       {
102          batchSize = Integer.parseInt(s);
103       }
104       if (batchSize <= 0)
105       {
106          throw new IllegalArgumentException JavaDoc("Invalid size: " + batchSize);
107       }
108
109       s = props.getProperty("cache.async.pollWait");
110       if (s != null)
111       {
112          pollWait = Integer.parseInt(s);
113       }
114
115       s = props.getProperty("cache.async.returnOld");
116       if (s != null)
117       {
118          returnOld = Boolean.valueOf(s);
119       }
120
121       s = props.getProperty("cache.async.queueSize");
122       if (s != null)
123       {
124          queueSize = Integer.parseInt(s);
125       }
126
127       s = props.getProperty("cache.async.put");
128       if (s != null)
129       {
130          useAsyncPut = Boolean.valueOf(s);
131       }
132    }
133
134    public boolean equals(Object JavaDoc obj)
135    {
136       if (obj instanceof AsynchCacheLoaderConfig && equalsExcludingProperties(obj))
137       {
138          AsynchCacheLoaderConfig other = (AsynchCacheLoaderConfig) obj;
139          return (batchSize == other.batchSize)
140                  && (pollWait == other.pollWait)
141                  && (queueSize == other.queueSize)
142                  && (returnOld == other.returnOld)
143                  && (useAsyncPut == other.useAsyncPut);
144       }
145       return false;
146    }
147
148    public int hashCode()
149    {
150       int result = hashCodeExcludingProperties();
151       result = 31 * result + batchSize;
152       result = 31 * result + pollWait;
153       result = 31 * result + queueSize;
154       result = 31 * result + (returnOld ? 0 : 1);
155       result = 31 * result + (useAsyncPut ? 0 : 1);
156       return result;
157    }
158
159
160 }
Popular Tags