KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > loader > TcpDelegatingCacheLoaderConfig


1 package org.jboss.cache.loader;
2
3 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
4
5 import java.util.Properties JavaDoc;
6
7 public class TcpDelegatingCacheLoaderConfig extends IndividualCacheLoaderConfig
8 {
9    /**
10     * The serialVersionUID
11     */

12    private static final long serialVersionUID = -3138555335000168505L;
13
14    private String JavaDoc host = "localhost";
15    private int port = 7500;
16
17    public TcpDelegatingCacheLoaderConfig()
18    {
19       setClassName(TcpDelegatingCacheLoader.class.getName());
20    }
21
22    /**
23     * For use by {@link TcpDelegatingCacheLoader}.
24     *
25     * @param base generic config object created by XML parsing.
26     */

27    TcpDelegatingCacheLoaderConfig(IndividualCacheLoaderConfig base)
28    {
29       setClassName(TcpDelegatingCacheLoader.class.getName());
30       populateFromBaseConfig(base);
31    }
32
33    /**
34     * For use by {@link TcpDelegatingCacheLoader}.
35     *
36     * @param host hostname of the delegate
37     * @param port port the delegate is listening on
38     */

39    TcpDelegatingCacheLoaderConfig(String JavaDoc host, int port)
40    {
41       setClassName(TcpDelegatingCacheLoader.class.getName());
42       this.host = host;
43       this.port = port;
44    }
45
46    public String JavaDoc getHost()
47    {
48       return host;
49    }
50
51    public void setHost(String JavaDoc host)
52    {
53       testImmutability("host");
54       this.host = host;
55    }
56
57    public int getPort()
58    {
59       return port;
60    }
61
62    public void setPort(int port)
63    {
64       testImmutability("port");
65       this.port = port;
66    }
67
68    public void setProperties(Properties JavaDoc props)
69    {
70       super.setProperties(props);
71       String JavaDoc s = props.getProperty("host");
72       if (s != null && s.length() > 0)
73       {
74          this.host = s;
75       }
76       s = props.getProperty("port");
77       if (s != null && s.length() > 0)
78       {
79          this.port = Integer.parseInt(s);
80       }
81    }
82
83    public boolean equals(Object JavaDoc obj)
84    {
85       if (obj instanceof TcpDelegatingCacheLoaderConfig && equalsExcludingProperties(obj))
86       {
87          TcpDelegatingCacheLoaderConfig other = (TcpDelegatingCacheLoaderConfig) obj;
88
89          return safeEquals(host, other.host)
90                  && (port == other.port);
91       }
92       return false;
93    }
94
95    public int hashCode()
96    {
97       int result = hashCodeExcludingProperties();
98       result = 31 * result + (host == null ? 0 : host.hashCode());
99       result = 31 * result + port;
100
101       return result;
102    }
103
104
105 }
Popular Tags