/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
private boolean bindToJndi(final String jndiName, final Object objectToBind) throws NamingException { if (context != null) { String parentContext; String jndiNameInContext; int sepIndex = jndiName.lastIndexOf('/'); if (sepIndex == -1) { parentContext = ""; } else { parentContext = jndiName.substring(0, sepIndex); } jndiNameInContext = jndiName.substring(sepIndex + 1); try { context.lookup(jndiName); //JMSServerManagerImpl.log.warn("Binding for " + jndiName + " already exists"); return false; } catch (Throwable e) { // OK } Context c = JNDIUtil.createContext(context, parentContext); c.rebind(jndiNameInContext, objectToBind); } return true; } }
/** * 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); } }
/** * 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); } }
/** * 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); } }