KickJava   Java API By Example, From Geeks To Geeks.

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


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.jboss.cache.buddyreplication.NextMemberBuddyLocator;
25
26 import java.util.Properties JavaDoc;
27
28
29 public class BuddyReplicationConfig extends ConfigurationComponent
30 {
31    private static final long serialVersionUID = -4826380823985089339L;
32
33    /**
34     * Test whether buddy replication is enabled.
35     */

36    private boolean enabled;
37
38    /**
39     * Name of the buddy pool for current instance. May be null if buddy pooling is not used.
40     */

41    private String JavaDoc buddyPoolName;
42
43    private boolean autoDataGravitation = true;
44    private boolean dataGravitationRemoveOnFind = true;
45    private boolean dataGravitationSearchBackupTrees = true;
46    @Dynamic
47    private int buddyCommunicationTimeout = 10000;
48    private BuddyLocatorConfig buddyLocatorConfig;
49
50    public BuddyReplicationConfig()
51    {
52    }
53
54    public boolean isAutoDataGravitation()
55    {
56       return autoDataGravitation;
57    }
58
59    public void setAutoDataGravitation(boolean autoDataGravitation)
60    {
61       testImmutability("autoDataGravitation");
62       this.autoDataGravitation = autoDataGravitation;
63    }
64
65    public int getBuddyCommunicationTimeout()
66    {
67       return buddyCommunicationTimeout;
68    }
69
70    public void setBuddyCommunicationTimeout(int buddyCommunicationTimeout)
71    {
72       testImmutability("buddyCommunicationTimeout");
73       this.buddyCommunicationTimeout = buddyCommunicationTimeout;
74    }
75
76    public String JavaDoc getBuddyPoolName()
77    {
78       return buddyPoolName;
79    }
80
81    public void setBuddyPoolName(String JavaDoc buddyPoolName)
82    {
83       testImmutability("buddyPoolName");
84       this.buddyPoolName = buddyPoolName;
85    }
86
87    public boolean isDataGravitationRemoveOnFind()
88    {
89       return dataGravitationRemoveOnFind;
90    }
91
92    public void setDataGravitationRemoveOnFind(boolean dataGravitationRemoveOnFind)
93    {
94       testImmutability("dataGravitationRemoveOnFind");
95       this.dataGravitationRemoveOnFind = dataGravitationRemoveOnFind;
96    }
97
98    public boolean isDataGravitationSearchBackupTrees()
99    {
100       return dataGravitationSearchBackupTrees;
101    }
102
103    public void setDataGravitationSearchBackupTrees(boolean dataGravitationSearchBackupTrees)
104    {
105       testImmutability("dataGravitationSearchBackupTrees");
106       this.dataGravitationSearchBackupTrees = dataGravitationSearchBackupTrees;
107    }
108
109    public boolean isEnabled()
110    {
111       return enabled;
112    }
113
114    public void setEnabled(boolean enabled)
115    {
116       testImmutability("enabled");
117       this.enabled = enabled;
118    }
119
120    public BuddyLocatorConfig getBuddyLocatorConfig()
121    {
122       return buddyLocatorConfig;
123    }
124
125    public void setBuddyLocatorConfig(BuddyLocatorConfig buddyLocatorConfig)
126    {
127       testImmutability("buddyLocatorConfig");
128       replaceChildConfig(this.buddyLocatorConfig, buddyLocatorConfig);
129       this.buddyLocatorConfig = buddyLocatorConfig;
130    }
131
132    public boolean equals(Object JavaDoc obj)
133    {
134       if (this == obj)
135          return true;
136
137       if (obj instanceof BuddyReplicationConfig)
138       {
139          BuddyReplicationConfig other = (BuddyReplicationConfig) obj;
140          return (this.autoDataGravitation == other.autoDataGravitation)
141                  && (this.dataGravitationRemoveOnFind == other.dataGravitationRemoveOnFind)
142                  && (this.dataGravitationSearchBackupTrees == other.dataGravitationSearchBackupTrees)
143                  && (this.enabled == other.enabled)
144                  && (this.buddyCommunicationTimeout == other.buddyCommunicationTimeout)
145                  && safeEquals(this.buddyPoolName, other.buddyPoolName)
146                  && safeEquals(this.buddyLocatorConfig, other.buddyLocatorConfig);
147       }
148
149       return false;
150    }
151
152    public int hashCode()
153    {
154       int result = 11;
155       result = 29 * result + (autoDataGravitation ? 0 : 1);
156       result = 29 * result + (dataGravitationRemoveOnFind ? 0 : 1);
157       result = 29 * result + (dataGravitationSearchBackupTrees ? 0 : 1);
158       result = 29 * result + (enabled ? 0 : 1);
159       result = 29 * result + buddyCommunicationTimeout;
160       result = 29 * result + (buddyPoolName == null ? 0 : buddyPoolName.hashCode());
161       result = 29 * result + (buddyLocatorConfig == null ? 0 : buddyLocatorConfig.hashCode());
162       return result;
163    }
164
165    public static class BuddyLocatorConfig extends ConfigurationComponent
166    {
167       private static final long serialVersionUID = -8003634097931826091L;
168
169       private String JavaDoc buddyLocatorClass = NextMemberBuddyLocator.class.getName();
170       ;
171       private Properties JavaDoc buddyLocatorProperties;
172
173       public BuddyLocatorConfig()
174       {
175       }
176
177       public String JavaDoc getBuddyLocatorClass()
178       {
179          return buddyLocatorClass;
180       }
181
182       public void setBuddyLocatorClass(String JavaDoc buddyLocatorClass)
183       {
184          testImmutability("buddyLocatorClass");
185          this.buddyLocatorClass = buddyLocatorClass;
186          if (buddyLocatorClass == null)
187             this.buddyLocatorClass = NextMemberBuddyLocator.class.getName();
188       }
189
190       public Properties JavaDoc getBuddyLocatorProperties()
191       {
192          return buddyLocatorProperties;
193       }
194
195       public void setBuddyLocatorProperties(Properties JavaDoc buddyLocatorProperties)
196       {
197          testImmutability("buddyLocatorProperties");
198          this.buddyLocatorProperties = buddyLocatorProperties;
199       }
200
201       public boolean equals(Object JavaDoc obj)
202       {
203          if (this == obj)
204             return true;
205
206          if (obj instanceof BuddyLocatorConfig)
207          {
208             BuddyLocatorConfig other = (BuddyLocatorConfig) obj;
209             return (safeEquals(this.buddyLocatorClass, other.buddyLocatorClass)
210                     && safeEquals(this.buddyLocatorProperties, other.buddyLocatorProperties));
211          }
212          return false;
213       }
214
215       public int hashCode()
216       {
217          int result = 19;
218          result = 41 * result + (buddyLocatorClass == null ? 0 : buddyLocatorClass.hashCode());
219          result = 41 * result + (buddyLocatorProperties == null ? 0 : buddyLocatorProperties.hashCode());
220          return result;
221       }
222
223       public String JavaDoc toString()
224       {
225          return super.toString() + " class=" + buddyLocatorClass +
226                  " properties=" + buddyLocatorProperties;
227       }
228
229    }
230 }
231
Popular Tags