1 25 package org.objectweb.carol.util.csiv2.struct; 26 27 import java.io.Serializable ; 28 import java.net.InetAddress ; 29 import java.net.UnknownHostException ; 30 31 import org.omg.CSIIOP.TransportAddress; 32 33 import org.objectweb.carol.util.configuration.CarolDefaultValues; 34 import org.objectweb.carol.util.configuration.TraceCarol; 35 36 39 public class TransportStruct implements Serializable { 40 41 44 private static final String LOCAL_IP = "127.0.0.1"; 45 46 49 private TransportAddress[] transportAdresses = null; 50 51 54 private short targetSupports = 0; 55 56 59 private short targetRequires = 0; 60 61 62 66 public static int getSslPort() { 67 String sslPortStr = System.getProperty("OASSLPort", String.valueOf(CarolDefaultValues.DEFAULT_SSL_PORT)); 69 return Integer.parseInt(sslPortStr); 70 } 71 72 75 public TransportAddress[] getTransportAddress() { 76 77 int sslPort = getSslPort(); 78 79 String ipAddr = null; 80 81 try { 82 InetAddress addr = InetAddress.getLocalHost(); 83 ipAddr = addr.getHostAddress(); 84 } catch (UnknownHostException uhe) { 85 TraceCarol.error("Cannot get current hostname", uhe); 86 ipAddr = LOCAL_IP; 87 } 88 transportAdresses = new TransportAddress[1]; 89 transportAdresses[0] = new TransportAddress(ipAddr, (short) sslPort); 90 return transportAdresses; 91 } 92 93 96 public void setTargetRequires(int targetRequires) { 97 this.targetRequires = (short) targetRequires; 98 } 99 100 103 public void setTargetSupports(int targetSupports) { 104 this.targetSupports = (short) targetSupports; 105 } 106 107 110 public short getTargetRequires() { 111 return targetRequires; 112 } 113 114 117 public short getTargetSupports() { 118 return targetSupports; 119 } 120 121 } | Popular Tags |