Java 类javax.naming.NotContextException 实例源码

项目:tomcat7    文件:NamingContext.java   
/**
 * 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;

}
项目:lams    文件:NamingContext.java   
/**
 * 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;

}
项目:unitimes    文件:LocalContext.java   
@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);
    }
}
项目:unitimes    文件:LocalContext.java   
@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);
    }
}
项目:unitimes    文件:LocalContext.java   
@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));
    }
}
项目:unitimes    文件:LocalContext.java   
@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));
    }
}
项目:jerrydog    文件:NamingContext.java   
/**
    * 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;

   }
项目:apache-tomcat-7.0.73-with-comment    文件:NamingContext.java   
/**
 * 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;

}
项目:lazycat    文件:NamingContext.java   
/**
 * 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;

}
项目:gemfirexd-oss    文件:ContextImpl.java   
/**
 * 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));
  }
}
项目:gemfirexd-oss    文件:ContextImpl.java   
/**
 * 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));
    }
  }
}
项目:carbon-jndi    文件:NamingContext.java   
/**
 * 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;

}
项目:gemfirexd-oss    文件:ContextImpl.java   
/**
 * 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));
  }
}
项目:gemfirexd-oss    文件:ContextImpl.java   
/**
 * 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));
    }
  }
}
项目:winstone    文件:NamingContext.java   
@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");
}
项目:winstone    文件:NamingContext.java   
@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");
}
项目:unitime    文件:LocalContext.java   
@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);
    }
}
项目:unitime    文件:LocalContext.java   
@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);
    }
}
项目:unitime    文件:LocalContext.java   
@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));
    }
}
项目:unitime    文件:LocalContext.java   
@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));
    }
}
项目:class-guard    文件:NamingContext.java   
/**
 * 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;

}
项目:lojix    文件:SimpleContext.java   
/**
 * 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");
}
项目:lojix    文件:SimpleContext.java   
/**
 * 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");
}
项目:cn1    文件:RegistryContext.java   
/**
 * {@inheritDoc}
 */
public NamingEnumeration<NameClassPair> list(Name name)
        throws NamingException {
    if (name.isEmpty()) {
        try {
            return new NameClassPairEnumeration(registry.list());
        } catch (RemoteException e) {
            throw (NamingException) newNamingException(e)
                    .fillInStackTrace();
        }
    }
    Object obj = lookup(name);

    if (obj instanceof Context) {
        try {
            return ((Context) obj).list(""); //$NON-NLS-1$
        } finally {
            ((Context) obj).close();
        }
    }
    // jndi.80=Name specifies an object that is not a context: {0}
    throw new NotContextException(Messages.getString("jndi.80", name)); //$NON-NLS-1$
}
项目:cn1    文件:RegistryContext.java   
/**
 * {@inheritDoc}
 */
public NamingEnumeration<Binding> listBindings(Name name)
        throws NamingException {
    if (name.isEmpty()) {
        try {
            return new BindingEnumeration(registry.list(), this);
        } catch (RemoteException e) {
            throw (NamingException) newNamingException(e)
                    .fillInStackTrace();
        }
    }
    Object obj = lookup(name);

    if (obj instanceof Context) {
        try {
            return ((Context) obj).listBindings(""); //$NON-NLS-1$
        } finally {
            ((Context) obj).close();
        }
    }
    // jndi.80=Name specifies an object that is not a context: {0}
    throw new NotContextException(Messages.getString("jndi.80", name)); //$NON-NLS-1$
}
项目:cn1    文件:RegistryContextFactory.java   
/**
 * {@inheritDoc}
 */
public Context getInitialContext(Hashtable<?, ?> environment)
        throws NamingException {
    String url = null;

    if (environment != null) {
        url = (String) environment.get(Context.PROVIDER_URL);
    }

    if (url == null) {
        url = RegistryContext.RMI_URL_PREFIX;
    }

    Object obj = new rmiURLContextFactory().getObjectInstance(url, null,
            null, environment);

    if (obj instanceof Context) {
        return (Context) obj;
    }
    // jndi.76=Object instantiated using the URL specified in environment is
    // not a context: {0}
    throw new NotContextException(Messages.getString("jndi.76", url)); //$NON-NLS-1$
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.directory.DirContext#bind(javax.naming.Name,
 *      java.lang.Object, javax.naming.directory.Attributes)
 */
public void bind(Name arg0, Object arg1, Attributes arg2)
        throws NamingException {
    ContextNamePair pair;

    try {
        pair = getTargetNamespaceContextNamePair(arg0);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair.context instanceof DirContext) {
        ((DirContext) pair.context).bind(pair.name, arg1, arg2);
    } else {
        // jndi.4A=found object is not a DirContext
        throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
    }
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.directory.DirContext#rebind(javax.naming.Name,
 *      java.lang.Object, javax.naming.directory.Attributes)
 */
public void rebind(Name arg0, Object arg1, Attributes arg2)
        throws NamingException {
    ContextNamePair pair;

    try {
        pair = getTargetNamespaceContextNamePair(arg0);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair.context instanceof DirContext) {
        ((DirContext) pair.context).rebind(pair.name, arg1, arg2);
    } else {
        // jndi.4A=found object is not a DirContext
        throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
    }
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.directory.DirContext#createSubcontext(javax.naming.Name,
 *      javax.naming.directory.Attributes)
 */
