📄 initrefs.cc
字号:
} for (i=0; i < the_fileServiceList.length(); i++,j++) { l[j] = CORBA::string_dup(the_fileServiceList[i].id); } return result;}voidomniInitialReferences::remFromFile(const char* id){ omni_tracedmutex_lock sync(sl_lock); CORBA::ULong i; for (i=0; i < the_fileServiceList.length(); i++) { if (strcmp((const char*)the_fileServiceList[i].id, id) == 0) { for (i++; i < the_fileServiceList.length(); i++) { the_fileServiceList[i-1].id = the_fileServiceList[i].id; the_fileServiceList[i-1].uri = the_fileServiceList[i].uri; the_fileServiceList[i-1].ref = the_fileServiceList[i].ref; } the_fileServiceList.length(the_fileServiceList.length() - 1); return; } }}voidomniInitialReferences::remFromArgs(const char* id){ omni_tracedmutex_lock sync(sl_lock); CORBA::ULong i; for (i=0; i < the_argsServiceList.length(); i++) { if (strcmp((const char*)the_argsServiceList[i].id, id) == 0) { for (i++; i < the_argsServiceList.length(); i++) { the_argsServiceList[i-1].id = the_argsServiceList[i].id; the_argsServiceList[i-1].uri = the_argsServiceList[i].uri; the_argsServiceList[i-1].ref = the_argsServiceList[i].ref; } the_argsServiceList.length(the_argsServiceList.length() - 1); return; } }}voidomniInitialReferences::initialise_bootstrap_agentImpl(){ ba_lock.lock(); if( !the_bootagentImpl ) the_bootagentImpl = new CORBA_InitialReferences_i(); ba_lock.unlock();}intomniInitialReferences::invoke_bootstrap_agentImpl(omniCallHandle& handle){ omni_tracedmutex_lock sync(ba_lock); if( !the_bootagentImpl ) return 0; // The upcall asserts that a localId is set, as a sanity-check. This // is the one dispatch case in which there isn't a localIdentity, so // we pretend. handle.localId((omniLocalIdentity*)1); ((omniServant*) the_bootagentImpl)->_dispatch(handle); return 1;}intomniInitialReferences::is_bootstrap_agentImpl_initialised(){ return the_bootagentImpl ? 1 : 0;}voidomniInitialReferences::initialise_bootstrap_agent(const char* host, CORBA::UShort port){ omni_tracedmutex_lock sync(sl_lock); try { IIOP::Address addr; addr.host = host; addr.port = port; _CORBA_Unbounded_Sequence_Octet objkey; objkey.length(4); objkey[0] = 'I'; objkey[1] = 'N'; objkey[2] = 'I'; objkey[3] = 'T'; GIOP::Version ver = { 1, 0 }; omniIOR* ior= new omniIOR(CORBA_InitialReferences::_PD_repoId, objkey,&addr,1,ver,omniIOR::NoInterceptor); omniObjRef* objref = omni::createObjRef( CORBA_InitialReferences::_PD_repoId,ior,0); if (!objref->_is_nil()) { the_bootagent = (CORBA_InitialReferences_ptr) objref->_ptrToObjRef(CORBA_InitialReferences::_PD_repoId); the_bootagent->_noExistentCheck(); } } catch(...) {}}/////////////////////////////////////////////////////////////////////////////// Handlers for Configuration Options ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////class DefaultInitRefHandler : public orbOptions::Handler {public: DefaultInitRefHandler() : orbOptions::Handler("DefaultInitRef", "DefaultInitRef = <Default URI>", 1, "-ORBDefaultInitRef <Default URI> (standard option)") {} void visit(const char* value,orbOptions::Source src) throw (orbOptions::BadParam) { if (src == orbOptions::fromArgv || src == orbOptions::fromArray) { omniInitialReferences::setDefaultInitRefFromArgs(value); } else { omniInitialReferences::setDefaultInitRefFromFile(value); } } void dump(orbOptions::sequenceString& result) { const char* v; v = the_fileDefaultInitRef; orbOptions::addKVString("DefaultInitRef (file)", v ? v : "", result); v = the_argsDefaultInitRef; orbOptions::addKVString("DefaultInitRef (args)", v ? v : "", result); }};static DefaultInitRefHandler DefaultInitRefHandler_;/////////////////////////////////////////////////////////////////////////////class InitRefHandler : public orbOptions::Handler {public: InitRefHandler() : orbOptions::Handler("InitRef", "InitRef = <ObjectID>=<ObjectURI>", 1, "-ORBInitRef <ObjectID>=<ObjectURI> (standard option)") {} void visit(const char* value, orbOptions::Source src) throw (orbOptions::BadParam) { unsigned int slen = strlen(value) + 1; CORBA::String_var id(CORBA::string_alloc(slen)); CORBA::String_var uri(CORBA::string_alloc(slen)); if (sscanf(value, "%[^=]=%s", (char*)id, (char*)uri) != 2) { throw orbOptions::BadParam(key(),value,"Invalid argument, expect <ObjectID>=<ObjectURI>"); } if (src == orbOptions::fromArgv) { if (!omniInitialReferences::setFromArgs(id, uri)) { throw orbOptions::BadParam(key(),value,"Invalid argument, expect <ObjectID>=<ObjectURI>"); } } else { if (!omniInitialReferences::setFromFile(id, uri)) { throw orbOptions::BadParam(key(),value,"Invalid argument, expect <ObjectID>=<ObjectURI>"); } } } void dumpRecord(serviceRecord& rec, orbOptions::sequenceString& result) { CORBA::String_var v; v = CORBA::string_alloc(strlen(rec.id)+strlen(rec.uri)+1); sprintf(v,"%s=%s",(const char*)rec.id,(const char*)rec.uri); orbOptions::addKVString(key(),v,result); } void dump(orbOptions::sequenceString& result) { CORBA::ULong i; for (i=0; i < the_argsServiceList.length(); i++) { dumpRecord(the_argsServiceList[i],result); } for (i=0; i < the_fileServiceList.length(); i++) { dumpRecord(the_fileServiceList[i],result); } }};static InitRefHandler InitRefHandler_;/////////////////////////////////////////////////////////////////////////////class supportBootstrapAgentHandler : public orbOptions::Handler {public: supportBootstrapAgentHandler() : orbOptions::Handler("supportBootstrapAgent", "supportBootstrapAgent = 0 or 1", 1, "-ORBsupportBootstrapAgent < 0 | 1 >") {} void visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) { CORBA::Boolean v; if (!orbOptions::getBoolean(value,v)) { throw orbOptions::BadParam(key(),value, orbOptions::expect_boolean_msg); } orbParameters::supportBootstrapAgent = v; } void dump(orbOptions::sequenceString& result) { orbOptions::addKVBoolean(key(),orbParameters::supportBootstrapAgent, result); }};static supportBootstrapAgentHandler supportBootstrapAgentHandler_;/////////////////////////////////////////////////////////////////////////////class bootstrapAgentPortHandler : public orbOptions::Handler {public: bootstrapAgentPortHandler() : orbOptions::Handler("bootstrapAgentPort", "bootstrapAgentPort = <1-65535>", 1, "-ORBbootstrapAgentPort < 1-65535 >") {} void visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) { CORBA::ULong v; if (!orbOptions::getULong(value,v) || !(v >=1 && v <=65535) ) { throw orbOptions::BadParam(key(),value, "Invalid value, expect 1-65535"); } orbParameters::bootstrapAgentPort = v; } void dump(orbOptions::sequenceString& result) { orbOptions::addKVULong(key(),orbParameters::bootstrapAgentPort, result); }};static bootstrapAgentPortHandler bootstrapAgentPortHandler_;/////////////////////////////////////////////////////////////////////////////class bootstrapAgentHostnameHandler : public orbOptions::Handler {public: bootstrapAgentHostnameHandler() : orbOptions::Handler("bootstrapAgentHostname", "bootstrapAgentHostname = <hostname>", 1, "-ORBbootstrapAgentHostname <hostname>") {} void visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) { orbParameters::bootstrapAgentHostname = value; } void dump(orbOptions::sequenceString& result) { const char* v = orbParameters::bootstrapAgentHostname; if (!v) v = ""; orbOptions::addKVString(key(),v,result); }};static bootstrapAgentHostnameHandler bootstrapAgentHostnameHandler_;/////////////////////////////////////////////////////////////////////////////// Module initialiser ///////////////////////////////////////////////////////////////////////////////class omni_initRefs_initialiser : public omniInitialiser {public: omni_initRefs_initialiser() { orbOptions::singleton().registerHandler(DefaultInitRefHandler_); orbOptions::singleton().registerHandler(InitRefHandler_); orbOptions::singleton().registerHandler(supportBootstrapAgentHandler_); orbOptions::singleton().registerHandler(bootstrapAgentHostnameHandler_); orbOptions::singleton().registerHandler(bootstrapAgentPortHandler_); }#ifdef __GNUG__ virtual#endif ~omni_initRefs_initialiser() { omnivector<resolvePseudoEntry>*& the_list = thePseudoFnList(); delete the_list; the_list = 0; } void attach() { const char* v = orbParameters::bootstrapAgentHostname; if (v && strlen(v)) { omniInitialReferences::remFromFile("NameService"); omniInitialReferences::remFromFile("InterfaceRepository"); omniInitialReferences:: initialise_bootstrap_agent(orbParameters::bootstrapAgentHostname, orbParameters::bootstrapAgentPort); } } void detach() { serviceRecord* sl; sl = the_argsServiceList.get_buffer(1); delete [] sl; sl = the_fileServiceList.get_buffer(1); delete [] sl; if (the_argsDefaultInitRef) CORBA::string_free(the_argsDefaultInitRef); the_argsDefaultInitRef = 0; if (the_fileDefaultInitRef) CORBA::string_free(the_fileDefaultInitRef); the_fileDefaultInitRef = 0; if( the_bootagentImpl ) delete the_bootagentImpl; the_bootagentImpl = 0; if( the_bootagent ) CORBA::release(the_bootagent); the_bootagent = 0; }};static omni_initRefs_initialiser initialiser;omniInitialiser& omni_initRefs_initialiser_ = initialiser;OMNI_NAMESPACE_END(omni)OMNI_USING_NAMESPACE(omni)void_omni_set_NameService(CORBA::Object_ptr ns){ setFromArgs((const char*) "NameService", ns);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -