KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > config > EvictionRegionConfig


1 /*
2  * JBoss, Home of Professional Open Source.
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * as indicated by the @author tags. See the copyright.txt file in the
5  * distribution for a full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.cache.config;
23
24 import org.apache.commons.logging.LogFactory;
25 import org.jboss.cache.Fqn;
26 import org.jboss.cache.eviction.EvictionPolicyConfig;
27
28 public class EvictionRegionConfig extends ConfigurationComponent
29 {
30    /**
31     * The serialVersionUID
32     */

33    private static final long serialVersionUID = -5482474634995601400L;
34
35    public static final String JavaDoc NAME = "name";
36    public static final String JavaDoc REGION = "region";
37    public static final String JavaDoc REGION_POLICY_CLASS = "policyClass";
38    public static final String JavaDoc EVENT_QUEUE_SIZE = "eventQueueSize";
39
40    private Fqn regionFqn;
41    @Dynamic
42    private Integer JavaDoc eventQueueSize;
43    private EvictionPolicyConfig evictionPolicyConfig;
44
45    public EvictionRegionConfig()
46    {
47    }
48
49    public EvictionPolicyConfig getEvictionPolicyConfig()
50    {
51       return evictionPolicyConfig;
52    }
53
54    public void setEvictionPolicyConfig(EvictionPolicyConfig config)
55    {
56       testImmutability("evictionPolicyConfig");
57       if (this.evictionPolicyConfig instanceof ConfigurationComponent)
58       {
59          removeChildConfig((ConfigurationComponent) this.evictionPolicyConfig);
60       }
61       if (config instanceof ConfigurationComponent)
62       {
63          addChildConfig((ConfigurationComponent) config);
64       }
65       if (config != null)
66          config.validate();
67
68       this.evictionPolicyConfig = config;
69    }
70
71    public Fqn getRegionFqn()
72    {
73       return regionFqn;
74    }
75
76    public void setRegionFqn(Fqn regionFqn)
77    {
78       testImmutability("regionFqn");
79       this.regionFqn = regionFqn;
80    }
81
82    public String JavaDoc getRegionName()
83    {
84       return regionFqn == null ? null : regionFqn.toString();
85    }
86
87    public void setRegionName(String JavaDoc name)
88    {
89       setRegionFqn(name == null ? null : Fqn.fromString(name));
90    }
91
92    public int getEventQueueSize()
93    {
94       return eventQueueSize == null ? EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT : eventQueueSize;
95    }
96
97    public void setEventQueueSize(int queueSize)
98    {
99       testImmutability("eventQueueSize");
100       if (queueSize <= 0)
101       {
102          LogFactory.getLog(EvictionRegionConfig.class).warn("Ignoring invalid queue capacity " +
103                  queueSize + " -- using " +
104                  EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
105          queueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
106       }
107       this.eventQueueSize = queueSize;
108    }
109
110    public void setDefaultEventQueueSize(int queueSize)
111    {
112       if (eventQueueSize == null)
113          setEventQueueSize(queueSize);
114    }
115
116
117    @Override JavaDoc
118    public boolean equals(Object JavaDoc obj)
119    {
120       if (this == obj)
121          return true;
122
123       if (obj instanceof EvictionRegionConfig)
124       {
125          EvictionRegionConfig other = (EvictionRegionConfig) obj;
126          return safeEquals(this.regionFqn, other.regionFqn);
127       }
128       return false;
129    }
130
131    @Override JavaDoc
132    public int hashCode()
133    {
134       int result = 17;
135       result = 31 * result + (regionFqn == null ? 0 : regionFqn.hashCode());
136
137       return result;
138    }
139
140
141 }
Popular Tags