1 20 21 package org.jacorb.orb.giop; 22 23 import org.jacorb.orb.*; 24 import org.jacorb.orb.portableInterceptor.*; 25 26 import org.omg.PortableInterceptor.*; 27 import org.omg.IOP.Codec ; 28 import org.omg.IOP.*; 29 import org.omg.IIOP.*; 30 31 35 36 public class BiDirConnectionClientInterceptor 37 extends DefaultClientInterceptor 38 { 39 private String name = "BiDirConnectionClientInterceptor"; 40 41 private Codec codec = null; 42 private ORB orb = null; 43 44 private ServiceContext bidir_ctx = null; 45 46 public BiDirConnectionClientInterceptor( ORB orb, Codec codec ) 47 { 48 this.orb = orb; 49 this.codec = codec; 50 } 51 52 public String name() 53 { 54 return name; 55 } 56 57 public void destroy() 58 { 59 } 60 61 public void send_request( ClientRequestInfo ri ) 62 throws ForwardRequest 63 { 64 67 if( orb.useBiDirGIOP() && 68 ((ClientRequestInfoImpl) ri).connection.isClientInitiated() ) 69 { 70 if( bidir_ctx == null ) 71 { 72 BasicAdapter ba = orb.getBasicAdapter(); 73 74 ListenPoint lp = new ListenPoint( ba.getAddress(), 75 (short) ba.getPort() ); 76 77 ListenPoint[] points = null; 78 if( ba.hasSSLListener() ) 79 { 80 ListenPoint ssl_lp = 81 new ListenPoint( ba.getAddress(), 82 (short) ba.getSSLPort() ); 83 84 points = new ListenPoint[]{ lp, ssl_lp }; 85 } 86 else 87 { 88 points = new ListenPoint[]{ lp }; 89 } 90 91 BiDirIIOPServiceContext b = 92 new BiDirIIOPServiceContext( points ); 93 org.omg.CORBA.Any any = orb.create_any(); 94 BiDirIIOPServiceContextHelper.insert( any, b ); 95 96 CDROutputStream cdr_out = new CDROutputStream(); 97 98 cdr_out.beginEncapsulatedArray(); 99 BiDirIIOPServiceContextHelper.write( cdr_out, b ); 100 101 bidir_ctx = new ServiceContext( BI_DIR_IIOP.value, 102 cdr_out.getBufferCopy() ); 103 } 104 105 ri.add_request_service_context( bidir_ctx, true ); 106 107 GIOPConnection conn = ((ClientRequestInfoImpl) ri).connection.getGIOPConnection(); 109 if(conn.getRequestListener() instanceof 110 NoBiDirClientRequestListener) 111 { 112 conn.setRequestListener(orb.getBasicAdapter().getRequestListener()); 113 } 114 } 115 } 116 } 118 | Popular Tags |