1 7 8 package com.sun.corba.se.impl.transport; 9 10 import java.io.InputStream ; 11 import java.io.IOException ; 12 import java.nio.ByteBuffer ; 13 14 import org.omg.CORBA.INTERNAL ; 15 16 import com.sun.corba.se.pept.broker.Broker; 17 import com.sun.corba.se.pept.encoding.InputObject; 18 import com.sun.corba.se.pept.encoding.OutputObject; 19 import com.sun.corba.se.pept.protocol.ClientRequestDispatcher; 20 import com.sun.corba.se.pept.protocol.MessageMediator; 21 import com.sun.corba.se.pept.transport.ByteBufferPool; 22 import com.sun.corba.se.pept.transport.ContactInfo; 23 import com.sun.corba.se.pept.transport.ContactInfoList; 24 import com.sun.corba.se.pept.transport.Connection; 25 import com.sun.corba.se.pept.transport.EventHandler; 26 import com.sun.corba.se.pept.transport.OutboundConnectionCache; 27 28 import com.sun.corba.se.spi.orb.ORB; 29 import com.sun.corba.se.spi.ior.IOR; 30 import com.sun.corba.se.spi.ior.ObjectKeyTemplate; 31 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 32 import com.sun.corba.se.spi.ior.iiop.IIOPAddress ; 33 import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate; 34 import com.sun.corba.se.spi.ior.iiop.IIOPProfile; 35 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 36 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry; 37 import com.sun.corba.se.spi.transport.CorbaConnection; 38 import com.sun.corba.se.spi.transport.CorbaContactInfoList; 39 import com.sun.corba.se.spi.transport.CorbaContactInfo; 40 41 import com.sun.corba.se.impl.encoding.ByteBufferWithInfo; 42 import com.sun.corba.se.impl.encoding.CDRInputObject; 43 import com.sun.corba.se.impl.encoding.CDRInputStream_1_0; 44 import com.sun.corba.se.impl.encoding.CDROutputObject; 45 import com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl; 46 import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr; 47 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; 48 import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase; 49 import com.sun.corba.se.impl.orbutil.ORBUtility; 50 51 54 public abstract class CorbaContactInfoBase 55 implements 56 CorbaContactInfo 57 { 58 protected ORB orb; 59 protected CorbaContactInfoList contactInfoList; 60 protected IOR effectiveTargetIOR; 62 protected short addressingDisposition; 63 protected OutboundConnectionCache connectionCache; 64 65 70 public Broker getBroker() 71 { 72 return orb; 73 } 74 75 public ContactInfoList getContactInfoList() 76 { 77 return contactInfoList; 78 } 79 80 public ClientRequestDispatcher getClientRequestDispatcher() 81 { 82 int scid = 83 getEffectiveProfile().getObjectKeyTemplate().getSubcontractId() ; 84 RequestDispatcherRegistry scr = orb.getRequestDispatcherRegistry() ; 85 return scr.getClientRequestDispatcher( scid ) ; 86 } 87 88 public void setConnectionCache(OutboundConnectionCache connectionCache) 91 { 92 this.connectionCache = connectionCache; 93 } 94 95 public OutboundConnectionCache getConnectionCache() 96 { 97 return connectionCache; 98 } 99 100 public MessageMediator createMessageMediator(Broker broker, 102 ContactInfo contactInfo, 103 Connection connection, 104 String methodName, 105 boolean isOneWay) 106 { 107 CorbaMessageMediator messageMediator = 113 new CorbaMessageMediatorImpl( 114 (ORB) broker, 115 contactInfo, 116 connection, 117 GIOPVersion.chooseRequestVersion( (ORB)broker, 118 effectiveTargetIOR), 119 effectiveTargetIOR, 120 ((CorbaConnection)connection).getNextRequestId(), 121 getAddressingDisposition(), 122 methodName, 123 isOneWay); 124 125 return messageMediator; 126 } 127 128 public MessageMediator createMessageMediator(Broker broker,Connection conn) 130 { 131 ORB orb = (ORB) broker; 132 CorbaConnection connection = (CorbaConnection) conn; 133 134 if (orb.transportDebugFlag) { 135 if (connection.shouldReadGiopHeaderOnly()) { 136 dprint( 137 ".createMessageMediator: waiting for message header on connection: " 138 + connection); 139 } else { 140 dprint( 141 ".createMessageMediator: waiting for message on connection: " 142 + connection); 143 } 144 } 145 146 Message msg = null; 147 148 if (connection.shouldReadGiopHeaderOnly()) { 149 msg = MessageBase.readGIOPHeader(orb, connection); 151 } else { 152 msg = MessageBase.readGIOPMessage(orb, connection); 154 } 155 156 ByteBuffer byteBuffer = msg.getByteBuffer(); 157 msg.setByteBuffer(null); 158 CorbaMessageMediator messageMediator = 159 new CorbaMessageMediatorImpl(orb, connection, msg, byteBuffer); 160 161 return messageMediator; 162 } 163 164 public MessageMediator finishCreatingMessageMediator(Broker broker, 166 Connection conn, MessageMediator messageMediator) 167 { 168 ORB orb = (ORB) broker; 169 CorbaConnection connection = (CorbaConnection) conn; 170 CorbaMessageMediator corbaMessageMediator = 171 (CorbaMessageMediator)messageMediator; 172 173 if (orb.transportDebugFlag) { 174 dprint( 175 ".finishCreatingMessageMediator: waiting for message body on connection: " 176 + connection); 177 } 178 179 Message msg = corbaMessageMediator.getDispatchHeader(); 180 msg.setByteBuffer(corbaMessageMediator.getDispatchBuffer()); 181 182 msg = MessageBase.readGIOPBody(orb, connection, msg); 184 185 ByteBuffer byteBuffer = msg.getByteBuffer(); 186 msg.setByteBuffer(null); 187 corbaMessageMediator.setDispatchHeader(msg); 188 corbaMessageMediator.setDispatchBuffer(byteBuffer); 189 190 return corbaMessageMediator; 191 } 192 193 public OutputObject createOutputObject(MessageMediator messageMediator) 194 { 195 CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator) 196 messageMediator; 197 198 OutputObject outputObject = 199 new CDROutputObject(orb, messageMediator, 200 corbaMessageMediator.getRequestHeader(), 201 corbaMessageMediator.getStreamFormatVersion()); 202 203 messageMediator.setOutputObject(outputObject); 204 return outputObject; 205 } 206 207 public InputObject createInputObject(Broker broker, 208 MessageMediator messageMediator) 209 { 210 CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator) 212 messageMediator; 213 return new CDRInputObject((ORB)broker, 214 (CorbaConnection)messageMediator.getConnection(), 215 corbaMessageMediator.getDispatchBuffer(), 216 corbaMessageMediator.getDispatchHeader()); 217 } 218 219 224 public short getAddressingDisposition() 225 { 226 return addressingDisposition; 227 } 228 229 public void setAddressingDisposition(short addressingDisposition) 230 { 231 this.addressingDisposition = addressingDisposition; 232 } 233 234 public IOR getTargetIOR() 236 { 237 return contactInfoList.getTargetIOR(); 238 } 239 240 public IOR getEffectiveTargetIOR() 241 { 242 return effectiveTargetIOR ; 243 } 244 245 public IIOPProfile getEffectiveProfile() 246 { 247 return effectiveTargetIOR.getProfile(); 248 } 249 250 255 public String toString() 256 { 257 return 258 "CorbaContactInfoBase[" 259 + "]"; 260 } 261 262 263 268 protected void dprint(String msg) 269 { 270 ORBUtility.dprint("CorbaContactInfoBase", msg); 271 } 272 } 273 274 | Popular Tags |