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


Java NotContextException类代码示例

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


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

示例1: getNameParser

import javax.naming.NotContextException; //导入依赖的package包/类
/**
 * Retrieves the parser associated with the named context. In a 
 * federation of namespaces, different naming systems will parse names 
 * differently. This method allows an application to get a parser for 
 * parsing names into their atomic components using the naming convention 
 * of a particular naming system. Within any single naming system, 
 * NameParser objects returned by this method must be equal (using the 
 * equals() test).
 * 
 * @param name the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic 
 * components
 * @exception NamingException if a naming exception is encountered
 */
@Override
public NameParser getNameParser(Name name)
    throws NamingException {

    while ((!name.isEmpty()) && (name.get(0).length() == 0))
        name = name.getSuffix(1);
    if (name.isEmpty())
        return nameParser;

    if (name.size() > 1) {
        Object obj = bindings.get(name.get(0));
        if (obj instanceof Context) {
            return ((Context) obj).getNameParser(name.getSuffix(1));
        } else {
            throw new NotContextException
                (sm.getString("namingContext.contextExpected"));
        }
    }

    return nameParser;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:37,代码来源:NamingContext.java

示例2: getNameParser

import javax.naming.NotContextException; //导入依赖的package包/类
/**
 * Retrieves the parser associated with the named context. In a 
 * federation of namespaces, different naming systems will parse names 
 * differently. This method allows an application to get a parser for 
 * parsing names into their atomic components using the naming convention 
 * of a particular naming system. Within any single naming system, 
 * NameParser objects returned by this method must be equal (using the 
 * equals() test).
 * 
 * @param name the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic 
 * components
 * @exception NamingException if a naming exception is encountered
 */
public NameParser getNameParser(Name name)
    throws NamingException {

    while ((!name.isEmpty()) && (name.get(0).length() == 0))
        name = name.getSuffix(1);
    if (name.isEmpty())
        return nameParser;

    if (name.size() > 1) {
        Object obj = bindings.get(name.get(0));
        if (obj instanceof Context) {
            return ((Context) obj).getNameParser(name.getSuffix(1));
        } else {
            throw new NotContextException
                (sm.getString("namingContext.contextExpected"));
        }
    }

    return nameParser;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:NamingContext.java

示例3: bind

import javax.naming.NotContextException; //导入依赖的package包/类
@Override
public void bind(Name name, Object obj) throws NamingException {
	if (name.isEmpty()) {
		throw new InvalidNameException("Cannot bind empty name");
	}

	Name nm = getMyComponents(name);
	String atom = nm.get(0);
	Object inter = iBindings.get(atom);

	if (nm.size() == 1) {
		if (inter != null)
			throw new NameAlreadyBoundException("Use rebind to override");

		obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv);

		iBindings.put(atom, obj);
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		((Context) inter).bind(nm.getSuffix(1), obj);
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:25,代码来源:LocalContext.java

示例4: rebind

import javax.naming.NotContextException; //导入依赖的package包/类
@Override
public void rebind(Name name, Object obj) throws NamingException {
	if (name.isEmpty())
		throw new InvalidNameException("Cannot bind empty name");

	Name nm = getMyComponents(name);
	String atom = nm.get(0);

	if (nm.size() == 1) {
		obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv);

		iBindings.put(atom, obj);
	} else {
		Object inter = iBindings.get(atom);
		
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		((Context) inter).rebind(nm.getSuffix(1), obj);
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:22,代码来源:LocalContext.java

示例5: unbind

import javax.naming.NotContextException; //导入依赖的package包/类
@Override
public void unbind(Name name) throws NamingException {
	if (name.isEmpty())
		throw new InvalidNameException("Cannot unbind empty name");

	Name nm = getMyComponents(name);
	String atom = nm.get(0);

	if (nm.size() == 1) {
		iBindings.remove(atom);
	} else {
		Object inter = iBindings.get(atom);
		
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		((Context) inter).unbind(nm.getSuffix(1));
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:20,代码来源:LocalContext.java

示例6: createSubcontext

import javax.naming.NotContextException; //导入依赖的package包/类
@Override
public Context createSubcontext(Name name) throws NamingException {
	if (name.isEmpty())
		throw new InvalidNameException("Cannot bind empty name");

	Name nm = getMyComponents(name);
	String atom = nm.get(0);
	Object inter = iBindings.get(atom);

	if (nm.size() == 1) {
		if (inter != null)
			throw new NameAlreadyBoundException("Use rebind to override");

		Context child = createCtx(this, atom, iEnv);

		iBindings.put(atom, child);

		return child;
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		return ((Context) inter).createSubcontext(nm.getSuffix(1));
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:26,代码来源:LocalContext.java

示例7: getNameParser

import javax.naming.NotContextException; //导入依赖的package包/类
/**
    * Retrieves the parser associated with the named context. In a 
    * federation of namespaces, different naming systems will parse names 
    * differently. This method allows an application to get a parser for 
    * parsing names into their atomic components using the naming convention 
    * of a particular naming system. Within any single naming system, 
    * NameParser objects returned by this method must be equal (using the 
    * equals() test).
    * 
    * @param name the name of the context from which to get the parser
    * @return a name parser that can parse compound names into their atomic 
    * components
    * @exception NamingException if a naming exception is encountered
    */
   public NameParser getNameParser(Name name)
       throws NamingException {

while ((!name.isEmpty()) && (name.get(0).length() == 0))
    name = name.getSuffix(1);
       if (name.isEmpty())
           return nameParser;

       if (name.size() > 1) {
           Object obj = bindings.get(name.get(0));
           if (obj instanceof Context) {
               return ((Context) obj).getNameParser(name.getSuffix(1));
           } else {
               throw new NotContextException
                   (sm.getString("namingContext.contextExpected"));
           }
       }

       return nameParser;

   }
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:36,代码来源:NamingContext.java

示例8: getNameParser

import javax.naming.NotContextException; //导入依赖的package包/类
/**
 * Retrieves the parser associated with the named context. In a federation
 * of namespaces, different naming systems will parse names differently.
 * This method allows an application to get a parser for parsing names into
 * their atomic components using the naming convention of a particular
 * naming system. Within any single naming system, NameParser objects
 * returned by this method must be equal (using the equals() test).
 * 
 * @param name
 *            the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic
 *         components
 * @exception NamingException
 *                if a naming exception is encountered
 */
@Override
public NameParser getNameParser(Name name) throws NamingException {

	while ((!name.isEmpty()) && (name.get(0).length() == 0))
		name = name.getSuffix(1);
	if (name.isEmpty())
		return nameParser;

	if (name.size() > 1) {
		Object obj = bindings.get(name.get(0));
		if (obj instanceof Context) {
			return ((Context) obj).getNameParser(name.getSuffix(1));
		} else {
			throw new NotContextException(sm.getString("namingContext.contextExpected"));
		}
	}

	return nameParser;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:36,代码来源:NamingContext.java

示例9: destroySubcontext

import javax.naming.NotContextException; //导入依赖的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

示例10: unbind

import javax.naming.NotContextException; //导入依赖的package包/类
/**
 * Removes name and its associated object from the context.
 * 
 * @param name name to remove
 * @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 NameNotFoundException if intermediate context can not be found
 * @throws NotContextException if name has more than one atomic name and
 *           intermediate context is not found.
 * @throws NamingException if any other naming exception occurs
 *  
 */
public void unbind(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 nameToRemove = parsedName.get(0);
  // scenerio unbind a
  // remove a and its associated object
  if (parsedName.size() == 1) {
    ctxMaps.remove(nameToRemove);
  }
  else {
    //        	 scenerio unbind a/b or a/b/c
    //        	 remove b and its associated object
    Object boundObject = ctxMaps.get(nameToRemove);
    if (boundObject instanceof Context) {
      //                remove b and its associated object
      ((Context) boundObject).unbind(parsedName.getSuffix(1));
    }
    else {
      // 			if the name is not found then throw exception
      if (!ctxMaps.containsKey(nameToRemove)) { throw new NameNotFoundException(LocalizedStrings.ContextImpl_CAN_NOT_FIND_0.toLocalizedString(name)); }
      throw new NotContextException(LocalizedStrings.ContextImpl_EXPECTED_CONTEXT_BUT_FOUND_0.toLocalizedString(boundObject));
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:39,代码来源:ContextImpl.java

示例11: getNameParser

import javax.naming.NotContextException; //导入依赖的package包/类
/**
 * Retrieves the parser associated with the named context. In a
 * federation of namespaces, different jndi systems will parse names
 * differently. This method allows an application to get a parser for
 * parsing names into their atomic components using the jndi convention
 * of a particular jndi system. Within any single jndi system,
 * NameParser objects returned by this method must be equal (using the
 * equals() test).
 *
 * @param name the name of the context from which to get the parser
 * @return a name parser that can parse compound names into their atomic
 * components
 * @throws NamingException if a jndi exception is encountered
 */
@Override
public NameParser getNameParser(Name name) throws NamingException {

    while ((!name.isEmpty()) && (name.get(0).length() == 0)) {
        name = name.getSuffix(1);
    }

    if (name.isEmpty()) {
        return NAME_PARSER;
    }

    if (name.size() > 1) {
        Object obj = bindings.get(name.get(0));
        if (obj instanceof Context) {
            return ((Context) obj).getNameParser(name.getSuffix(1));
        } else {
            throw new NotContextException(SM.getString("namingContext.contextExpected"));
        }
    }

    return NAME_PARSER;

}
 
开发者ID:wso2,项目名称:carbon-jndi,代码行数:38,代码来源:NamingContext.java

示例12: list

import javax.naming.NotContextException; //导入依赖的package包/类
@Override
public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException {
	final Name searchName = validateName(name);
	// If null, it means we don't know how to handle this -> throw to the
	// parent
	if (searchName == null) {
		return parent.list(name);
	} else if (searchName.isEmpty()) {
		// listing this context
		return new Names(bindings);
	}

	// Perhaps 'name' names a context
	final Object target = lookup(name);
	if (target instanceof Context) {
		return ((Context) target).list("");
	}
	throw new NotContextException(name + " cannot be listed");
}
 
开发者ID:geronimo-iia,项目名称:winstone,代码行数:20,代码来源:NamingContext.java

示例13: listBindings

import javax.naming.NotContextException; //导入依赖的package包/类
@Override
public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException {
	final Name searchName = validateName(name);
	// If null, it means we don't know how to handle this -> throw to the
	// parent
	if (searchName == null) {
		return parent.listBindings(name);
	}
	if (searchName.isEmpty()) {
		// listing this context
		return new Bindings(this, environnement, bindings);
	}

	// Perhaps 'name' names a context
	final Object target = lookup(name);
	if (target instanceof Context) {
		return ((Context) target).listBindings("");
	}
	throw new NotContextException(name + " cannot be listed");
}
 
开发者ID:geronimo-iia,项目名称:winstone,代码行数:21,代码来源:NamingContext.java

示例14: list

import javax.naming.NotContextException; //导入依赖的package包/类
/**
 * Enumerates the names bound in the named context, along with the class names of objects bound to them. The
 * contents of any subcontexts are not included. If a binding is added to or removed from this context, its effect
 * on an enumeration previously returned is undefined.
 *
 * @param  name The name of the context to list.
 *
 * @return An enumeration of the names and class names of the bindings in this context. Each element of the
 *         enumeration is of type NameClassPair.
 *
 * @throws NamingException If the context is not known.
 */
public NamingEnumeration list(String name) throws NamingException
{
    if ("".equals(name))
    {
        // listing this context
        return new FlatNames(bindings.keys());
    }

    // Perhaps `name' names a context
    Object target = lookup(name);

    if (target instanceof Context)
    {
        return ((Context) target).list("");
    }

    throw new NotContextException(name + " cannot be listed");
}
 
开发者ID:rupertlssmith,项目名称:lojix,代码行数:31,代码来源:SimpleContext.java

示例15: listBindings

import javax.naming.NotContextException; //导入依赖的package包/类
/**
 * Enumerates the names bound in the named context, along with the objects bound to them. The contents of any
 * subcontexts are not included.
 *
 * <p/>If a binding is added to or removed from this context, its effect on an enumeration previously returned is
 * undefined.
 *
 * @param  name The name of the context to list.
 *
 * @return An enumeration of the bindings in this context. Each element of the enumeration is of type Binding.
 *
 * @throws NamingException If the context is not known.
 */
public NamingEnumeration listBindings(String name) throws NamingException
{
    if ("".equals(name))
    {
        // listing this context
        return new FlatBindings(bindings.keys());
    }

    // Perhaps `name' names a context
    Object target = lookup(name);

    if (target instanceof Context)
    {
        return ((Context) target).listBindings("");
    }

    throw new NotContextException(name + " cannot be listed");
}
 
开发者ID:rupertlssmith,项目名称:lojix,代码行数:32,代码来源:SimpleContext.java


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