[omniORB] Questions about Naming Service

Walt Yao Walt.Yao@cl.cam.ac.uk
Fri, 30 Apr 1999 18:34:55 +0100


> Now my problem:
> I would like to bind a object, say an object called Obj1 to a tree like=
 say:
> 	root
> 	|
> 	text.kind
> 	|
> 	shorttext.kind
> 	|
> 	Obj1.kind
> =

> Is it possible for me to do something like:
> 	CosNaming::Name contextName;
> 	CosNaming::NamingContext_var pathContext;
> =

> 	contextName.length(2);
> 	contextName[0].id=3D"text";
> 	contextName[0].kind=3D"kind";
> 	contextName[1].id=3D"shorttext";
> 	contextName[1].kind=3D"kind";
> =

> 	pathContext=3DrootContext->bind_new_context(contextName,  p_orb);
> =

> // and then eventually bind the object under the name Obj1.kind:
> =

Your question puts in a shorter form is that you want to create several l=
evels =

of contexts in one call to bind_new_context().  No, this will not work.  =
A =

'NotFound' exception will be thrown.  If you refer to the Naming Service =

standard, you'll find the semantics of bind_new_context is defined as fol=
lows:

ctx->bind_new_context (<c1; c2; ...; cn>) is equivalent to =

(ctx->resolve(<c1; c2; ...; cn-1>))->bind_new_context (<cn>)

since you don't have the context 'text' and 'shorttext' present at the ti=
me of =

calling bind_new_context, this will fail.

I know it's slightly inconvenient, but you have to stick to new_context()=
 for every level in a path.

// Walt