/** * Context.rebind() requires that all intermediate contexts and the target context (that named by * all but terminal atomic component of the name) must already exist, otherwise * NameNotFoundException is thrown. This method behaves similar to Context.rebind(), but creates * intermediate contexts, if necessary. */ public static void rebind(final Context c, final String jndiName, final Object o) throws NamingException { Context context = c; String name = jndiName; int idx = jndiName.lastIndexOf('/'); if (idx != -1) { context = JNDIUtil.createContext(c, jndiName.substring(0, idx)); name = jndiName.substring(idx + 1); } boolean failed = false; try { context.rebind(name, o); } catch (Exception ignored) { failed = true; } if (failed) { context.bind(name, o); } }
public static void tearDownRecursively(final Context c) throws Exception { for (NamingEnumeration ne = c.listBindings(""); ne.hasMore();) { Binding b = (Binding)ne.next(); String name = b.getName(); Object object = b.getObject(); if (object instanceof Context) { JNDIUtil.tearDownRecursively((Context)object); } c.unbind(name); } }
public static void tearDownRecursively(final Context c) throws Exception { for (NamingEnumeration<Binding> ne = c.listBindings(""); ne.hasMore();) { Binding b = ne.next(); String name = b.getName(); Object object = b.getObject(); if (object instanceof Context) { JNDIUtil.tearDownRecursively((Context)object); } c.unbind(name); } }
Context c = org.hornetq.utils.JNDIUtil.createContext(context, parentContext);
Context c = org.hornetq.utils.JNDIUtil.createContext(context, parentContext);
/** * Context.rebind() requires that all intermediate contexts and the target context (that named by * all but terminal atomic component of the name) must already exist, otherwise * NameNotFoundException is thrown. This method behaves similar to Context.rebind(), but creates * intermediate contexts, if necessary. */ public static void rebind(final Context c, final String jndiName, final Object o) throws NamingException { Context context = c; String name = jndiName; int idx = jndiName.lastIndexOf('/'); if (idx != -1) { context = JNDIUtil.createContext(c, jndiName.substring(0, idx)); name = jndiName.substring(idx + 1); } boolean failed = false; try { context.rebind(name, o); } catch (Exception ignored) { failed = true; } if (failed) { context.bind(name, o); } }