ctx.rebind(name, val); Name n = ctx.getNameParser( "" ).parse( name ); while ( n.size() > 1 ) { final String ctxName = n.get( 0 ); subctx = (Context) ctx.lookup( ctxName ); ctx = ctx.createSubcontext( ctxName ); n = n.getSuffix( 1 ); ctx.rebind( n, val );
/** {@inheritDoc} */ public Name composeName(Name name, Name prefix) throws NamingException { final Name result = (Name) prefix.clone(); if (name instanceof CompositeName) { if (name.size() == 1) { // name could be a nested name final String firstComponent = name.get(0); result.addAll(parseName(firstComponent)); } else { result.addAll(name); } } else { result.addAll(new CompositeName(name.toString())); } return result; }
public Object lookup(final Name name) throws NamingException { Assert.checkNotNullParam("name", name); if (name instanceof CompositeName) { if (name.isEmpty()) { return lookupNative(new SimpleName()); } final String first = name.get(0); final Object next = lookup(getNativeNameParser().parse(first)); if (name.size() == 1) { return next; } else if (next instanceof Context) { final Context context = (Context) next; try { return context.lookup(name.getSuffix(1)); } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { return lookupNative(name); } }
checkIsDestroyed(); Name parsedName = getParsedName(name); if (parsedName.size() == 0 || parsedName.get(0).length() == 0) { throw new InvalidNameException( "Name can not be empty!"); String nameToRemove = parsedName.get(0); if (parsedName.size() == 1) { ctxMaps.remove(nameToRemove); } else { if (boundObject instanceof Context) { ((Context) boundObject).unbind(parsedName.getSuffix(1)); } else { throw new NameNotFoundException( String.format("Can not find %s", name)); throw new NotContextException(String.format("Expected Context but found %s", boundObject));
@Override public Object lookup(Name name) throws NamingException { if (name.isEmpty()) { return this.clone(); String atomicName = normalizedName.get(0); Object atomicNameBinding = bindings.get(atomicName); if (normalizedName.size() == 1) { if (atomicNameBinding == null) { throw new NameNotFoundException("Name ["+atomicName+"] from ["+normalizedName+"] not found in this binding"); return NamingManager.getObjectInstance( atomicNameBinding, new CompositeName().add(atomicName), env); } catch (Exception e) { NamingException _e = new NamingException("NamingManager.getObjectInstance(...) failed"); _e.setRootCause(e); throw _e; return ((Context)atomicNameBinding).lookup(normalizedName.getSuffix(1)); throw new NotContextException(atomicName+" from ["+name+"] is not a context, cannot perform further lookup");
this.parent.destroySubcontext(name); else if (childName.isEmpty()) { if (!name.isEmpty()) this.parent.destroySubcontext(name.getSuffix(name.size() - 2)); else throw new NamingException(ContainerJNDIManager.JNDI_RESOURCES .getString("WinstoneContext.CantDestroyEmptyName")); } else if (childName.size() > 1) { Object ctx = lookup(childName.get(0)); if (!(ctx instanceof Context)) throw new NotContextException(ContainerJNDIManager.JNDI_RESOURCES.getString( "WinstoneContext.NotContext", new String[] { childName.get(0), ctx.getClass().getName() })); else if (ctx == null) throw new NameNotFoundException(ContainerJNDIManager.JNDI_RESOURCES.getString( "WinstoneContext.NameNotFound", childName.get(0))); else try { ((Context) ctx).destroySubcontext(childName.getSuffix(1)); } finally { ((Context) ctx).close(); Context childContext = (Context) lookup(childName.get(0)); childContext.close(); this.bindings.remove(childName.get(0));
public Object lookup(Name name) throws NamingException { if (name.isEmpty()) { return this; } String key = name.get(0); Name suffix = name.getSuffix(1); Object ret = lookupInstance(key, suffix); if (ret instanceof Context) { Context ctx = (Context) ret; if (!suffix.isEmpty()) { ret = ctx.lookup(suffix); } } if (ret == null) { throw new NameNotFoundException(name.toString()); } return ret; }
if (_nc == null) throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString()); if (name.size() == 0) return this; // %%% should clone() so that env can be changed NameComponent[] path = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.nameToCosName(name); return NamingManager.getObjectInstance(answer, name, this, _env); } catch (NamingException e) { throw e; } catch (Exception e) { NamingException ne = IIOPLogger.ROOT_LOGGER.errorGeneratingObjectViaFactory(); ne.setRootCause(e); throw ne; return cctx.lookup(cpe.getRemainingName());
result = namingStore.lookup(absoluteName,dereference); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); if (continuationContext instanceof NamingContext) { result = ((NamingContext)continuationContext).lookup(cpe.getRemainingName(), dereference); } else { result = continuationContext.lookup(cpe.getRemainingName()); throw notAContextException(absoluteName.getPrefix(absoluteName.size() - resolveResult.getRemainingName().size())); return ((NamingContext)namingContext).lookup(resolveResult.getRemainingName(), dereference); } else { return namingContext.lookup(resolveResult.getRemainingName());
public void rebind(Name name, Object obj) throws NamingException if (name.size() == 0) throw new NamingException(L.l("can't bind root")); for (; i + 1 < name.size(); i++) { String first = name.get(i); ((Context) value).bind(name.getSuffix(i + 1), obj); return; throw new NotContextException(L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value)); else throw new NameNotFoundException(getFullPath(name)); String first = name.get(i);
public Context createSubcontext(Name name) throws NamingException { if (name.size() == 0) throw new NamingException(L.l("can't create root subcontext")); AbstractModel model = _model; int i = 0; for (; i + 1 < name.size(); i++) { String first = name.get(i); Object value = model.lookup(first); if (value instanceof AbstractModel) { model = (AbstractModel) value; continue; } value = dereference(value, null, model); if (value instanceof Context) { return ((Context) value).createSubcontext(name.getSuffix(i + 1)); } else if (value != null) throw new NotContextException(L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value)); else throw new NameNotFoundException(getFullPath(name)); } String first = name.get(i); model = model.createSubcontext(first); return create(getFullPath(name), model, _env); }
public void start() throws Exception { Context baseCtx = ctx; Name name = baseCtx.getNameParser("").parse(jndiName); baseCtx = Util.createSubcontext(baseCtx, name.getPrefix(name.size() - 1)); String atom = name.get(name.size() - 1); RefAddr refAddr = new StringRefAddr(JndiSessionProxyObjectFactory.REF_ADDR_NAME_JNDI_BINDING_DELEGATE_PROXY_FACTORY, atom + PROXY_FACTORY_NAME); Reference ref = new Reference("java.lang.Object", refAddr, JndiSessionProxyObjectFactory.class.getName(), null); try { Util.rebind(baseCtx, atom, ref); } catch (NamingException e) { NamingException namingException = new NamingException("Could not bind producer factory into JNDI under jndiName: " + baseCtx.getNameInNamespace() + "/" + atom); namingException.setRootCause(e); throw namingException; } }
public void destroySubcontext(Name name) throws NamingException { if (name.size() == 0) throw new NamingException(L.l("can't destroy root subcontext")); AbstractModel model = _model; int i = 0; for (; i + 1 < name.size(); i++) { String first = name.get(i); Object value = model.lookup(first); if (value instanceof AbstractModel) { model = (AbstractModel) value; continue; } value = dereference(value, null, model); if (value instanceof Context) { ((Context) value).destroySubcontext(name.getSuffix(i + 1)); return; } else if (value != null) throw new NotContextException(L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value)); else throw new NameNotFoundException(getFullPath(name)); } String first = name.get(i); model.unbind(first); }
checkIsDestroyed(); Name parsedName = getParsedName(name); if (parsedName.size() == 0) { Vector bindings = new Vector(); Iterator iterat = ctxMaps.keySet().iterator(); Object subContext = ctxMaps.get(parsedName.get(0)); if (subContext instanceof Context) { Name nextLayer = nameParser.parse(""); if (parsedName.size() > 1) { nextLayer = parsedName.getSuffix(1); return ((Context) subContext).list(nextLayer); if (subContext == null && !ctxMaps.containsKey(parsedName.get(0))) { throw new NameNotFoundException( String.format("Name %s not found", name)); } else { throw new NotContextException(String.format("Expected Context but found %s", subContext));
/** * @see javax.naming.Context#unbind(javax.naming.Name) */ public void unbind(Name name) throws NamingException { if(name.isEmpty()) { throw new InvalidNameException("Cannot unbind to empty name"); } if(name.size() == 1) { if(table.containsKey(name)) { table.remove(name); } return; } /* Look up the target context first. */ Object targetContext = lookup(name.getPrefix(name.size() - 1)); if(targetContext == null || !(targetContext instanceof Context)) { throw new NamingException("Cannot unbind object. Target context does not exist."); } ((Context)targetContext).unbind(name.getSuffix(name.size() - 1)); }
public void rebind(final Name name, final Object obj) throws NamingException { Assert.checkNotNullParam("name", name); if (name.isEmpty()) { throw log.invalidEmptyName(); } if (name instanceof CompositeName) { final String first = name.get(0); final Name firstName = getNativeNameParser().parse(first); if (name.size() == 1) { rebindNative(firstName, obj); return; } final Object next = lookup(firstName); if (next instanceof Context) { final Context context = (Context) next; try { context.rebind(name.getSuffix(1), obj); } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { rebindNative(name, obj); } }
public void bind(final Name name, final Object obj) throws NamingException { Assert.checkNotNullParam("name", name); if (name.isEmpty()) { throw log.invalidEmptyName(); } if (name instanceof CompositeName) { final String first = name.get(0); final Name firstName = getNativeNameParser().parse(first); if (name.size() == 1) { bindNative(firstName, obj); return; } final Object next = lookup(firstName); if (next instanceof Context) { final Context context = (Context) next; try { context.bind(name.getSuffix(1), obj); } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { bindNative(name, obj); } }