--- D:\Temp\jacorb\old\BiDirConnectionServerInterceptor.java 2006-06-28 13:41:44.000000000 +0530 +++ D:\Temp\jacorb\new\BiDirConnectionServerInterceptor.java 2008-12-16 16:22:13.323490900 +0530 @@ -21,6 +21,7 @@ package org.jacorb.orb.giop; import org.omg.PortableInterceptor.*; +import org.omg.ETF.Profile; import org.omg.IIOP.*; import org.omg.IOP.*; @@ -34,86 +35,91 @@ * @author Nicolas Noffke * @version $Id: BiDirConnectionServerInterceptor.java,v 1.15 2006/06/28 12:41:43 alphonse.bendt Exp $ */ -public class BiDirConnectionServerInterceptor - extends DefaultServerInterceptor -{ +public class BiDirConnectionServerInterceptor extends DefaultServerInterceptor { private static final String NAME = "BiDirConnectionServerInterceptor"; private final ORB orb; private final Logger logger; private final ClientConnectionManager conn_mg; - protected BiDirConnectionServerInterceptor( ORB orb ) - { + protected BiDirConnectionServerInterceptor(ORB orb) { super(); this.orb = orb; - this.logger = orb.getConfiguration().getNamedLogger("jacorb.giop.bidir.interceptor"); + this.logger = orb.getConfiguration().getNamedLogger( + "jacorb.giop.bidir.interceptor"); conn_mg = orb.getClientConnectionManager(); } - public String name() - { + public String name() { return NAME; } - public void destroy() - { + public void destroy() { // nothing to do } - public void receive_request_service_contexts( ServerRequestInfo requestInfo ) - throws ForwardRequest - { - if( orb.useBiDirGIOP() ) - { - try - { - final ServiceContext context = requestInfo.get_request_service_context( BI_DIR_IIOP.value ); + public void receive_request_service_contexts(ServerRequestInfo requestInfo) + throws ForwardRequest { + if (orb.useBiDirGIOP()) { + try { + final ServiceContext context = requestInfo + .get_request_service_context(BI_DIR_IIOP.value); addConnections(requestInfo, context); - } - catch( org.omg.CORBA.BAD_PARAM e ) - { + } catch (org.omg.CORBA.BAD_PARAM e) { logger.debug("no BiDir context present"); } } } - private void addConnections(ServerRequestInfo requestInfo, ServiceContext ctx) - { - final BiDirIIOPServiceContext bidir_ctx = readBiDirContext(ctx); + private void addConnections(ServerRequestInfo requestInfo, + ServiceContext ctx) { + GIOPConnection connection = ((ServerRequestInfoImpl) requestInfo).request + .getConnection(); + + // ACP adding to get the correct port + IIOPProfile profile = (IIOPProfile) connection.getProfile(); + IIOPAddress addr = (IIOPAddress) profile.getAddress(); + // End ACP - GIOPConnection connection = - ((ServerRequestInfoImpl) requestInfo).request.getConnection(); + // Also add a profile where only the client IP is stored and not the + // port + final BiDirIIOPServiceContext bidir_ctx = readBiDirContext(ctx); + if (bidir_ctx.listen_points.length == 0) { + return; + } - for( int i = 0; i < bidir_ctx.listen_points.length; i++ ) - { - ListenPoint listenPoint = bidir_ctx.listen_points[i]; + // ACP we should not add the IP on which we are running take the first one as this is getting + //stored in the profile If more than one client connection is added in the client connection + //the request id will be added to one connection object and it won't be found when the reply comes - IIOPAddress addr = new IIOPAddress (listenPoint.host, listenPoint.port); + ListenPoint listenPoint = bidir_ctx.listen_points[0]; - if (logger.isDebugEnabled()) - { - logger.debug("Client conn. added to target " + addr ); + if (logger.isDebugEnabled()) { + logger.debug("**Client conn. added to target with NULL Port " + + addr + "host=" + addr.getIP()); } - conn_mg.addConnection( connection, new IIOPProfile (addr, null) ); - } + // IIOPAddress haddr = new IIOPAddress(addr.getIP(), 0);//port is set as + // null here + IIOPAddress haddr = new IIOPAddress(addr.getIP(), listenPoint.port); + IIOPProfile hpf = new IIOPProfile(haddr, null); // note that the key + // here is the profile + // and not the connection + conn_mg.addConnection(connection, hpf); + } - private BiDirIIOPServiceContext readBiDirContext(ServiceContext ctx) - { - final CDRInputStream cdr_in = - new CDRInputStream( orb, ctx.context_data ); - try - { + + private BiDirIIOPServiceContext readBiDirContext(ServiceContext ctx) { + final CDRInputStream cdr_in = new CDRInputStream(orb, ctx.context_data); + + try { cdr_in.openEncapsulatedArray(); return BiDirIIOPServiceContextHelper.read(cdr_in); - } - finally - { + } finally { cdr_in.close(); } }