1 package org.jboss.cache.loader; 2 3 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig; 4 5 import java.util.Properties ; 6 7 public class TcpDelegatingCacheLoaderConfig extends IndividualCacheLoaderConfig 8 { 9 12 private static final long serialVersionUID = -3138555335000168505L; 13 14 private String host = "localhost"; 15 private int port = 7500; 16 17 public TcpDelegatingCacheLoaderConfig() 18 { 19 setClassName(TcpDelegatingCacheLoader.class.getName()); 20 } 21 22 27 TcpDelegatingCacheLoaderConfig(IndividualCacheLoaderConfig base) 28 { 29 setClassName(TcpDelegatingCacheLoader.class.getName()); 30 populateFromBaseConfig(base); 31 } 32 33 39 TcpDelegatingCacheLoaderConfig(String host, int port) 40 { 41 setClassName(TcpDelegatingCacheLoader.class.getName()); 42 this.host = host; 43 this.port = port; 44 } 45 46 public String getHost() 47 { 48 return host; 49 } 50 51 public void setHost(String 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 props) 69 { 70 super.setProperties(props); 71 String 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 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 |