gpt4 book ai didi

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

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

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

WebResource.isFile介绍

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

代码示例

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

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

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

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

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

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

代码示例来源: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: codefollower/Tomcat-Research

/**
 * Check if sendfile can be used.
 */
protected boolean checkSendfile(HttpServletRequest request,
               HttpServletResponse response,
               WebResource resource,
               long length, Range range) {
  if (sendfileSize > 0
    && resource.isFile()
    && length > sendfileSize
    && (resource.getCanonicalPath() != null)
    && (Boolean.TRUE == request.getAttribute(Globals.SENDFILE_SUPPORTED_ATTR))
    && (request.getClass().getName().equals("org.apache.catalina.connector.RequestFacade"))
    && (response.getClass().getName().equals("org.apache.catalina.connector.ResponseFacade"))) {
    request.setAttribute(Globals.SENDFILE_FILENAME_ATTR, resource.getCanonicalPath());
    if (range == null) {
      request.setAttribute(Globals.SENDFILE_FILE_START_ATTR, Long.valueOf(0L));
      request.setAttribute(Globals.SENDFILE_FILE_END_ATTR, Long.valueOf(length));
    } else {
      request.setAttribute(Globals.SENDFILE_FILE_START_ATTR, Long.valueOf(range.start));
      request.setAttribute(Globals.SENDFILE_FILE_END_ATTR, Long.valueOf(range.end + 1));
    }
    return true;
  }
  return false;
}

代码示例来源: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: 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 void processWebInfLib() {
  WebResource[] possibleJars = listResources("/WEB-INF/lib", false);
  for (WebResource possibleJar : possibleJars) {
    if (possibleJar.isFile() && possibleJar.getName().endsWith(".jar")) {
      createWebResourceSet(ResourceSetType.CLASSES_JAR,
          "/WEB-INF/classes", possibleJar.getURL(), "/");
    }
  }
}

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

/**
 * Get the readme file as a string.
 */
protected String getReadme(WebResource directory) {
  if (readmeFile != null) {
    WebResource resource = resources.getResource(
        directory.getWebappPath() + readmeFile);
    if (resource.isFile()) {
      StringWriter buffer = new StringWriter();
      InputStream is = resource.getInputStream();
      copyRange(new InputStreamReader(is),
          new PrintWriter(buffer));
      return buffer.toString();
    } else {
      if (debug > 10)
        log("readme '" + readmeFile + "' not found");
      return null;
    }
  }
  return null;
}

代码示例来源: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: 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.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;
    }
  }
}

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

/**
 * Class loader resources are handled by treating JARs in WEB-INF/lib as
 * resource JARs (without the internal META-INF/resources/ prefix) mounted
 * at WEB-INF/classes (rather than the web app root). This enables reuse
 * of the resource handling plumbing.
 *
 * These resources are marked as class loader only so they are only used in
 * the methods that are explicitly defined to return class loader resources.
 * This prevents calls to getResource("/WEB-INF/classes") returning from one
 * or more of the JAR files.
 *
 * @throws LifecycleException If an error occurs that should stop the web
 *                            application from starting
 */
protected void processWebInfLib() throws LifecycleException {
  WebResource[] possibleJars = listResources("/WEB-INF/lib", false);
  for (WebResource possibleJar : possibleJars) {
    if (possibleJar.isFile() && possibleJar.getName().endsWith(".jar")) {
      createWebResourceSet(ResourceSetType.CLASSES_JAR,
          "/WEB-INF/classes", possibleJar.getURL(), "/");
    }
  }
}

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

/**
 * Class loader resources are handled by treating JARs in WEB-INF/lib as
 * resource JARs (without the internal META-INF/resources/ prefix) mounted
 * at WEB-INF/classes (rather than the web app root). This enables reuse
 * of the resource handling plumbing.
 *
 * These resources are marked as class loader only so they are only used in
 * the methods that are explicitly defined to return class loader resources.
 * This prevents calls to getResource("/WEB-INF/classes") returning from one
 * or more of the JAR files.
 *
 * @throws LifecycleException If an error occurs that should stop the web
 *                            application from starting
 */
protected void processWebInfLib() throws LifecycleException {
  WebResource[] possibleJars = listResources("/WEB-INF/lib", false);
  for (WebResource possibleJar : possibleJars) {
    if (possibleJar.isFile() && possibleJar.getName().endsWith(".jar")) {
      createWebResourceSet(ResourceSetType.CLASSES_JAR,
          "/WEB-INF/classes", possibleJar.getURL(), "/");
    }
  }
}

代码示例来源:origin: stackoverflow.com

