javax.naming.Context.createSubcontext()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中javax.naming.Context.createSubcontext()方法的一些代码示例,展示了Context.createSubcontext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.createSubcontext()方法的具体详情如下:
包路径:javax.naming.Context
类名称:Context
方法名:createSubcontext

Context.createSubcontext介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
  protected Object doOperation(HttpServerExchange exchange, String name) throws NamingException {
    return localContext.createSubcontext(name);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public Context createSubcontext(Name name) throws NamingException {
  return context.createSubcontext(name);
}

代码示例来源:origin: wildfly/wildfly

@Override
public Context createSubcontext(String name) throws NamingException {
  return context.createSubcontext(name);
}

代码示例来源:origin: internetarchive/heritrix3

/**
 * 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;
}

代码示例来源:origin: wildfly/wildfly

@Override
public Context createSubcontext(final String name) throws NamingException {
  return CNCtxFactory.INSTANCE.getInitialContext(environment).createSubcontext(name);
}

代码示例来源:origin: wildfly/wildfly

@Override
public Context createSubcontext(final Name name) throws NamingException {
  return CNCtxFactory.INSTANCE.getInitialContext(environment).createSubcontext(name);
}

代码示例来源:origin: wildfly/wildfly

/**
* 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;
}

代码示例来源:origin: wildfly/wildfly

@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());
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * 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;
}

代码示例来源:origin: wildfly/wildfly

@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());
  }
}

代码示例来源:origin: hibernate/hibernate-orm

ctx = ctx.createSubcontext( ctxName );

代码示例来源:origin: wildfly/wildfly

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());
  }
}

代码示例来源:origin: wildfly/wildfly

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);
}

代码示例来源:origin: apache/geode

/**
 * 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) {
 }
}

代码示例来源:origin: wildfly/wildfly

/**
 * 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());
  }
}

代码示例来源:origin: apache/geode

/**
 * 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) {
 }
}

代码示例来源:origin: apache/geode

return ((Context) boundObject).createSubcontext(parsedName.getSuffix(1));
} else {
 throw new NotContextException(String.format("Expected Context but found %s",

代码示例来源:origin: spring-projects/spring-framework

assertTrue("Correct String registered", String.class.getName().equals(bindingMap.get("mystring").getClassName()));
context1.createSubcontext("jdbc").bind("sub/subds", ds);

代码示例来源:origin: hibernate/hibernate-orm

LOG.tracev( "Creating sub-context: {0}", intermediateContextName );
try {
  intermediateContext = intermediateContextBase.createSubcontext( intermediateContextName );

代码示例来源:origin: wildfly/wildfly

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);
  }
}

相关文章