1 22 package org.jboss.services.binding; 23 24 import java.net.InetAddress ; 25 import java.net.UnknownHostException ; 26 27 34 public class ServiceBinding implements Cloneable 35 { 36 39 private String name = null; 40 44 private String hostName = null; 45 48 private int port = 0; 49 52 private InetAddress bindAddress = null; 53 54 56 public Object clone() 57 { 58 Object copy = null; 59 try 60 { 61 copy = super.clone(); 62 } 63 catch(CloneNotSupportedException cantHappend) 64 { 65 } 66 return copy; 67 } 68 69 82 public ServiceBinding(String name, String hostName, int port) 83 throws UnknownHostException 84 { 85 this.setName(name); 86 this.setHostName(hostName); 87 this.setBindAddress(hostName); 88 this.setPort(port); 89 } 90 91 96 public String getName() 97 { 98 return this.name; 99 } 100 101 106 public void setName(String name) 107 { 108 this.name = name; 109 } 110 111 116 public void setBindAddress(InetAddress bindAddress) 117 { 118 this.bindAddress = bindAddress; 119 } 120 121 128 public void setBindAddress(String hostName) 129 throws UnknownHostException 130 { 131 this.bindAddress = InetAddress.getByName(hostName); 132 } 133 134 139 public InetAddress getBindAddress() 140 { 141 return this.bindAddress; 142 } 143 144 149 public void setPort(int port) 150 { 151 this.port = port; 152 } 153 154 159 public int getPort() 160 { 161 return this.port; 162 } 163 164 169 public String getHostName() 170 { 171 return this.hostName; 172 } 173 174 179 public void setHostName(String hostName) 180 { 181 this.hostName = hostName; 182 } 183 184 189 public String toString() 190 { 191 StringBuffer sBuf = new StringBuffer ("ServiceBinding [name="); 192 String host = getHostName(); 193 194 if (hostName == null) 195 { 196 host = "<ANY>"; 197 } 198 199 sBuf.append(this.getName()); 200 sBuf.append(";hostName="); 201 sBuf.append(host); 202 sBuf.append(";bindAddress="); 203 sBuf.append(this.getBindAddress().toString()); 204 sBuf.append(";port="); 205 sBuf.append(this.getPort()); 206 sBuf.append("]"); 207 return sBuf.toString(); 208 } 209 } 210 | Popular Tags |