本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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));
}
}
示例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));
}
}
示例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;
}
示例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;
}
示例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));
}
}
示例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));
}
}
}
示例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;
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}