1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.eviction; |
8 |
| |
9 |
| import org.jboss.cache.config.ConfigurationException; |
10 |
| import org.jboss.cache.config.Dynamic; |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| public class ElementSizeConfiguration extends EvictionPolicyConfigBase |
32 |
| { |
33 |
| |
34 |
| private static final long serialVersionUID = 2510593544656833758L; |
35 |
| |
36 |
| @Dynamic |
37 |
| private int maxElementsPerNode; |
38 |
| |
39 |
17
| public ElementSizeConfiguration()
|
40 |
| { |
41 |
17
| super();
|
42 |
| |
43 |
17
| setMaxElementsPerNode(-1);
|
44 |
| } |
45 |
| |
46 |
32
| @Override
|
47 |
| protected void setEvictionPolicyClassName() |
48 |
| { |
49 |
32
| setEvictionPolicyClass(ElementSizePolicy.class.getName());
|
50 |
| } |
51 |
| |
52 |
18
| public int getMaxElementsPerNode()
|
53 |
| { |
54 |
18
| return maxElementsPerNode;
|
55 |
| } |
56 |
| |
57 |
50
| public void setMaxElementsPerNode(int maxElementsPerNode)
|
58 |
| { |
59 |
50
| testImmutability("maxElementsPerNode");
|
60 |
50
| this.maxElementsPerNode = maxElementsPerNode;
|
61 |
| } |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
45
| @Override
|
68 |
| public void validate() throws ConfigurationException |
69 |
| { |
70 |
45
| if (maxElementsPerNode < 0)
|
71 |
| { |
72 |
1
| throw new ConfigurationException("maxElementsPerNode must be must be " +
|
73 |
| "configured to a value greater than or equal to 0"); |
74 |
| } |
75 |
| } |
76 |
| |
77 |
0
| public String toString()
|
78 |
| { |
79 |
0
| StringBuffer str = new StringBuffer();
|
80 |
0
| str.append("ElementSizeConfiguration: maxElementsPerNode =");
|
81 |
0
| str.append(getMaxElementsPerNode()).append(" maxNodes =").append(getMaxNodes());
|
82 |
0
| return str.toString();
|
83 |
| } |
84 |
| |
85 |
0
| @Override
|
86 |
| public boolean equals(Object obj) |
87 |
| { |
88 |
0
| if (this == obj)
|
89 |
0
| return true;
|
90 |
0
| if (obj instanceof ElementSizeConfiguration && super.equals(obj))
|
91 |
| { |
92 |
0
| return this.maxElementsPerNode == ((ElementSizeConfiguration) obj).maxElementsPerNode;
|
93 |
| } |
94 |
0
| return false;
|
95 |
| } |
96 |
| |
97 |
30
| @Override
|
98 |
| public int hashCode() |
99 |
| { |
100 |
30
| int result = super.hashCode();
|
101 |
30
| result = 31 * result + maxElementsPerNode;
|
102 |
30
| return result;
|
103 |
| } |
104 |
| |
105 |
15
| @Override
|
106 |
| public void reset() |
107 |
| { |
108 |
15
| super.reset();
|
109 |
15
| setMaxElementsPerNode(-1);
|
110 |
| } |
111 |
| } |