1 7 8 package com.sun.corba.se.impl.legacy.connection; 9 10 import java.net.Socket ; 11 import java.nio.channels.SocketChannel ; 12 import java.util.Collections ; 13 14 import org.omg.CORBA.COMM_FAILURE ; 15 import org.omg.CORBA.CompletionStatus ; 16 17 import com.sun.corba.se.pept.transport.Acceptor; 18 import com.sun.corba.se.pept.transport.ContactInfo; 19 20 import com.sun.corba.se.spi.ior.IOR; 21 import com.sun.corba.se.spi.legacy.connection.GetEndPointInfoAgainException; 22 import com.sun.corba.se.spi.orb.ORB; 23 import com.sun.corba.se.spi.transport.CorbaConnection; 24 import com.sun.corba.se.spi.transport.CorbaContactInfo; 25 import com.sun.corba.se.spi.transport.SocketInfo; 26 27 import com.sun.corba.se.impl.orbutil.ORBUtility; 28 import com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl; 29 import com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl; 30 31 34 public class SocketFactoryConnectionImpl 35 extends 36 SocketOrChannelConnectionImpl 37 { 38 public SocketFactoryConnectionImpl(ORB orb, 40 CorbaContactInfo contactInfo, 41 boolean useSelectThreadToWait, 42 boolean useWorkerThread) 43 { 44 super(orb, useSelectThreadToWait, useWorkerThread); 45 46 this.contactInfo = contactInfo; 49 50 boolean isBlocking = !useSelectThreadToWait; 51 SocketInfo socketInfo = 52 ((SocketFactoryContactInfoImpl)contactInfo).socketInfo; 54 try { 55 socket = 56 orb.getORBData().getLegacySocketFactory().createSocket(socketInfo); 57 socketChannel = socket.getChannel(); 58 if (socketChannel != null) { 59 socketChannel.configureBlocking(isBlocking); 60 } else { 61 setUseSelectThreadToWait(false); 64 } 65 if (orb.transportDebugFlag) { 66 dprint(".initialize: connection created: " + socket); 67 } 68 } catch (GetEndPointInfoAgainException ex) { 69 throw wrapper.connectFailure( 70 ex, socketInfo.getType(), socketInfo.getHost(), 71 Integer.toString(socketInfo.getPort())) ; 72 } catch (Exception ex) { 73 throw wrapper.connectFailure( 74 ex, socketInfo.getType(), socketInfo.getHost(), 75 Integer.toString(socketInfo.getPort())) ; 76 } 77 state = OPENING; 78 } 79 80 public String toString() 81 { 82 synchronized ( stateEvent ){ 83 return 84 "SocketFactoryConnectionImpl[" + " " 85 + (socketChannel == null ? 86 socket.toString() : socketChannel.toString()) + " " 87 + getStateString( state ) + " " 88 + shouldUseSelectThreadToWait() + " " 89 + shouldUseWorkerThreadForEvent() 90 + "]" ; 91 } 92 } 93 94 public void dprint(String msg) 96 { 97 ORBUtility.dprint("SocketFactoryConnectionImpl", msg); 98 } 99 100 } 101 102 | Popular Tags |