1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| package org.jboss.cache.config; |
23 |
| |
24 |
| import org.apache.commons.logging.LogFactory; |
25 |
| import org.jboss.cache.Fqn; |
26 |
| |
27 |
| public class EvictionRegionConfig extends ConfigurationComponent |
28 |
| { |
29 |
| |
30 |
| |
31 |
| |
32 |
| private static final long serialVersionUID = -5482474634995601400L; |
33 |
| |
34 |
| public static final String NAME = "name"; |
35 |
| public static final String REGION = "region"; |
36 |
| public static final String REGION_POLICY_CLASS = "policyClass"; |
37 |
| public static final String EVENT_QUEUE_SIZE = "eventQueueSize"; |
38 |
| |
39 |
| private Fqn regionFqn; |
40 |
| @Dynamic |
41 |
| private Integer eventQueueSize; |
42 |
| private EvictionPolicyConfig evictionPolicyConfig; |
43 |
| |
44 |
4589
| public EvictionRegionConfig()
|
45 |
| { |
46 |
| } |
47 |
| |
48 |
1421846
| public EvictionPolicyConfig getEvictionPolicyConfig()
|
49 |
| { |
50 |
1421846
| return evictionPolicyConfig;
|
51 |
| } |
52 |
| |
53 |
4270
| public void setEvictionPolicyConfig(EvictionPolicyConfig config)
|
54 |
| { |
55 |
4270
| testImmutability("evictionPolicyConfig");
|
56 |
4270
| if (this.evictionPolicyConfig instanceof ConfigurationComponent)
|
57 |
| { |
58 |
12
| removeChildConfig((ConfigurationComponent) this.evictionPolicyConfig);
|
59 |
| } |
60 |
4270
| if (config instanceof ConfigurationComponent)
|
61 |
| { |
62 |
4202
| addChildConfig((ConfigurationComponent) config);
|
63 |
| } |
64 |
4270
| if (config != null)
|
65 |
4270
| config.validate();
|
66 |
| |
67 |
4270
| this.evictionPolicyConfig = config;
|
68 |
| } |
69 |
| |
70 |
1135
| public Fqn getRegionFqn()
|
71 |
| { |
72 |
1135
| return regionFqn;
|
73 |
| } |
74 |
| |
75 |
3040
| public void setRegionFqn(Fqn regionFqn)
|
76 |
| { |
77 |
3040
| testImmutability("regionFqn");
|
78 |
3040
| this.regionFqn = regionFqn;
|
79 |
| } |
80 |
| |
81 |
8
| public String getRegionName()
|
82 |
| { |
83 |
8
| return regionFqn == null ? null : regionFqn.toString();
|
84 |
| } |
85 |
| |
86 |
3036
| public void setRegionName(String name)
|
87 |
| { |
88 |
3036
| setRegionFqn(name == null ? null : Fqn.fromString(name));
|
89 |
| } |
90 |
| |
91 |
5337
| public int getEventQueueSize()
|
92 |
| { |
93 |
5337
| return eventQueueSize == null ? EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT : eventQueueSize;
|
94 |
| } |
95 |
| |
96 |
3036
| public void setEventQueueSize(int queueSize)
|
97 |
| { |
98 |
3036
| testImmutability("eventQueueSize");
|
99 |
3036
| if (queueSize <= 0)
|
100 |
| { |
101 |
0
| LogFactory.getLog(EvictionRegionConfig.class).warn("Ignoring invalid queue capacity " +
|
102 |
| queueSize + " -- using " + |
103 |
| EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT); |
104 |
0
| queueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
|
105 |
| } |
106 |
3036
| this.eventQueueSize = queueSize;
|
107 |
| } |
108 |
| |
109 |
3031
| public void setDefaultEventQueueSize(int queueSize)
|
110 |
| { |
111 |
3031
| if (eventQueueSize == null)
|
112 |
0
| setEventQueueSize(queueSize);
|
113 |
| } |
114 |
| |
115 |
| |
116 |
0
| @Override
|
117 |
| public boolean equals(Object obj) |
118 |
| { |
119 |
0
| if (this == obj)
|
120 |
0
| return true;
|
121 |
| |
122 |
0
| if (obj instanceof EvictionRegionConfig)
|
123 |
| { |
124 |
0
| EvictionRegionConfig other = (EvictionRegionConfig) obj;
|
125 |
0
| return safeEquals(this.regionFqn, other.regionFqn);
|
126 |
| } |
127 |
0
| return false;
|
128 |
| } |
129 |
| |
130 |
3031
| @Override
|
131 |
| public int hashCode() |
132 |
| { |
133 |
3031
| int result = 17;
|
134 |
3031
| result = 31 * result + (regionFqn == null ? 0 : regionFqn.hashCode());
|
135 |
| |
136 |
3031
| return result;
|
137 |
| } |
138 |
| |
139 |
| |
140 |
| } |