当前位置: 首页>>代码示例>>Java>>正文


Java ContextNotEmptyException类代码示例

本文整理汇总了Java中javax.naming.ContextNotEmptyException的典型用法代码示例。如果您正苦于以下问题:Java ContextNotEmptyException类的具体用法?Java ContextNotEmptyException怎么用?Java ContextNotEmptyException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContextNotEmptyException类属于javax.naming包,在下文中一共展示了ContextNotEmptyException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: destroySubcontext

import javax.naming.ContextNotEmptyException; //导入依赖的package包/类
/**
 * Destroys subcontext with name name. The subcontext must be empty otherwise
 * ContextNotEmptyException is thrown. Once a context is destroyed, the
 * instance should not be used.
 * 
 * @param name subcontext to destroy
 * @throws NoPermissionException if this context has been destroyed.
 * @throws InvalidNameException if name is empty or is CompositeName that
 *           spans more than one naming system.
 * @throws ContextNotEmptyException if Context name is not empty.
 * @throws NameNotFoundException if subcontext with name name can not be
 *           found.
 * @throws NotContextException if name is not bound to instance of
 *           ContextImpl.
 *  
 */
public void destroySubcontext(Name name) throws NamingException {
  checkIsDestroyed();
  Name parsedName = getParsedName(name);
  if (parsedName.size() == 0 || parsedName.get(0).length() == 0) { throw new InvalidNameException(LocalizedStrings.ContextImpl_NAME_CAN_NOT_BE_EMPTY.toLocalizedString()); }
  String subContextName = parsedName.get(0);
  Object boundObject = ctxMaps.get(subContextName);
  if (boundObject == null) { throw new NameNotFoundException(LocalizedStrings.ContextImpl_NAME_0_NOT_FOUND_IN_THE_CONTEXT.toLocalizedString(subContextName)); }
  if (!(boundObject instanceof ContextImpl)) { throw new NotContextException(); }
  ContextImpl contextToDestroy = (ContextImpl) boundObject;
  if (parsedName.size() == 1) {
    // Check if the Context to be destroyed is empty. Can not destroy
    // non-empty Context.
    if (contextToDestroy.ctxMaps.size() == 0) {
      ctxMaps.remove(subContextName);
      contextToDestroy.destroyInternal();
    }
    else {
      throw new ContextNotEmptyException(LocalizedStrings.ContextImpl_CAN_NOT_DESTROY_NONEMPTY_CONTEXT.toLocalizedString());
    }
  }
  else {
    // Let the subcontext destroy the context
    ((ContextImpl) boundObject).destroySubcontext(parsedName.getSuffix(1));
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:42,代码来源:ContextImpl.java

示例2: destroySubcontext

import javax.naming.ContextNotEmptyException; //导入依赖的package包/类
/**
 * Destroys subcontext with name name. The subcontext must be empty otherwise
 * ContextNotEmptyException is thrown. Once a context is destroyed, the instance should not be
 * used.
 * 
 * @param name subcontext to destroy
 * @throws NoPermissionException if this context has been destroyed.
 * @throws InvalidNameException if name is empty or is CompositeName that spans more than one
 *         naming system.
 * @throws ContextNotEmptyException if Context name is not empty.
 * @throws NameNotFoundException if subcontext with name name can not be found.
 * @throws NotContextException if name is not bound to instance of ContextImpl.
 * 
 */
public void destroySubcontext(Name name) throws NamingException {
  checkIsDestroyed();
  Name parsedName = getParsedName(name);
  if (parsedName.size() == 0 || parsedName.get(0).length() == 0) {
    throw new InvalidNameException(
        LocalizedStrings.ContextImpl_NAME_CAN_NOT_BE_EMPTY.toLocalizedString());
  }
  String subContextName = parsedName.get(0);
  Object boundObject = ctxMaps.get(subContextName);
  if (boundObject == null) {
    throw new NameNotFoundException(LocalizedStrings.ContextImpl_NAME_0_NOT_FOUND_IN_THE_CONTEXT
        .toLocalizedString(subContextName));
  }
  if (!(boundObject instanceof ContextImpl)) {
    throw new NotContextException();
  }
  ContextImpl contextToDestroy = (ContextImpl) boundObject;
  if (parsedName.size() == 1) {
    // Check if the Context to be destroyed is empty. Can not destroy
    // non-empty Context.
    if (contextToDestroy.ctxMaps.size() == 0) {
      ctxMaps.remove(subContextName);
      contextToDestroy.destroyInternal();
    } else {
      throw new ContextNotEmptyException(
          LocalizedStrings.ContextImpl_CAN_NOT_DESTROY_NONEMPTY_CONTEXT.toLocalizedString());
    }
  } else {
    // Let the subcontext destroy the context
    ((ContextImpl) boundObject).destroySubcontext(parsedName.getSuffix(1));
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:47,代码来源:ContextImpl.java


注:本文中的javax.naming.ContextNotEmptyException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。