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 |
| public class LRUConfiguration extends EvictionPolicyConfigBase |
29 |
| { |
30 |
| |
31 |
| private static final long serialVersionUID = -3426716488271559729L; |
32 |
| |
33 |
| @Dynamic |
34 |
| private int timeToLiveSeconds; |
35 |
| @Dynamic |
36 |
| private int maxAgeSeconds; |
37 |
| |
38 |
2985
| public LRUConfiguration()
|
39 |
| { |
40 |
2985
| super();
|
41 |
| |
42 |
2985
| setTimeToLiveSeconds(-1);
|
43 |
| } |
44 |
| |
45 |
5961
| @Override
|
46 |
| protected void setEvictionPolicyClassName() |
47 |
| { |
48 |
5961
| setEvictionPolicyClass(LRUPolicy.class.getName());
|
49 |
| } |
50 |
| |
51 |
| |
52 |
19187
| public int getTimeToLiveSeconds()
|
53 |
| { |
54 |
19187
| return timeToLiveSeconds;
|
55 |
| } |
56 |
| |
57 |
8954
| public void setTimeToLiveSeconds(int timeToLiveSeconds)
|
58 |
| { |
59 |
8954
| testImmutability("timeToLiveSeconds");
|
60 |
8954
| this.timeToLiveSeconds = timeToLiveSeconds;
|
61 |
| } |
62 |
| |
63 |
517
| public int getMaxAgeSeconds()
|
64 |
| { |
65 |
517
| return maxAgeSeconds;
|
66 |
| } |
67 |
| |
68 |
39
| public void setMaxAgeSeconds(int maxAgeSeconds)
|
69 |
| { |
70 |
39
| testImmutability("maxAgeSeconds");
|
71 |
39
| this.maxAgeSeconds = maxAgeSeconds;
|
72 |
| } |
73 |
| |
74 |
| |
75 |
| |
76 |
| |
77 |
| |
78 |
7018
| @Override
|
79 |
| public void validate() throws ConfigurationException |
80 |
| { |
81 |
7018
| if (timeToLiveSeconds < 0)
|
82 |
| { |
83 |
1
| throw new ConfigurationException("timeToLiveSeconds must be " +
|
84 |
| "configured to a value greater than or equal to 0"); |
85 |
| } |
86 |
| } |
87 |
| |
88 |
0
| public String toString()
|
89 |
| { |
90 |
0
| StringBuffer str = new StringBuffer();
|
91 |
0
| str.append("LRUConfiguration: timeToLiveSeconds = ").append(getTimeToLiveSeconds()).append(" maxAgeSeconds =");
|
92 |
0
| str.append(getMaxAgeSeconds()).append(" maxNodes =").append(getMaxNodes());
|
93 |
0
| return str.toString();
|
94 |
| } |
95 |
| |
96 |
0
| @Override
|
97 |
| public boolean equals(Object obj) |
98 |
| { |
99 |
0
| if (obj instanceof LRUConfiguration && super.equals(obj))
|
100 |
| { |
101 |
0
| LRUConfiguration other = (LRUConfiguration) obj;
|
102 |
0
| return maxAgeSeconds == other.maxAgeSeconds
|
103 |
| && timeToLiveSeconds == other.timeToLiveSeconds; |
104 |
| } |
105 |
0
| return false;
|
106 |
| } |
107 |
| |
108 |
4052
| @Override
|
109 |
| public int hashCode() |
110 |
| { |
111 |
4052
| int result = super.hashCode();
|
112 |
4052
| result = 31 * result + maxAgeSeconds;
|
113 |
4052
| result = 31 * result + timeToLiveSeconds;
|
114 |
4052
| return result;
|
115 |
| } |
116 |
| |
117 |
2976
| @Override
|
118 |
| public void reset() |
119 |
| { |
120 |
2976
| super.reset();
|
121 |
2976
| setTimeToLiveSeconds(-1);
|
122 |
| } |
123 |
| |
124 |
| } |