gpt4 book ai didi

org.apache.catalina.WebResource.exists()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 12:57:05 28 4
gpt4 key购买 nike

本文整理了Java中org.apache.catalina.WebResource.exists()方法的一些代码示例,展示了WebResource.exists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebResource.exists()方法的具体详情如下:
包路径:org.apache.catalina.WebResource
类名称:WebResource
方法名:exists

WebResource.exists介绍

[英]See java.io.File#exists().
[中]参见java。伊奥。文件#exists()。

代码示例

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
public boolean exists() {
  Boolean cachedExists = this.cachedExists;
  if (cachedExists == null) {
    cachedExists = Boolean.valueOf(webResource.exists());
    this.cachedExists = cachedExists;
  }
  return cachedExists.booleanValue();
}

代码示例来源:origin: codefollower/Tomcat-Research

@Override
public boolean exists() {
  Boolean cachedExists = this.cachedExists;
  if (cachedExists == null) {
    cachedExists = Boolean.valueOf(webResource.exists());
    this.cachedExists = cachedExists;
  }
  return cachedExists.booleanValue();
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
public boolean exists() {
  Boolean cachedExists = this.cachedExists;
  if (cachedExists == null) {
    cachedExists = Boolean.valueOf(webResource.exists());
    this.cachedExists = cachedExists;
  }
  return cachedExists.booleanValue();
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

private boolean preResourceExists(String path) {
  for (WebResourceSet webResourceSet : preResources) {
    WebResource webResource = webResourceSet.getResource(path);
    if (webResource.exists()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

private boolean preResourceExists(String path) {
  for (WebResourceSet webResourceSet : preResources) {
    WebResource webResource = webResourceSet.getResource(path);
    if (webResource.exists()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: codefollower/Tomcat-Research

private boolean preResourceExists(String path) {
  for (WebResourceSet webResourceSet : preResources) {
    WebResource webResource = webResourceSet.getResource(path);
    if (webResource.exists()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

protected WebResource[] getResourcesInternal(String path,
    boolean useClassLoaderResources) {
  List<WebResource> result = new ArrayList<>();
  for (List<WebResourceSet> list : allResources) {
    for (WebResourceSet webResourceSet : list) {
      if (useClassLoaderResources || !webResourceSet.getClassLoaderOnly()) {
        WebResource webResource = webResourceSet.getResource(path);
        if (webResource.exists()) {
          result.add(webResource);
        }
      }
    }
  }
  if (result.size() == 0) {
    result.add(main.getResource(path));
  }
  return result.toArray(new WebResource[result.size()]);
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

private List<PrecompressedResource> getAvailablePrecompressedResources(String path) {
  List<PrecompressedResource> ret = new ArrayList<>(compressionFormats.length);
  for (CompressionFormat format : compressionFormats) {
    WebResource precompressedResource = resources.getResource(path + format.extension);
    if (precompressedResource.exists() && precompressedResource.isFile()) {
      ret.add(new PrecompressedResource(precompressedResource, format));
    }
  }
  return ret;
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

private List<PrecompressedResource> getAvailablePrecompressedResources(String path) {
  List<PrecompressedResource> ret = new ArrayList<>(compressionFormats.length);
  for (CompressionFormat format : compressionFormats) {
    WebResource precompressedResource = resources.getResource(path + format.extension);
    if (precompressedResource.exists() && precompressedResource.isFile()) {
      ret.add(new PrecompressedResource(precompressedResource, format));
    }
  }
  return ret;
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

protected WebResource[] getResourcesInternal(String path,
    boolean useClassLoaderResources) {
  List<WebResource> result = new ArrayList<>();
  for (List<WebResourceSet> list : allResources) {
    for (WebResourceSet webResourceSet : list) {
      if (useClassLoaderResources || !webResourceSet.getClassLoaderOnly()) {
        WebResource webResource = webResourceSet.getResource(path);
        if (webResource.exists()) {
          result.add(webResource);
        }
      }
    }
  }
  if (result.size() == 0) {
    result.add(main.getResource(path));
  }
  return result.toArray(new WebResource[result.size()]);
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Determines the methods normally allowed for the resource.
 *
 */
private StringBuilder determineMethodsAllowed(HttpServletRequest req) {
  StringBuilder methodsAllowed = new StringBuilder();
  WebResource resource = resources.getResource(getRelativePath(req));
  if (!resource.exists()) {
    methodsAllowed.append("OPTIONS, MKCOL, PUT, LOCK");
    return methodsAllowed;
  }
  methodsAllowed.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE");
  methodsAllowed.append(", PROPPATCH, COPY, MOVE, LOCK, UNLOCK");
  if (listings) {
    methodsAllowed.append(", PROPFIND");
  }
  if (resource.isFile()) {
    methodsAllowed.append(", PUT");
  }
  return methodsAllowed;
}

代码示例来源:origin: codefollower/Tomcat-Research

private WebResource[] getResources(String path,
    boolean useClassLoaderResources) {
  path = validate(path);
  ArrayList<WebResource> result = new ArrayList<>();
  for (ArrayList<WebResourceSet> list : allResources) {
    for (WebResourceSet webResourceSet : list) {
      if (useClassLoaderResources || !webResourceSet.getClassLoaderOnly()) {
        WebResource webResource = webResourceSet.getResource(path);
        if (webResource.exists()) {
          result.add(webResource);
        }
      }
    }
  }
  if (result.size() == 0) {
    result.add(main.getResource(path));
  }
  return result.toArray(new WebResource[result.size()]);
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Process a DELETE request for the specified resource.
 *
 * @param req The servlet request we are processing
 * @param resp The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
  throws ServletException, IOException {
  if (readOnly) {
    resp.sendError(HttpServletResponse.SC_FORBIDDEN);
    return;
  }
  String path = getRelativePath(req);
  WebResource resource = resources.getResource(path);
  if (resource.exists()) {
    if (resource.delete()) {
      resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {
      resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    }
  } else {
    resp.sendError(HttpServletResponse.SC_NOT_FOUND);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

return null;
} else if ((resource.isDirectory() && !canonicalPath.endsWith(File.separator) ||
    !resource.exists()) && path.endsWith("/")) {
  return canonicalPath + File.separatorChar;
} else {

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Process a DELETE request for the specified resource.
 *
 * @param req The servlet request we are processing
 * @param resp The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
  throws ServletException, IOException {
  if (readOnly) {
    sendNotAllowed(req, resp);
    return;
  }
  String path = getRelativePath(req);
  WebResource resource = resources.getResource(path);
  if (resource.exists()) {
    if (resource.delete()) {
      resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {
      resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    }
  } else {
    resp.sendError(HttpServletResponse.SC_NOT_FOUND);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Return an enumeration of <code>URLs</code> representing all of the
 * resources with the given name.  If no resources with this name are
 * found, return an empty enumeration.
 *
 * @param name Name of the resources to be found
 *
 * @exception IOException if an input/output error occurs
 */
@Override
public Enumeration<URL> findResources(String name) throws IOException {
  if (log.isDebugEnabled())
    log.debug("    findResources(" + name + ")");
  LinkedHashSet<URL> result = new LinkedHashSet<>();
  String path = nameToPath(name);
  WebResource[] webResources = resources.getClassLoaderResources(path);
  for (WebResource webResource : webResources) {
    if (webResource.exists()) {
      result.add(webResource.getURL());
    }
  }
  return Collections.enumeration(result);
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

protected final WebResource getResourceInternal(String path,
    boolean useClassLoaderResources) {
  WebResource result = null;
  WebResource virtual = null;
  WebResource mainEmpty = null;
  for (List<WebResourceSet> list : allResources) {
    for (WebResourceSet webResourceSet : list) {
      if (!useClassLoaderResources &&  !webResourceSet.getClassLoaderOnly() ||
          useClassLoaderResources && !webResourceSet.getStaticOnly()) {
        result = webResourceSet.getResource(path);
        if (result.exists()) {
          return result;
        }
        if (virtual == null) {
          if (result.isVirtual()) {
            virtual = result;
          } else if (main.equals(webResourceSet)) {
            mainEmpty = result;
          }
        }
      }
    }
  }
  // Use the first virtual result if no real result was found
  if (virtual != null) {
    return virtual;
  }
  // Default is empty resource in main resources
  return mainEmpty;
}

代码示例来源:origin: codefollower/Tomcat-Research

@Override
public boolean resolveResource(int type, String name) {
  WebResourceRoot resources = request.getContext().getResources();
  WebResource resource = resources.getResource(name);
  if (!resource.exists()) {
    return false;
  } else {
    switch (type) {
    case 0:
      return (resource.isDirectory());
    case 1:
      return (resource.isFile());
    case 2:
      return (resource.isFile() && resource.getContentLength() > 0);
    default:
      return false;
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
public boolean resolveResource(int type, String name) {
  WebResourceRoot resources = request.getContext().getResources();
  WebResource resource = resources.getResource(name);
  if (!resource.exists()) {
    return false;
  } else {
    switch (type) {
    case 0:
      return resource.isDirectory();
    case 1:
      return resource.isFile();
    case 2:
      return resource.isFile() && resource.getContentLength() > 0;
    default:
      return false;
    }
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
public boolean resolveResource(int type, String name) {
  WebResourceRoot resources = request.getContext().getResources();
  WebResource resource = resources.getResource(name);
  if (!resource.exists()) {
    return false;
  } else {
    switch (type) {
    case 0:
      return resource.isDirectory();
    case 1:
      return resource.isFile();
    case 2:
      return resource.isFile() && resource.getContentLength() > 0;
    default:
      return false;
    }
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com