I have a name list consisting of 4 contexts. Context 1,2 and 3 are binded to the root node, and context 4 is binded to context 2. I am able to list the name of context 1-3 but I cant get context 4.
It is only listing nodes at the first level. I think that if I check each node, check if it has sub-nodes and then list them that will work but I am not sure how do do that. Here is my code. I have two methods to list the contexts
import java.io.*;
import org.omg.CORBA.*;
import HelloNaming.*;
import org.omg.CosNaming.* ;
import org.omg.CosNaming.NamingContextPackage.*;
public class HelloNamingClient
{
public static void main(String args[])
{
try{
NameComponent nc[]= new NameComponent[2];
ORB orb = ORB.init(args, null);
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext rootCtx = NamingContextHelper.narrow(objRef);
final int batchSize = 7;
BindingIterator b ;
BindingListHolder bList = new BindingListHolder() ;
BindingIteratorHolder bIterator = new BindingIteratorHolder();
rootCtx.list(batchSize, bList, bIterator) ;
for (int i=0; i<bList.value.length; i++) {
System.out.println(bList.value[i].binding_name[0].id) ;
}
NamingContextExt ncc =
NamingContextExtHelper.narrow(orb.resolve_initial_references(
"NameService"));
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder blIt= new BindingIteratorHolder();
ncc.list(1000, bl, blIt);
Binding bindings[] = bl.value;
for (int i=0; i < bindings.length; i++) {
int lastIx = bindings[i].binding_name.length-1;
if (bindings[i].binding_type == BindingType.ncontext) {
System.out.println( "Context: " +
bindings[i].binding_name[lastIx].id);
} else {
System.out.println("Object: " +
bindings[i].binding_name[lastIx].id);
}
}
} catch (Exception e) {
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}