[omniORB] Interworking with Java IDL
Tim S. Woodall
tim@redpt.com
Fri, 31 Jul 1998 07:53:43 -0500
Stefan Michael Hebsgaard wrote:
> my guess is that the tnameserv uses the port given
> at startup (defaults to 900), so that clients can
> can make a connection on that port at receive the
> nameservice IOR that way. I actually think that this
> is a much better approach then manually distributing
> the nameservice IOR.
>
This has been discussed on this list in the past. JavaIDL
clients employ a bootstrap protocol published by SUN to
contact the name server.
Following is a modification to the omniORB ORB::ORB_init
method that allows it to resolve the root context of the JavaIDL
name service. Note that if the JavaIDL name service is not
present at the specified host/port, the ORB defaults to the
name service specified by the local configuration file.
Changes are delineated by:
#ifdef/#ifndef _USE_BOOTSTRAP_PROTOCOL
#endif
Perhaps we could convince the omniORB staff to work this
into a future release in some form?
Regards,
Tim S. Woodall
RedPoint Network Systems
tim@redpt.com
CORBA::ORB_ptr
CORBA::ORB_init(int &argc,char **argv,const char *orb_identifier)
{
omni_mutex_lock sync(internalLock);
if (!parse_ORB_args(argc,argv,orb_identifier)) {
throw CORBA::INITIALIZE(0,CORBA::COMPLETED_NO);
}
if (orb)
return CORBA::ORB::_duplicate(orb);
try {
// initialise object tables
omniObject::globalInit();
// Now initialise all the rope factories that will be used to
// create outgoing ropes.
_tcpOutgoingFactory *tcpOutgoingFactory = new _tcpOutgoingFactory;
globalOutgoingRopeFactories.insert(tcpOutgoingFactory);
// Add rope factories for other transports here.
#ifndef _USE_BOOTSTRAP_PROTOCOL
// get configuration information:
{
initFile configFile;
configFile.initialize();
NameServiceRef = configFile.NameService();
}
#endif
// myPrincipalID, to be used in the principal field of IIOP calls
CORBA::ULong l = strlen("nobody")+1;
CORBA::Octet *p = (CORBA::Octet *) "nobody";
omni::myPrincipalID.length(l);
unsigned int i;
for (i=0; i < l; i++) {
omni::myPrincipalID[i] = p[i];
}
omniORB::seed.hi = omniORB::seed.med = 0;
#ifdef _HAS_SIGNAL
#ifndef _USE_MACH_SIGNAL
struct sigaction act;
sigemptyset(&act.sa_mask);
act.sa_handler = SIG_IGN;
act.sa_flags = 0;
if (sigaction(SIGPIPE,&act,0) < 0) {
if (omniORB::traceLevel > 0) {
cerr << "Warning: omni::init() cannot install the SIG_IGN handler for
signal SIGPIPE. (errno = " << errno << ")" << endl;
}
}
#else
struct sigvec act;
act.sv_mask = 0;
act.sv_handler = SIG_IGN;
act.sv_flags = 0;
if (sigvec(SIGPIPE,&act,0) < 0) {
if (omniORB::traceLevel > 0) {
cerr << "Warning: omni::init() cannot install the SIG_IGN handler for
signal SIGPIPE. (errno = " << errno << ")" << endl;
}
}
#endif
#endif // _HAS_SIGNAL
#ifdef __WIN32__
// Initialize WinSock:
WORD versionReq;
WSADATA wData;
versionReq = MAKEWORD(1, 1); // Nothing specific to releases > 1.1
used
int rc = WSAStartup(versionReq, &wData);
if (rc != 0)
{
// Couldn't find a usable DLL.
throw CORBA::INITIALIZE(0,CORBA::COMPLETED_NO);
}
// Confirm that the returned Windows Sockets DLL supports 1.1
if ( LOBYTE( wData.wVersion ) != 1 ||
HIBYTE( wData.wVersion ) != 1 )
{
// Couldn't find a usable DLL
WSACleanup();
throw CORBA::INITIALIZE(0,CORBA::COMPLETED_NO);
}
#endif
// Initialise a giopServerThreadWrapper singelton
omniORB::giopServerThreadWrapper::setGiopServerThreadWrapper(
new omniORB::giopServerThreadWrapper);
// Start the thread to cleanup idle outgoing strands.
StrandScavenger::initOutScavenger();
#ifdef _USE_BOOTSTRAP_PROTOCOL
{
tcpSocketEndpoint e(omniORB::InitialHost, omniORB::InitialPort);
Rope *rope = tcpOutgoingFactory->findOrCreateOutgoing(&e);
if(rope == 0)
throw CORBA::INITIALIZE(0,CORBA::COMPLETED_NO);
try {
char _key[] = { 'I', 'N', 'I', 'T' };
GIOP_C _giopc(rope);
CORBA::ULong _msgsize = GIOP_C::RequestHeaderSize(sizeof(_key),4);
CORBA::String_member _name_service;
_name_service = CORBA::string_dup("NameService");
_msgsize = _name_service.NP_alignedSize(_msgsize);
_giopc.InitialiseRequest(_key,sizeof(_key),(char
*)"get",4,_msgsize,0);
_name_service >>= _giopc;
int result = _giopc.ReceiveReply();
switch(result)
{
case GIOP::NO_EXCEPTION:
NameServiceRef = CORBA::Object::unmarshalObjRef(_giopc);
break;
default:
throw CORBA::INITIALIZE(0,CORBA::COMPLETED_NO);
break;
}
}
catch(...)
{
// get configuration information from config file
initFile configFile;
configFile.initialize();
NameServiceRef = configFile.NameService();
}
rope->decrRefCount();
}
#endif
}
catch (const CORBA::INITIALIZE &ex) {
throw;
}
catch (...) {
throw CORBA::INITIALIZE(0,CORBA::COMPLETED_NO);
}
orb = new CORBA::ORB;
return orb;
}