Link to home
Start Free TrialLog in
Avatar of khbh
khbh

asked on

Search for CORBA binding instead of a static name

Instead of looking up a static CORBA binding I would like to search the bindings to find the desired one. The desired binding will have a name that follows a specific pattern, i.e. the version will be appended at the end.


Today I have the following in my code:
private static final String NAME = "aName";
...
org.omg.CORBA.Object nsObj = orb.resolve_initial_references("NameService");
org.omg.CosNaming.NamingContext namingContext = org.omg.CosNaming.NamingContextHelper.narrow(nsObj);
org.omg.CosNaming.NameComponent[] nc = { new org.omg.CosNaming.NameComponent(NAME, "") };
org.omg.CORBA.Object cfObj = namingContext.resolve(nc);
myObj = MyHelper.narrow(cfObj);


I would like to have something like:
org.omg.CORBA.Object nsObj = orb.resolve_initial_references("NameService");
org.omg.CosNaming.NamingContext namingContext = org.omg.CosNaming.NamingContextHelper.narrow(nsObj);
String theName = ???; // Something that matches "aName*", where * is the version number
org.omg.CosNaming.NameComponent[] nc = { new org.omg.CosNaming.NameComponent(theName, "") };
org.omg.CORBA.Object cfObj = namingContext.resolve(nc);
myObj = MyHelper.narrow(cfObj);

Any clues?
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of khbh
khbh

ASKER

OK, I've done an ugly hack that loops over the versions and has a try-catch clause.

Thanks!