public DirContext createSubcontext(Name arg0, Attributes arg1)
        throws NamingException {
    ContextNamePair pair;

    try {
        pair = getTargetNamespaceContextNamePair(arg0);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair.context instanceof DirContext) {
        return ((DirContext) pair.context)
                .createSubcontext(pair.name, arg1);
    }
    // jndi.4A=found object is not a DirContext
    throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.Context#destroySubcontext(javax.naming.Name)
 */
public void destroySubcontext(Name arg0) throws NamingException {
    ContextNamePair pair;

    try {
        pair = getTargetNamespaceContextNamePair(arg0);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair.context instanceof Context) {
        ((Context) pair.context).destroySubcontext(pair.name);
    } else {
        // jndi.4E=found object is not a Context
        throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
    }
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.Context#unbind(javax.naming.Name)
 */
public void unbind(Name arg0) throws NamingException {
    ContextNamePair pair;

    try {
        pair = getTargetNamespaceContextNamePair(arg0);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair.context instanceof Context) {
        ((Context) pair.context).unbind(pair.name);
    } else {
        // jndi.4E=found object is not a Context
        throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
    }
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.Context#bind(javax.naming.Name, java.lang.Object)
 */
public void bind(Name arg0, Object arg1) throws NamingException {
    ContextNamePair pair;

    try {
        pair = getTargetNamespaceContextNamePair(arg0);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair.context instanceof Context) {
        ((Context) pair.context).bind(pair.name, arg1);
    } else {
        // jndi.4E=found object is not a Context
        throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
    }
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.Context#rebind(javax.naming.Name, java.lang.Object)
 */
public void rebind(Name arg0, Object arg1) throws NamingException {
    ContextNamePair pair;

    try {
        pair = getTargetNamespaceContextNamePair(arg0);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair.context instanceof Context) {
        ((Context) pair.context).rebind(pair.name, arg1);
    } else {
        // jndi.4E=found object is not a Context
        throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
    }
}
项目:cn1    文件:DNSContext.java   
/**
 * This method is not supported.
 * 
 * @see javax.naming.Context#rename(javax.naming.Name, javax.naming.Name)
 */
public void rename(Name arg0, Name arg1) throws NamingException {
    ContextNamePair pair1;
    ContextNamePair pair2;

    try {
        pair1 = getTargetNamespaceContextNamePair(arg0);
        pair2 = getTargetNamespaceContextNamePair(arg1);
    } catch (IllegalArgumentException e) {
        throw new OperationNotSupportedException();
    }
    if (pair1.context instanceof Context
            && pair1.context.getClass().getName().equals(
                    pair2.context.getClass().getName())
            && ((Context) pair1.context).getNameInNamespace().equals(
                    ((Context) pair2.context).getNameInNamespace())) {
        ((Context) pair1.context).rename(pair1.name, pair2.name);
    } else {
        // jndi.4F=found object is not a Context or target contexts are not
        // equal
        throw new NotContextException(Messages.getString("jndi.4F")); //$NON-NLS-1$
    }
}
项目:cn1    文件:DNSContext.java   
/**
 * Returns the name parser for given name.
 * 
 * @param name
 *            a name in the string form to return a name parser for
 * @return the name parser found
 * @throws NotContextException
 *             if found object is not a context
 * @throws NamingException
 *             if such exception was encountered during lookup
 * @see DNSContext#getNameParser(Name) for details
 * @see javax.naming.Context#getNameParser(java.lang.String)
 */
public NameParser getNameParser(String name) throws NamingException {
    Object obj;

    if (name == null) {
        // jndi.2E=The name is null
        throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
    }
    obj = lookup(name);
    if (obj instanceof DNSContext) {
        return nameParser;
    } else if (obj instanceof Context) {
        return ((Context) obj).getNameParser(""); //$NON-NLS-1$
    }
    // jndi.4E=found object is not a Context
    throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
项目:cn1    文件:DNSContext.java   
/**
 * Tries to look for the context associated with the given name and returns
 * the appropriate name parser. For <code>DNSContext</code> this method
 * will return an instance of <code>DNSNameParser</code> class.
 * 
 * @param a
 *            name to return a name parser for
 * @return a name parser for the naming system the found context is
 *         associated with
 * @throws NotContextException
 *             if found object is not a context so we cannot obtain a name
 *             parser from it
 * @throws NamingException
 *             if such exception was encountered during lookup
 * @see javax.naming.Context#getNameParser(javax.naming.Name)
 */
public NameParser getNameParser(Name name) throws NamingException {
    Object obj;

    if (name == null) {
        // jndi.2E=The name is null
        throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
    }
    obj = lookup(name);
    if (obj instanceof DNSContext) {
        return nameParser;
    } else if (obj instanceof Context) {
        return ((Context) obj).getNameParser(""); //$NON-NLS-1$
    }
    // jndi.4E=found object is not a Context
    throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
项目:apache-tomcat-7.0.57    文件:NamingContext.java   
/**
 * 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;

}
项目:apache-tomcat-7.0.57    文件:NamingContext.java   
/**
 * 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;

}
项目:ffmq    文件:FFMQJNDIContext.java   
@Override
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
   {
       if (name.isEmpty())
           return new ListOfNames(bindings.keys());

       Object target = lookup(name);
       if (target instanceof Context)
       {
           try
           {
               return ((Context)target).list("");
           }
           finally
           {
               ((Context)target).close();
           }
       }
       throw new NotContextException(name + " cannot be listed");
   }
项目:ffmq    文件:FFMQJNDIContext.java   
@Override
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
   {
       if (name.isEmpty())
           return new ListOfBindings(bindings.keys());

       Object target = lookup(name);
       if (target instanceof Context)
       {
           try
           {
               return ((Context)target).listBindings("");
           }
           finally
           {
               ((Context)target).close();
           }
       }
       throw new NotContextException(name + " cannot be listed");
   }