@Override protected Object doOperation(HttpServerExchange exchange, String name) throws NamingException { return localContext.createSubcontext(name); } }
@Override public Context createSubcontext(Name name) throws NamingException { return context.createSubcontext(name); }
@Override public Context createSubcontext(String name) throws NamingException { return context.createSubcontext(name); }
/** * Get subcontext. Only looks down one level. * @param subContext Name of subcontext to return. * @return Sub context. * @throws NamingException */ public static Context getSubContext(final CompoundName subContext) throws NamingException { Context context = new InitialContext(); try { context = (Context)context.lookup(subContext); } catch (NameNotFoundException e) { context = context.createSubcontext(subContext); } return context; }
@Override public Context createSubcontext(final String name) throws NamingException { return CNCtxFactory.INSTANCE.getInitialContext(environment).createSubcontext(name); }
@Override public Context createSubcontext(final Name name) throws NamingException { return CNCtxFactory.INSTANCE.getInitialContext(environment).createSubcontext(name); }
/** * Create a context path recursively. */ public static Context createContext(final Context c, final String path) throws NamingException { Context crtContext = c; for (StringTokenizer st = new StringTokenizer(path, "/"); st.hasMoreTokens(); ) { String tok = st.nextToken(); try { Object o = crtContext.lookup(tok); if (!(o instanceof Context)) { throw new NamingException("Path " + path + " overwrites and already bound object"); } crtContext = (Context) o; continue; } catch (NameNotFoundException e) { // OK } crtContext = crtContext.createSubcontext(tok); } return crtContext; }
@Override public Context createSubcontext(final Name name) throws NamingException { Assert.checkNotNullParam("name", name); final ReparsedName reparsedName = reparse(name); ContextResult result = getProviderContext(reparsedName.getUrlScheme()); if(result.oldStyle) { return result.context.createSubcontext(name); } else { return result.context.createSubcontext(reparsedName.getName()); } }
/** * Create a subcontext including any intermediate contexts. * @param ctx the parent JNDI Context under which value will be bound * @param name the name relative to ctx of the subcontext. * @return The new or existing JNDI subcontext * @throws NamingException on any JNDI failure */ private static Context createSubcontext(Context ctx, final Name name) throws NamingException { Context subctx = ctx; for (int pos = 0; pos < name.size(); pos++) { final String ctxName = name.get(pos); try { subctx = (Context) ctx.lookup(ctxName); } catch (NameNotFoundException e) { subctx = ctx.createSubcontext(ctxName); } // The current subctx will be the ctx for the next name component ctx = subctx; } return subctx; }
@Override public Context createSubcontext(final String name) throws NamingException { Assert.checkNotNullParam("name", name); final ReparsedName reparsedName = reparse(getNameParser().parse(name)); ContextResult result = getProviderContext(reparsedName.getUrlScheme()); if(result.oldStyle) { return result.context.createSubcontext(name); } else { return result.context.createSubcontext(reparsedName.getName()); } }
ctx = ctx.createSubcontext( ctxName );
public Context createSubcontext(Name name) throws NamingException { final ParsedName parsedName = parse(name); final Context namespaceContext = findContext(name, parsedName); if (namespaceContext == null) return super.createSubcontext(parsedName.remaining()); else return namespaceContext.createSubcontext(parsedName.remaining()); } }
void handleCreateSubcontext(final MessageInputStream message, final int messageId, final int id) throws IOException { final Object result; try (MessageInputStream mis = message) { if (version == 1) { try (Unmarshaller unmarshaller = createUnmarshaller(mis, configuration)) { final int parameterType = unmarshaller.readUnsignedByte(); if (parameterType != Protocol.P_NAME) { Messages.log.unexpectedParameterType(Protocol.P_NAME, parameterType); } final Name name = unmarshaller.readObject(Name.class); result = localContext.createSubcontext(name); } catch (ClassNotFoundException e) { throw new IOException(e); } } else { mis.readInt(); // consume authId final String name = mis.readUTF(); result = localContext.createSubcontext(name); } } catch (NamingException e) { writeExceptionResponse(e, messageId, id); return; } writeSuccessResponse(messageId, id, result); }
/** * Tests inability to create duplicate subcontexts. */ @Test public void testSubcontextCreationOfDuplicates() throws NamingException { // Try to create duplicate subcontext try { initialContext.createSubcontext("java:gf"); fail(); } catch (NameAlreadyBoundException expected) { } // Try to create duplicate subcontext using multi-component name try { gemfireContext.createSubcontext("env/datasource"); fail(); } catch (NameAlreadyBoundException expected) { } }
/** * Uses the callBindNewContext convenience function to create a new * context. Throws an invalid name exception if the name is empty. * * @param name string * @return the new context object. * @throws NamingException See callBindNewContext */ public javax.naming.Context createSubcontext(Name name) throws NamingException { if (name.size() == 0) throw IIOPLogger.ROOT_LOGGER.invalidEmptyName(); NameComponent[] path = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.nameToCosName(name); try { return callBindNewContext(path); } catch (CannotProceedException e) { javax.naming.Context cctx = getContinuationContext(e); return cctx.createSubcontext(e.getRemainingName()); } }
/** * Tests ability to destroy empty subcontexts. */ @Test public void testSubcontextDestruction() throws Exception { // Create three new subcontexts dataSourceContext.createSubcontext("sub1"); dataSourceContext.createSubcontext("sub2"); envContext.createSubcontext("sub3"); // Destroy initialContext.destroySubcontext("java:gf/env/datasource/sub1"); dataSourceContext.destroySubcontext("sub2"); envContext.destroySubcontext("sub3"); // Perform lookup try { dataSourceContext.lookup("sub1"); fail(); } catch (NameNotFoundException expected) { } try { envContext.lookup("datasource/sub2"); fail(); } catch (NameNotFoundException expected) { } try { initialContext.lookup("java:gf/sub3"); fail(); } catch (NameNotFoundException expected) { } }
return ((Context) boundObject).createSubcontext(parsedName.getSuffix(1)); } else { throw new NotContextException(String.format("Expected Context but found %s",
assertTrue("Correct String registered", String.class.getName().equals(bindingMap.get("mystring").getClassName())); context1.createSubcontext("jdbc").bind("sub/subds", ds);
LOG.tracev( "Creating sub-context: {0}", intermediateContextName ); try { intermediateContext = intermediateContextBase.createSubcontext( intermediateContextName );
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); } }