 |
|
| Computers Forum Index » Computer - Object (Corba) » [Q] cannot bind to Compound name using Java 1.6 Corba... |
|
Page 1 of 1 |
|
| Author |
Message |
| VSP... |
Posted: Mon May 18, 2009 5:09 am |
|
|
|
Guest
|
I have been trying to get this to work for about 10 hours but
no matter what I try it does not work.
Basically my Combond name is
Level1->Level2->object
so all I want to do is to fist see if
Level1->Level2 naming contexts exist, if not create them
and then bind the objec to them
But Sun returns NotFound when I am trying to use
bind_new_context and I just cannot figure out why
(my naming server is OmniOrb, and it appears that I can do things
if my Contexts are not combound (that is there is only Level1)
here is the code
what am I doing wrong?
---------------------------
org.omg.CosNaming.NameComponent lvl1Name=new
org.omg.CosNaming.NameComponent("Level1","kind1");
org.omg.CosNaming.NameComponent lvl2Name=new
org.omg.CosNaming.NameComponent("Level2","kind2");
org.omg.CosNaming.NameComponent[] nameTree1={lvl1Name};
org.omg.CosNaming.NameComponent[] nameTree2={lvl2Name};
org.omg.CosNaming.NameComponent[] nameTree=new
org.omg.CosNaming.NameComponent[2];
nameTree[0]=lvl1Name;
nameTree[1]=lvl2Name;
NamingContext currContext=null;
try{
//fails when tree is more than 1
currContext=rootContext.bind_new_context(nameTree);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
System.out.println("nameTree already bound");
}
catch (org.omg.CosNaming.NamingContextPackage.NotFound ex)
{
System.out.println("BIGPROBLEM nameTree not found: "+ex);
}
/* Now, bind the server to the naming context tree we have done
above */
NameComponent lvl3Name=
new NameComponent("OBJNM__monster__2800","aa_bbb");
NameComponent[] last={lvl1Name,lvl2Name,lvl3Name};
try
{
currContext.bind(last,obj);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
// if the context already exists then we just need to bind the object
//to that naming context
currContext.rebind(last, obj);
}
-------------------------
I also tried to bind piece by piece, but I do not think it is possible
because while I can bind_new_context for level 1 and then for level2
if both level1 and level2 exist (created by another server)
the there is no way for me to get the NamingContext
of the Level1->Level2
I tried bind_context (nameTree,newContext) and the newContext
never gets reset to anything valid;
thank you in advance,
VSP |
|
|
| Back to top |
|
|
|
| VSP... |
Posted: Mon May 18, 2009 4:52 pm |
|
|
|
Guest
|
Thank you very much for reply
That is true, if I think of it
I cannot go to a root file system and do
mkdir Level1/Level2
I have to do either
1)
Mkdir Level1
cd Level1
mkdir Level2
or
2)
mkdir Level1
mkdir Level1/Level2
The 2) option worked for me.
I cannot however understand how in corba
I can do the first way, when Level1 and Level 2 already exist
for example, I cannot understand how to
obtain a NamingContext of a second level
when Level 1 and Level 2 already exist
When I try
curr=bind_new_context on level 1 it throughs exception that it is
already bound
that's fine, but it also does NOT assign anything to 'curr'
when I then try
curr=null;
....
catch (AlreadyBound )
{
rootContext.bind_context( Level1, curr)
}
that does not work either (curr remains empty)
so how do I 'walk' a graph when first level and second level are
NamingContextes and not object
?
thank you
On May 18, 9:56 am, "Raghu V. Hudli" <d... at (no spam) spam.mail> wrote:
Quote: VSP wrote:
I have been trying to get this to work for about 10 hours but
no matter what I try it does not work.
Basically my Combond name is
Level1->Level2->object
so all I want to do is to fist see if
Level1->Level2 naming contexts exist, if not create them
and then bind the objec to them
But Sun returns NotFound when I am trying to use
bind_new_context and I just cannot figure out why
(my naming server is OmniOrb, and it appears that I can do things
if my Contexts are not combound (that is there is only Level1)
here is the code
what am I doing wrong?
---------------------------
org.omg.CosNaming.NameComponent lvl1Name=new
org.omg.CosNaming.NameComponent("Level1","kind1");
org.omg.CosNaming.NameComponent lvl2Name=new
org.omg.CosNaming.NameComponent("Level2","kind2");
org.omg.CosNaming.NameComponent[] nameTree1={lvl1Name};
org.omg.CosNaming.NameComponent[] nameTree2={lvl2Name};
org.omg.CosNaming.NameComponent[] nameTree=new
org.omg.CosNaming.NameComponent[2];
nameTree[0]=lvl1Name;
nameTree[1]=lvl2Name;
NamingContext currContext=null;
try{
//fails when tree is more than 1
currContext=rootContext.bind_new_context(nameTree);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
System.out.println("nameTree already bound");
}
catch (org.omg.CosNaming.NamingContextPackage.NotFound ex)
{
System.out.println("BIGPROBLEM nameTree not found: "+ex);
}
/* Now, bind the server to the naming context tree we have done
above */
NameComponent lvl3Name> > new NameComponent("OBJNM__monster__2800","aa_bbb");
NameComponent[] last={lvl1Name,lvl2Name,lvl3Name};
try
{
currContext.bind(last,obj);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
// if the context already exists then we just need to bind the object
//to that naming context
currContext.rebind(last, obj);
}
-------------------------
I also tried to bind piece by piece, but I do not think it is possible
because while I can bind_new_context for level 1 and then for level2
if both level1 and level2 exist (created by another server)
the there is no way for me to get the NamingContext
of the Level1->Level2
I tried bind_context (nameTree,newContext) and the newContext
never gets reset to anything valid;
thank you in advance,
VSP
Think of the naming graph to be much like a file system with contexts
being subdirectories or folders and object bindings to be like files.
Just like in the file system, where you need to make sure
all sub directories/folders in the path to create a file, in CosNaming
you need to make sure each
intermediate naming context object exists. Your approach of binding
"piece by piece" is correct and should work. The naming context of
Level1->Level2 can be obtained by invoking resolve
on the root name context with nameTree as the name. Alternatively, you
can bind last (name) to obj by invoking bind on the root name context.
Hope this helps...
Raghu |
|
|
| Back to top |
|
|
|
| Raghu V. Hudli... |
Posted: Mon May 18, 2009 6:08 pm |
|
|
|
Guest
|
VSP wrote:
Quote: I have been trying to get this to work for about 10 hours but
no matter what I try it does not work.
Basically my Combond name is
Level1->Level2->object
so all I want to do is to fist see if
Level1->Level2 naming contexts exist, if not create them
and then bind the objec to them
But Sun returns NotFound when I am trying to use
bind_new_context and I just cannot figure out why
(my naming server is OmniOrb, and it appears that I can do things
if my Contexts are not combound (that is there is only Level1)
here is the code
what am I doing wrong?
---------------------------
org.omg.CosNaming.NameComponent lvl1Name=new
org.omg.CosNaming.NameComponent("Level1","kind1");
org.omg.CosNaming.NameComponent lvl2Name=new
org.omg.CosNaming.NameComponent("Level2","kind2");
org.omg.CosNaming.NameComponent[] nameTree1={lvl1Name};
org.omg.CosNaming.NameComponent[] nameTree2={lvl2Name};
org.omg.CosNaming.NameComponent[] nameTree=new
org.omg.CosNaming.NameComponent[2];
nameTree[0]=lvl1Name;
nameTree[1]=lvl2Name;
NamingContext currContext=null;
try{
//fails when tree is more than 1
currContext=rootContext.bind_new_context(nameTree);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
System.out.println("nameTree already bound");
}
catch (org.omg.CosNaming.NamingContextPackage.NotFound ex)
{
System.out.println("BIGPROBLEM nameTree not found: "+ex);
}
/* Now, bind the server to the naming context tree we have done
above */
NameComponent lvl3Name=
new NameComponent("OBJNM__monster__2800","aa_bbb");
NameComponent[] last={lvl1Name,lvl2Name,lvl3Name};
try
{
currContext.bind(last,obj);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
// if the context already exists then we just need to bind the object
//to that naming context
currContext.rebind(last, obj);
}
-------------------------
I also tried to bind piece by piece, but I do not think it is possible
because while I can bind_new_context for level 1 and then for level2
if both level1 and level2 exist (created by another server)
the there is no way for me to get the NamingContext
of the Level1->Level2
I tried bind_context (nameTree,newContext) and the newContext
never gets reset to anything valid;
thank you in advance,
VSP
Think of the naming graph to be much like a file system with contexts
being subdirectories or folders and object bindings to be like files.
Just like in the file system, where you need to make sure
all sub directories/folders in the path to create a file, in CosNaming
you need to make sure each
intermediate naming context object exists. Your approach of binding
"piece by piece" is correct and should work. The naming context of
Level1->Level2 can be obtained by invoking resolve
on the root name context with nameTree as the name. Alternatively, you
can bind last (name) to obj by invoking bind on the root name context.
Hope this helps...
Raghu |
|
|
| Back to top |
|
|
|
| Raghu V. Hudli... |
Posted: Tue May 19, 2009 4:37 am |
|
|
|
Guest
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
VSP wrote:
<blockquote
cite="mid:c0adb5ae-3907-4fae-99a9-3ec2912c7100 at (no spam) r34g2000vba.googlegroups.com"
type="cite">
<pre wrap="">Thank you very much for reply
That is true, if I think of it
I cannot go to a root file system and do
mkdir Level1/Level2
I have to do either
1)
Mkdir Level1
cd Level1
mkdir Level2
or
2)
mkdir Level1
mkdir Level1/Level2
The 2) option worked for me.
I cannot however understand how in corba
I can do the first way, when Level1 and Level 2 already exist
for example, I cannot understand how to
obtain a NamingContext of a second level
when Level 1 and Level 2 already exist
</pre>
</blockquote>
As you would know to get any object reference, including one for naming
context,<br>
you have to resolve a name. As I wrote earlier,
rootContext.resolve(nameOfLevel2Context)<br>
will give you the NamingContext of Level2. <br>
<br>
<blockquote
cite="mid:c0adb5ae-3907-4fae-99a9-3ec2912c7100 at (no spam) r34g2000vba.googlegroups.com"
type="cite">
<pre wrap="">
When I try
curr=bind_new_context on level 1 it throughs exception that it is
already bound
that's fine, but it also does NOT assign anything to 'curr'
when I then try
curr=null;
....
catch (AlreadyBound )
{
rootContext.bind_context( Level1, curr)
}
that does not work either (curr remains empty)
so how do I 'walk' a graph when first level and second level are
NamingContextes and not object
?
</pre>
</blockquote>
You can invoke the "list" method on any context. You will get a
sequence of Bindings and<br>
a BindingIterator to iterate through the rest. Each Binding will tell
you whether the binding <br>
is for a context or a (non naming context) object. For the bindings of
a context type you <br>
can invoke list and walk the graph. Binding also returns the name of
the binding. <br>
<br>
Again, here think of "ls" or "dir" command. These list "files" in the
directory or folder.<br>
Subdirectories are special files that one can "cd" to and further "ls"
or "dir". <br>
<br>
Raghu<br>
<br>
<blockquote
cite="mid:c0adb5ae-3907-4fae-99a9-3ec2912c7100 at (no spam) r34g2000vba.googlegroups.com"
type="cite">
<pre wrap="">thank you
On May 18, 9:56 am, "Raghu V. Hudli" <a class="moz-txt-link-rfc2396E" href="mailto:d... at (no spam) spam.mail"><d... at (no spam) spam.mail></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">VSP wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I have been trying to get this to work for about 10 hours but
no matter what I try it does not work.
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">Basically my Combond name is
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">Level1->Level2->object
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">so all I want to do is to fist see if
Level1->Level2 naming contexts exist, if not create them
and then bind the objec to them
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">But Sun returns NotFound when I am trying to use
bind_new_context and I just cannot figure out why
(my naming server is OmniOrb, and it appears that I can do things
if my Contexts are not combound (that is there is only Level1)
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">here is the code
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">what am I doing wrong?
---------------------------
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">org.omg.CosNaming.NameComponent lvl1Name=new
org.omg.CosNaming.NameComponent("Level1","kind1");
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">org.omg.CosNaming.NameComponent lvl2Name=new
org.omg.CosNaming.NameComponent("Level2","kind2");
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">org.omg.CosNaming.NameComponent[] nameTree1={lvl1Name};
org.omg.CosNaming.NameComponent[] nameTree2={lvl2Name};
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">org.omg.CosNaming.NameComponent[] nameTree=new
org.omg.CosNaming.NameComponent[2];
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">nameTree[0]=lvl1Name;
nameTree[1]=lvl2Name;
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">NamingContext currContext=null;
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap=""> try{
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">//fails when tree is more than 1
currContext=rootContext.bind_new_context(nameTree);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
System.out.println("nameTree already bound");
}
catch (org.omg.CosNaming.NamingContextPackage.NotFound ex)
{
System.out.println("BIGPROBLEM nameTree not found: "+ex);
}
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap=""> /* Now, bind the server to the naming context tree we have done
above */
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">NameComponent lvl3Name=
new NameComponent("OBJNM__monster__2800","aa_bbb");
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">NameComponent[] last={lvl1Name,lvl2Name,lvl3Name};
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap=""> try
{
currContext.bind(last,obj);
}
catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex)
{
// if the context already exists then we just need to bind the object
//to that naming context
currContext.rebind(last, obj);
}
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">-------------------------
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">I also tried to bind piece by piece, but I do not think it is possible
because while I can bind_new_context for level 1 and then for level2
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">if both level1 and level2 exist (created by another server)
the there is no way for me to get the NamingContext
of the Level1->Level2
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">I tried bind_context (nameTree,newContext) and the newContext
never gets reset to anything valid;
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">thank you in advance,
VSP
</pre>
</blockquote>
<pre wrap="">Think of the naming graph to be much like a file system with contexts
being subdirectories or folders and object bindings to be like files.
Just like in the file system, where you need to make sure
all sub directories/folders in the path to create a file, in CosNaming
you need to make sure each
intermediate naming context object exists. Your approach of binding
"piece by piece" is correct and should work. The naming context of
Level1->Level2 can be obtained by invoking resolve
on the root name context with nameTree as the name. Alternatively, you
can bind last (name) to obj by invoking bind on the root name context.
Hope this helps...
Raghu
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html> |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Tue Dec 01, 2009 10:50 pm
|
|