106 for(CORBA::ULong i=0; i<n.length(); i++)
108 os<<
"/"<<n[i].id.in();
109 const char* kind =n[i].kind.in();
119 CosNaming::Name name;
120 CORBA::ULong nameLen=0;
121 name.length(nameLen);
124 string::size_type pos=0;
128 pos=n.find_first_not_of(
"/.",pos);
129 if(string::npos==pos)
break;
130 string::size_type sep =n.find_first_of(
"/.",pos);
131 string piece =n.substr(pos, (string::npos==sep? sep: sep-pos) );
134 name.length(++nameLen);
135 name[nameLen-1].id=CORBA::string_dup(piece.c_str());
139 name[nameLen-1].kind=CORBA::string_dup(piece.c_str());
141 if(string::npos==sep)
break;
150 CosNaming::NamingContext_ptr namingContext,
151 const CosNaming::Name& name,
152 CORBA::Object_ptr obj
156 if(CORBA::is_nil(namingContext))
165 for(CORBA::ULong i=0; i<(name.length()-1); ++i)
170 namingContext=namingContext->bind_new_context(n);
172 catch(CosNaming::NamingContext::AlreadyBound&)
174 CORBA::Object_var obj2 =namingContext->resolve(n);
175 namingContext=CosNaming::NamingContext::_narrow(obj2);
178 if(CORBA::is_nil(namingContext))
182 n[0]=name[name.length()-1];
185 namingContext->bind(n,obj);
187 catch(CosNaming::NamingContext::AlreadyBound& ex)
190 namingContext->rebind(n,obj);
195 catch (CORBA::COMM_FAILURE& ex)
197 cerr <<
"Caught system exception COMM_FAILURE, unable to contact the "
198 <<
"naming service." << endl;
200 catch (omniORB::fatalException& ex)
202 cerr <<
"Caught omniORB fatal exception binding " << name << endl;
205 catch (CORBA::SystemException& ex)
207 const char* exName =NULL;
208 const char* exMinor =NULL;
210 exName =ex.NP_minorString();
211 exMinor=ex.NP_minorString();
213 cerr<<
"System exception binding "<<name;
217 cerr<<
" ("<<exMinor<<
")";
220 catch (CORBA::Exception& ex)
222 cerr<<
"CORBA exception binding "<<name
ostream & operator<<(ostream &os, const CosNaming::Name &n)
int bindName2Object(CosNaming::NamingContext_ptr namingContext, const CosNaming::Name &name, CORBA::Object_ptr obj)
Binds CosNaming::Name to object in the naming service.
CosNaming::Name str2name(const char *namestr)
Converts stringified name to naming service name.