for (WebResource jar : jars) {
  if (jar.getName().endsWith(".jar") && jar.isFile() && jar.canRead()) {

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

/**
 * Start the class loader.
 *
 * @exception LifecycleException if a lifecycle error occurs
 */
@Override
public void start() throws LifecycleException {
  state = LifecycleState.STARTING_PREP;
  WebResource classes = resources.getResource("/WEB-INF/classes");
  if (classes.isDirectory() && classes.canRead()) {
    localRepositories.add(classes.getURL());
  }
  WebResource[] jars = resources.listResources("/WEB-INF/lib");
  for (WebResource jar : jars) {
    if (jar.getName().endsWith(".jar") && jar.isFile() && jar.canRead()) {
      localRepositories.add(jar.getURL());
      jarModificationTimes.put(
          jar.getName(), Long.valueOf(jar.getLastModified()));
    }
  }
  state = LifecycleState.STARTED;
}

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

/**
 * Start the class loader.
 *
 * @exception LifecycleException if a lifecycle error occurs
 */
@Override
public void start() throws LifecycleException {
  state = LifecycleState.STARTING_PREP;
  WebResource classes = resources.getResource("/WEB-INF/classes");
  if (classes.isDirectory() && classes.canRead()) {
    localRepositories.add(classes.getURL());
  }
  WebResource[] jars = resources.listResources("/WEB-INF/lib");
  for (WebResource jar : jars) {
    if (jar.getName().endsWith(".jar") && jar.isFile() && jar.canRead()) {
      localRepositories.add(jar.getURL());
      jarModificationTimes.put(
          jar.getName(), Long.valueOf(jar.getLastModified()));
    }
  }
  state = LifecycleState.STARTED;
}

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

private WebXml getTomcatWebXmlFragment(WebXmlParser webXmlParser) {
  WebXml webXmlTomcatFragment = createWebXml();
  webXmlTomcatFragment.setOverridable(true);
  // Set to distributable else every app will be prevented from being
  // distributable when the Tomcat fragment is merged with the main
  // web.xml
  webXmlTomcatFragment.setDistributable(true);
  // When merging, the default welcome files are only used if the app has
  // not defined any welcomes files.
  webXmlTomcatFragment.setAlwaysAddWelcomeFiles(false);
  WebResource resource = context.getResources().getResource(Constants.TomcatWebXml);
  if (resource.isFile()) {
    try {
      InputSource source = new InputSource(resource.getURL().toURI().toString());
      source.setByteStream(resource.getInputStream());
      if (!webXmlParser.parseWebXml(source, webXmlTomcatFragment, false)) {
        ok = false;
      }
    } catch (URISyntaxException e) {
      log.error(sm.getString("contextConfig.tomcatWebXmlError"), e);
    }
  }
  return webXmlTomcatFragment;
}

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

private WebXml getTomcatWebXmlFragment(WebXmlParser webXmlParser) {
  WebXml webXmlTomcatFragment = createWebXml();
  webXmlTomcatFragment.setOverridable(true);
  // Set to distributable else every app will be prevented from being
  // distributable when the Tomcat fragment is merged with the main
  // web.xml
  webXmlTomcatFragment.setDistributable(true);
  // When merging, the default welcome files are only used if the app has
  // not defined any welcomes files.
  webXmlTomcatFragment.setAlwaysAddWelcomeFiles(false);
  WebResource resource = context.getResources().getResource(Constants.TomcatWebXml);
  if (resource.isFile()) {
    try {
      InputSource source = new InputSource(resource.getURL().toURI().toString());
      source.setByteStream(resource.getInputStream());
      if (!webXmlParser.parseWebXml(source, webXmlTomcatFragment, false)) {
        ok = false;
      }
    } catch (URISyntaxException e) {
      log.error(sm.getString("contextConfig.tomcatWebXmlError"), e);
    }
  }
  return webXmlTomcatFragment;
}

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

protected void processAnnotationsWebResource(WebResource webResource,
    WebXml fragment, boolean handlesTypesOnly,
    Map<String,JavaClassCacheEntry> javaClassCache) {
  if (webResource.isDirectory()) {
    WebResource[] webResources =
        webResource.getWebResourceRoot().listResources(
            webResource.getWebappPath());
    if (webResources.length > 0) {
      if (log.isDebugEnabled()) {
        log.debug(sm.getString(
            "contextConfig.processAnnotationsWebDir.debug",
            webResource.getURL()));
      }
      for (WebResource r : webResources) {
        processAnnotationsWebResource(r, fragment, handlesTypesOnly, javaClassCache);
      }
    }
  } else if (webResource.isFile() &&
      webResource.getName().endsWith(".class")) {
    try (InputStream is = webResource.getInputStream()) {
      processAnnotationsStream(is, fragment, handlesTypesOnly, javaClassCache);
    } catch (IOException e) {
      log.error(sm.getString("contextConfig.inputStreamWebResource",
          webResource.getWebappPath()),e);
    } catch (ClassFormatException e) {
      log.error(sm.getString("contextConfig.inputStreamWebResource",
          webResource.getWebappPath()),e);
    }
  }
}

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