KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > eviction > LFUConfiguration


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.eviction;
8
9 import org.jboss.cache.config.Dynamic;
10
11 /**
12  * Configuration implementation for {@link LFUPolicy}.
13  * <p/>
14  * If configured via XML, expects the following:
15  * <p/>
16  * <pre>
17  * <region name="abc">
18  * <attribute name="minNodes">10</attribute>
19  * <attribute name="maxNodes">20</attribute>
20  * </region>
21  * </pre>
22  *
23  * @author Daniel Huang (dhuang@jboss.org)
24  * @version $Revision: 1.8 $
25  */

26 public class LFUConfiguration extends EvictionPolicyConfigBase
27 {
28    /** The serialVersionUID */
29    private static final long serialVersionUID = 1865801530398969179L;
30    
31    @Dynamic
32    private int minNodes;
33
34    public LFUConfiguration()
35    {
36       setEvictionPolicyClassName();
37    }
38
39    @Override JavaDoc
40    protected void setEvictionPolicyClassName()
41    {
42       setEvictionPolicyClass(LFUPolicy.class.getName());
43    }
44
45    public int getMinNodes()
46    {
47       return minNodes;
48    }
49
50    public void setMinNodes(int minNodes)
51    {
52       testImmutability("minNodes");
53       this.minNodes = minNodes;
54    }
55    
56    public String JavaDoc toString()
57    {
58       StringBuffer JavaDoc ret = new StringBuffer JavaDoc();
59       ret.append("LFUConfiguration: maxNodes = ").append(getMaxNodes()).append(" minNodes = ").append(getMinNodes());
60       return ret.toString();
61    }
62
63    @Override JavaDoc
64    public boolean equals(Object JavaDoc obj)
65    {
66       if (obj instanceof LFUConfiguration && super.equals(obj))
67       {
68          return (this.minNodes == ((LFUConfiguration) obj).minNodes);
69       }
70       return false;
71    }
72
73    @Override JavaDoc
74    public int hashCode()
75    {
76       int result = super.hashCode();
77       result = 31 * result + minNodes;
78       return result;
79    }
80
81 }
82
Popular Tags