KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > buddyreplication > NextMemberBuddyLocatorConfig


1 package org.jboss.cache.buddyreplication;
2
3 import org.jboss.cache.config.BuddyReplicationConfig;
4 import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
5 import org.jboss.cache.config.Dynamic;
6
7 import java.util.Properties JavaDoc;
8
9 /**
10  * Type-specific configuration object for NextMemberBuddyLocator.
11  */

12 public class NextMemberBuddyLocatorConfig extends BuddyLocatorConfig
13 {
14    private static final long serialVersionUID = 2443438867383733851L;
15
16    @Dynamic
17    private int numBuddies = 1;
18    @Dynamic
19    private boolean ignoreColocatedBuddies = true;
20
21    /**
22     * Default constructor.
23     */

24    public NextMemberBuddyLocatorConfig()
25    {
26       setBuddyLocatorClass(NextMemberBuddyLocator.class.getName());
27    }
28
29    /**
30     * Constructor for use by {@link NextMemberBuddyLocator#init(BuddyLocatorConfig)}.
31     *
32     * @param base the config passed in to <code>init()</code>.
33     */

34    NextMemberBuddyLocatorConfig(BuddyReplicationConfig.BuddyLocatorConfig base)
35    {
36       this();
37       setBuddyLocatorProperties(base.getBuddyLocatorProperties());
38    }
39
40    public String JavaDoc getBuddyLocatorClass()
41    {
42       return NextMemberBuddyLocator.class.getName();
43    }
44
45    public void setBuddyLocatorClass(String JavaDoc buddyLocatorClass)
46    {
47       // ignore it
48
}
49
50    public boolean isIgnoreColocatedBuddies()
51    {
52       return ignoreColocatedBuddies;
53    }
54
55    public void setIgnoreColocatedBuddies(boolean ignoreColocatedBuddies)
56    {
57       testImmutability("ignoreColocatedBuddies");
58       this.ignoreColocatedBuddies = ignoreColocatedBuddies;
59    }
60
61    public int getNumBuddies()
62    {
63       return numBuddies;
64    }
65
66    public void setNumBuddies(int numBuddies)
67    {
68       testImmutability("numBuddies");
69       this.numBuddies = numBuddies;
70    }
71
72    public void setBuddyLocatorProperties(Properties JavaDoc props)
73    {
74       super.setBuddyLocatorProperties(props);
75       if (props != null)
76       {
77          String JavaDoc numBuddiesStr = props.getProperty("numBuddies");
78          String JavaDoc ignoreColocatedBuddiesStr = props.getProperty("ignoreColocatedBuddies");
79          if (numBuddiesStr != null) numBuddies = Integer.parseInt(numBuddiesStr);
80          if (ignoreColocatedBuddiesStr != null)
81          {
82             ignoreColocatedBuddies = Boolean.valueOf(ignoreColocatedBuddiesStr);
83          }
84       }
85    }
86
87    public boolean equals(Object JavaDoc obj)
88    {
89       if (this == obj)
90          return true;
91
92       if (obj instanceof NextMemberBuddyLocatorConfig)
93       {
94          NextMemberBuddyLocatorConfig other = (NextMemberBuddyLocatorConfig) obj;
95          return (other.ignoreColocatedBuddies == this.ignoreColocatedBuddies)
96                  && (other.numBuddies == this.numBuddies);
97       }
98       return false;
99    }
100
101    public int hashCode()
102    {
103       int result = 13;
104       result = 23 * result + (ignoreColocatedBuddies ? 0 : 1);
105       result = 23 * result + numBuddies;
106       return result;
107    }
108
109
110 }
Popular Tags