1 7 8 package com.sun.corba.se.impl.transport; 9 10 import java.util.ArrayList ; 11 import java.util.Iterator ; 12 import java.util.List ; 13 14 import org.omg.IOP.TAG_ALTERNATE_IIOP_ADDRESS ; 15 16 import com.sun.corba.se.spi.ior.IOR; 17 import com.sun.corba.se.spi.ior.ObjectKeyTemplate; 18 import com.sun.corba.se.spi.ior.iiop.IIOPProfile ; 19 import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate ; 20 import com.sun.corba.se.spi.ior.iiop.IIOPAddress ; 21 import com.sun.corba.se.spi.ior.iiop.AlternateIIOPAddressComponent; 22 import com.sun.corba.se.spi.transport.IORToSocketInfo; 23 import com.sun.corba.se.spi.transport.SocketInfo; 24 25 public class DefaultIORToSocketInfoImpl 26 implements IORToSocketInfo 27 { 28 public List getSocketInfo(IOR ior) 29 { 30 SocketInfo socketInfo; 31 List result = new ArrayList (); 32 33 IIOPProfileTemplate iiopProfileTemplate = (IIOPProfileTemplate) 34 ior.getProfile().getTaggedProfileTemplate() ; 35 IIOPAddress primary = iiopProfileTemplate.getPrimaryAddress() ; 36 String hostname = primary.getHost().toLowerCase(); 37 int port = primary.getPort(); 38 socketInfo = createSocketInfo(hostname, port); 44 result.add(socketInfo); 45 46 Iterator iterator = iiopProfileTemplate.iteratorById( 47 TAG_ALTERNATE_IIOP_ADDRESS.value); 48 49 while (iterator.hasNext()) { 50 AlternateIIOPAddressComponent alternate = 51 (AlternateIIOPAddressComponent) iterator.next(); 52 hostname = alternate.getAddress().getHost().toLowerCase(); 53 port = alternate.getAddress().getPort(); 54 socketInfo= createSocketInfo(hostname, port); 55 result.add(socketInfo); 56 } 57 return result; 58 } 59 60 private SocketInfo createSocketInfo(final String hostname, final int port) 61 { 62 return new SocketInfo() { 63 public String getType() { return SocketInfo.IIOP_CLEAR_TEXT; } 64 public String getHost() { return hostname; } 65 public int getPort() { return port; }}; 66 } 67 } 68 69 | Popular Tags |