KickJava   Java API By Example, From Geeks To Geeks.

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


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.ConfigurationException;
10
11 /**
12  * Configuration for {@link MRUPolicy}.
13  * <p/>
14  * If configured via XML, expects the following:
15  * <p/>
16  * <pre>
17  * <region name="abc">
18  * <attribute name="maxNodes">1000</attribute>
19  * </region>
20  * </pre>
21  *
22  * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
23  *
24  * @author Daniel Huang (dhuang@jboss.org)
25  * @version $Revision: 1.7 $
26  */

27 public class MRUConfiguration extends EvictionPolicyConfigBase
28 {
29    /** The serialVersionUID */
30    private static final long serialVersionUID = -8734577898966155218L;
31
32    public MRUConfiguration()
33    {
34       setEvictionPolicyClassName();
35       // We require that maxNodes is set
36
setMaxNodes(-1);
37    }
38
39    @Override JavaDoc
40    protected void setEvictionPolicyClassName()
41    {
42       setEvictionPolicyClass(MRUPolicy.class.getName());
43    }
44
45
46    /**
47     * Requires a positive maxNodes value or ConfigurationException
48     * is thrown.
49     */

50    @Override JavaDoc
51    public void validate() throws ConfigurationException
52    {
53       if (getMaxNodes() < 0)
54          throw new ConfigurationException("maxNodes not configured");
55    }
56
57    public String JavaDoc toString()
58    {
59       StringBuffer JavaDoc str = new StringBuffer JavaDoc();
60       str.append("MRUConfiguration: ").
61             append(" maxNodes =").append(getMaxNodes());
62       return str.toString();
63    }
64
65    @Override JavaDoc
66    public boolean equals(Object JavaDoc obj)
67    {
68       return (obj instanceof MRUConfiguration && super.equals(obj));
69    }
70
71    @Override JavaDoc
72    public void reset()
73    {
74       setMaxNodes(-1);
75    }
76    
77 }
78
Popular Tags