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 );
if (cname.size() == 0) String firstComponent = cname.get(0); Object ctx = null; throw new NameNotFoundException (); ctx = binding.getObject(); ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), this, _env); throw new NamingException (e.getMessage()); throw new NotContextException(); return ((Context)ctx).listBindings (cname.getSuffix(1));
Context c = (Context)ctx.lookup (name); NameParser parser = c.getNameParser(""); NamingEnumeration enm = ctx.listBindings(name); while (enm.hasMore()) if (b.getObject() instanceof Context) map.putAll(flattenBindings (c, b.getName())); Name compoundName = parser.parse (c.getNameInNamespace()); compoundName.add(b.getName()); map.put (compoundName.toString(), b.getObject());
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); } }
NameParser parser = ctx.getNameParser(""); String securityDomain = null; Name name = null; name = parser.parse((String) args[0]); else name = (Name) args[0]; securityDomain = name.get(0); SecurityDomainContext val = (SecurityDomainContext) args[1]; securityManagerMap.put(securityDomain, val); throw SecurityLogger.ROOT_LOGGER.operationNotSupported(method); if (args[0] instanceof String) name = parser.parse((String) args[0]); else name = (Name) args[0]; securityDomain = name.get(0); SecurityDomainContext securityDomainCtx = lookupSecurityDomain(securityManagement, securityManagerMap, securityDomain); Object binding = securityDomainCtx.getAuthenticationManager(); if (name.size() == 2) { String request = name.get(1); binding = lookup(securityDomainCtx, request);
@Override public Object lookup(final String name) throws NamingException { Assert.checkNotNullParam("name", name); final ReparsedName reparsedName = reparse(getNameParser().parse(name)); if (reparsedName.isEmpty()) { return new WildFlyRootContext(environment.clone(), namingProviderFactories, namingContextFactories); } ContextResult result = getProviderContext(reparsedName.getUrlScheme()); if(result.oldStyle) { return result.context.lookup(name); } else { return result.context.lookup(reparsedName.getName()); } }
public static void rebind(Context ctx, String strName, Object value) throws javax.naming.NamingException { Name name = ctx.getNameParser("").parse(strName); int size = name.size(); String atom = name.get(size - 1); Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); String key = parentCtx.getNameInNamespace() + "/" + atom; wrapperMap.put(key, value); String className = value.getClass().getName(); String factory = NonSerializableFactory.class.getName(); StringRefAddr addr = new StringRefAddr("nns", key); Reference memoryRef = new Reference(className, addr, factory, null); parentCtx.rebind(atom, memoryRef); }
/** Join two names together. These are treated as * CompoundNames. * * @param name a <code>Name</code> value * @param prefix a <code>Name</code> value * @return a <code>Name</code> value * @exception NamingException if an error occurs */ public String composeName (String name, String prefix) throws NamingException { if (name == null) throw new NamingException ("Name cannot be null"); if (prefix == null) throw new NamingException ("Prefix cannot be null"); Name compoundName = _parser.parse(prefix); compoundName.add (name); return compoundName.toString(); }
checkIsDestroyed(); Name parsedName = getParsedName(name); if (parsedName.size() == 0) { Vector bindings = new Vector(); Iterator iterat = ctxMaps.keySet().iterator(); while (iterat.hasNext()) { String bindingName = (String) iterat.next(); bindings.addElement(new Binding(bindingName, ctxMaps.get(bindingName))); 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 {
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 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); } }
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 unbind(final Name name) 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) { unbindNative(firstName); return; } final Object next = lookup(firstName); if (next instanceof Context) { final Context context = (Context) next; try { context.unbind(name.getSuffix(1)); } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { unbindNative(name); } }
public CloseableNamingEnumeration<Binding> listBindings(final Name name) throws NamingException { Assert.checkNotNullParam("name", name); if (name instanceof CompositeName) { if (name.isEmpty()) { return listBindingsNative(new SimpleName()); } final String first = name.get(0); final Name firstName = getNativeNameParser().parse(first); if (name.size() == 1) { return listBindingsNative(firstName); } final Object next = lookup(firstName); if (next instanceof Context) { final Context context = (Context) next; try { return CloseableNamingEnumeration.fromEnumeration(context.listBindings(name.getSuffix(1))); } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { return listBindingsNative(name); } }
public CloseableNamingEnumeration<NameClassPair> list(final Name name) throws NamingException { Assert.checkNotNullParam("name", name); if (name instanceof CompositeName) { if (name.isEmpty()) { return listNative(new SimpleName()); } final String first = name.get(0); final Name firstName = getNativeNameParser().parse(first); if (name.size() == 1) { return listNative(firstName); } final Object next = lookup(firstName); if (next instanceof Context) { final Context context = (Context) next; try { return CloseableNamingEnumeration.fromEnumeration(context.list(name.getSuffix(1))); } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { return listNative(name); } }
public String composeName(final String name, final String prefix) throws NamingException { Assert.checkNotNullParam("name", name); Assert.checkNotNullParam("prefix", prefix); return composeName(getNameParser().parse(name), getNameParser().parse(prefix)).toString(); }
public void destroySubcontext(final Name name) 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) { destroySubcontext(firstName); return; } final Object next = lookup(firstName); if (next instanceof Context) { final Context context = (Context) next; try { context.destroySubcontext(name.getSuffix(1)); return; } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { destroySubcontextNative(name); } }
public void rename(final Name oldName, final Name newName) throws NamingException { Assert.checkNotNullParam("oldName", oldName); Assert.checkNotNullParam("newName", newName); if (oldName.isEmpty() || newName.isEmpty()) { throw log.invalidEmptyName(); final String oldFirst = oldName.get(0); final Name oldFirstName = getNativeNameParser().parse(oldFirst); final Name newFirstName; if (newName instanceof CompositeName) { newFirstName = getNativeNameParser().parse(newName.get(0)); } else { newFirstName = newName; final Context context = (Context) next; try { context.rename(oldName.getSuffix(1), newName.getSuffix(1)); } finally { NamingUtils.safeClose(context); if (newName instanceof CompositeName) { if (newName.size() == 1) { target = getNativeNameParser().parse(newName.get(0)); } else { throw log.renameAcrossProviders(oldName, newName);
public Context createSubcontext(final Name name) throws NamingException { 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) { return createSubcontext(firstName); } final Object next = lookup(firstName); if (next instanceof Context) { final Context context = (Context) next; try { return context.createSubcontext(name.getSuffix(1)); } finally { NamingUtils.safeClose(context); } } else { throw log.notContextInCompositeName(first); } } else { return createSubcontextNative(name); } }
/** * @see javax.naming.Context#createSubcontext(javax.naming.Name) */ public Context createSubcontext(Name name) throws NamingException { Context newContext; /* Get the subcontexts of /this/ subcontext. */ Hashtable subContexts = getSubContexts(); if(name.size() > 1) { if(subContexts.containsKey(name.getPrefix(1))) { Context subContext = (Context)subContexts.get(name.getPrefix(1)); newContext = subContext.createSubcontext(name.getSuffix(1)); return newContext; } throw new NameNotFoundException("The subcontext " + name.getPrefix(1) + " was not found."); } if(lookup(name) != null) { throw new NameAlreadyBoundException(); } Name contextName = getNameParser((Name)null).parse(getNameInNamespace()); contextName.addAll(name); newContext = new MemoryContext(this); ((AbstractContext)newContext).setNameInNamespace(contextName); bind(name, newContext); return newContext; } }