[omniORB] omniINSPOA and bidir connections (omniORB4)

Fernando A. de Araujo Filho maverick@elogica.com.br
Wed Oct 23 07:25:01 2002


Hi, first of all, sorry for my bad english ..
This is my first email to the list.

With respect to Rob Eger reger@txcorp.com message "omniINSPOA and bidir
connections (omniORB4)"
sent  last "Fri Sep 6 16:41:02 2002", I had the exactly same problem.
I need to change my applications to implement bidirectional feature.
I will not more use insPOA. I never used nameservices or omnimapper, I dont
know how to ...

To solve my problem I decided :

On servant side:
1. I need (or not) publish all interfaces and make my servant configured to
accept bidirectional conections
argv[0] = strdup("-ORBendPoint");
argv[1] = new char[16];
argv[1] = (char*) malloc(32);
sprintf(argv[1], "giop:tcp::%d", 3456);
argv[2] = strdup("-ORBserverTransportRule");
argv[3] = strdup("* unix,tcp,bidir");
argv[6] = strdup("-ORBacceptBiDirectionalGIOP");
argv[7] = strdup("1");
argv[10] = strdup("-ORBendPointPublishAllIFs");
argv[11] = strdup("1");

2. create POAs with PERSISTENT, BIDIRECTIONAL_POLICY_TYPE and USER_ID
policies
CORBA::PolicyList pl;
pl.length(3);
CORBA::Any a;
a <<= BiDirPolicy::BOTH;
pl[0] = orb->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, a);
pl[1] = rootpoa->create_lifespan_policy(PortableServer::PERSISTENT);
pl[2] = rootpoa->create_id_assignment_policy(PortableServer::USER_ID);
PortableServer::POA_var poa = rootpoa->create_POA("bidir.persistent", pman,
pl);
server_i* myserver = new server_i();
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId("bidir");
poa->activate_object_with_id(oid, myserver );
obj = myserver->_this();
myserver->_remove_ref();

On client side
1. I need to make my client configured to offer bidirectional conections
argv1[0] = strdup("-ORBclientTransportRule");
argv1[1] = strdup("* unix,tcp,bidir");
argv1[4] = strdup("-ORBofferBiDirectionalGIOP");
argv1[5] = strdup("1");

2. I need to know the "IR Type ID", "POA name" and corresponding "ObjectId
name"  to activate the "servant reference".
No problem, my applications are specifics.
CORBA::PolicyList pl;
pl.length(1);
CORBA::Any a;
a <<= BiDirPolicy::BOTH;
pl[0] = orb->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, a);
PortableServer::POA_var poa = rootpoa->create_POA("bidir.persistent", pman,
pl);
//  I have created a function, a copy of  "genRef" listed on
omniORB-4.0.0\src\appl\utils\genior\genior.cc,
//  that return a IOR from the parameters passed.
obj =
orb->string_to_object(geniorGetIOR("IDL:cb/Server:1.0","192.168.0.2",28809,"
bidir.persistent", "bidir"));
cb::Server_var server = cb::Server::_narrow(obj);

With that approach, I have solved my problems ... sorry if its not "elegant"
Basically, if I dont found a solution, I dont have money to buy food for my
kids :-)

regards,

Fernando A. de Araujo Filho
maverick@elogica.com.br

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omniORB4/CORBA.h>
#ifdef HAVE_UNISTD_H
#  include <unistd.h>
#endif
#include <ctype.h>

static GIOP::Version giop_version = { 1,2 };
static CORBA::Boolean extra_profiles = 1;

char* geniorGetIOR(const char* IRTypeId, const char* hostname, int port,
       const char* poaName, const char* objIDName)
{

 if (poaName == 0)
  return 0;
 omniORB::seqOctets keySeedParser;
 omniORB::seqOctets* keySeed =new omniORB::seqOctets;;
 keySeed->length(2+strlen(poaName)+strlen(objIDName));

 (*keySeed)[0]=255;
 for (unsigned int j=1; j<strlen(poaName)+1; j++)
  (*keySeed)[j]=poaName[j-1];
 (*keySeed)[strlen(poaName)+1]=0;
 for (j=strlen(poaName)+2; j<(strlen(poaName)+2+strlen(objIDName)); j++)
  (*keySeed)[j]=objIDName[j-strlen(poaName)-2];
 // remove 3 lines below if you have already initialized the orb
 CORBA::ORB_var orb;
 int argc = 0;
 orb = CORBA::ORB_init(argc,0,"omniORB4");
 //
 IIOP::Address addrs;
 addrs.host = hostname;
 addrs.port = port;
 omniIOR* ior = new omniIOR(IRTypeId,*keySeed,&addrs,1,giop_version,
    ((extra_profiles) ? omniIOR::DefaultInterceptors
          : omniIOR::NoInterceptor));
 omniObjRef* objref = omni::createObjRef(CORBA::Object::_PD_repoId,ior,0);
 CORBA::String_var result;
 result = omniObjRef::_toString(objref);
  return result._retn();
 }