* @param obj the CORBA object to be bound.
* @throws Exception if an error occurs while binding the object.
*/
public static synchronized void rebind(final NamingContextExt ctx, final String strName, final org.omg.CORBA.Object obj) throws Exception {
final NameComponent[] name = ctx.to_name(strName);
NamingContext intermediateCtx = ctx;
for (int i = 0; i < name.length - 1; i++) {
final NameComponent[] relativeName = new NameComponent[]{name[i]};
try {
intermediateCtx = NamingContextHelper.narrow(
intermediateCtx.resolve(relativeName));
} catch (NotFound e) {
intermediateCtx = intermediateCtx.bind_new_context(relativeName);
}
}
intermediateCtx.rebind(new NameComponent[]{name[name.length - 1]}, obj);
}