/**
   * List the resources which are members of a collection.
   *
   * @param file Collection
   * @return Vector containing NamingEntry objects
   */
  protected List<NamingEntry> list(File file) {

    List<NamingEntry> entries = new ArrayList<NamingEntry>();
    if (!file.isDirectory()) return entries;
    String[] names = file.list();
    if (names == null) {
      /* Some IO error occurred such as bad file permissions.
      Prevent a NPE with Arrays.sort(names) */
      log.warn(sm.getString("fileResources.listingNull", file.getAbsolutePath()));
      return entries;
    }

    Arrays.sort(names); // Sort alphabetically
    NamingEntry entry = null;

    for (int i = 0; i < names.length; i++) {

      File currentFile = new File(file, names[i]);
      Object object = null;
      if (currentFile.isDirectory()) {
        FileDirContext tempContext = new FileDirContext(env);
        tempContext.setDocBase(file.getPath());
        tempContext.setAllowLinking(getAllowLinking());
        object = tempContext;
      } else {
        object = new FileResource(currentFile);
      }
      entry = new NamingEntry(names[i], object, NamingEntry.ENTRY);
      entries.add(entry);
    }

    return entries;
  }
  /**
   * Retrieves the named object.
   *
   * @param name the name of the object to look up
   * @return the object bound to name
   */
  @Override
  protected Object doLookup(String name) {
    Object result = null;
    File file = file(name);

    if (file == null) return null;

    if (file.isDirectory()) {
      FileDirContext tempContext = new FileDirContext(env);
      tempContext.setDocBase(file.getPath());
      tempContext.setAllowLinking(getAllowLinking());
      result = tempContext;
    } else {
      result = new FileResource(file);
    }

    return result;
  }