gpt4 book ai didi

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

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

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

WebResource.getURL介绍

[英]Obtain a URL to access the resource or null if no such URL is available or if the resource does not exist.
[中]获取一个URL以访问资源,如果没有可用的URL或资源不存在,则获取null

代码示例

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

@Override
public URL getURL() {
  return webResource.getURL();
}

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

@Override
public URL getURL() {
  return webResource.getURL();
}

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

@Override
public URL getURL() {
  return webResource.getURL();
}

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

@Override
public URL getCodeBase() {
  if (getWebappPath().startsWith("/WEB-INF/classes/") && name.endsWith(".class")) {
    return getWebResourceRoot().getResource("/WEB-INF/classes/").getURL();
  } else {
    return getURL();
  }
}

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

@Override
public URL getCodeBase() {
  if (getWebappPath().startsWith("/WEB-INF/classes/") && name.endsWith(".class")) {
    return getWebResourceRoot().getResource("/WEB-INF/classes/").getURL();
  } else {
    return getURL();
  }
}

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

/**
 * Return the URL to the resource that is mapped to a specified path.
 * The path must begin with a "/" and is interpreted as relative to the
 * current context root.
 *
 * @param path The path to the desired resource
 *
 * @exception MalformedURLException if the path is not given
 *  in the correct form
 */
@Override
public URL getResource(String path)
  throws MalformedURLException {
  if (path == null ||
      !path.startsWith("/") && GET_RESOURCE_REQUIRE_SLASH)
    throw new MalformedURLException(sm.getString(
        "applicationContext.requestDispatcher.iae", path));
  WebResourceRoot resources = context.getResources();
  if (resources != null) {
    return resources.getResource(path).getURL();
  }
  return null;
}

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

@Override
public URL getResource(String path) throws MalformedURLException {
  String validatedPath = validateResourcePath(path, false);
  if (validatedPath == null) {
    throw new MalformedURLException(
        sm.getString("applicationContext.requestDispatcher.iae", path));
  }
  WebResourceRoot resources = context.getResources();
  if (resources != null) {
    return resources.getResource(validatedPath).getURL();
  }
  return null;
}

代码示例来源: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: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
public URL getResource(String path) throws MalformedURLException {
  String validatedPath = validateResourcePath(path, false);
  if (validatedPath == null) {
    throw new MalformedURLException(
        sm.getString("applicationContext.requestDispatcher.iae", path));
  }
  WebResourceRoot resources = context.getResources();
  if (resources != null) {
    return resources.getResource(validatedPath).getURL();
  }
  return null;
}

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

/**
 * 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: 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.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: codefollower/Tomcat-Research

/**
 * Start the class loader.
 *
 * @exception LifecycleException if a lifecycle error occurs
 */
@Override
public void start() throws LifecycleException {
  WebResource classes = resources.getResource("/WEB-INF/classes");
  if (classes.isDirectory() && classes.canRead()) {
    addURL(classes.getURL());
  }
  WebResource[] jars = resources.listResources("/WEB-INF/lib");
  for (WebResource jar : jars) {
    if (jar.getName().endsWith(".jar") && jar.isFile() && jar.canRead()) {
      addURL(jar.getURL());
      jarModificationTimes.put(
          jar.getName(), Long.valueOf(jar.getLastModified()));
    }
  }
  started = true;
  String encoding = null;
  try {
    encoding = System.getProperty("file.encoding");
  } catch (SecurityException e) {
    return;
  }
  if (encoding.indexOf("EBCDIC")!=-1) {
    needConvert = true;
  }
}

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

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

/**
 * Allocate resources, including proxy.
 * @throws LifecycleException if a start error occurs
 */
public void resourcesStart() throws LifecycleException {
  // Check current status in case resources were added that had already
  // been started
  if (!resources.getState().isAvailable()) {
    resources.start();
  }
  if (effectiveMajorVersion >=3 && addWebinfClassesResources) {
    WebResource webinfClassesResource = resources.getResource(
        "/WEB-INF/classes/META-INF/resources");
    if (webinfClassesResource.isDirectory()) {
      getResources().createWebResourceSet(
          WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/",
          webinfClassesResource.getURL(), "/");
    }
  }
}

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

/**
 * Allocate resources, including proxy.
 * @throws LifecycleException if a start error occurs
 */
public void resourcesStart() throws LifecycleException {
  // Check current status in case resources were added that had already
  // been started
  if (!resources.getState().isAvailable()) {
    resources.start();
  }
  if (effectiveMajorVersion >=3 && addWebinfClassesResources) {
    WebResource webinfClassesResource = resources.getResource(
        "/WEB-INF/classes/META-INF/resources");
    if (webinfClassesResource.isDirectory()) {
      getResources().createWebResourceSet(
          WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/",
          webinfClassesResource.getURL(), "/");
    }
  }
}

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

/**
 * Allocate resources, including proxy.
 * Return <code>true</code> if initialization was successfull,
 * or <code>false</code> otherwise.
 */
public void resourcesStart() throws LifecycleException {
  // May have been started (but not fully configured) in init() so no need
  // to start the resources if they are already available
  if (!resources.getState().isAvailable()) {
    resources.start();
  }
  if (effectiveMajorVersion >=3 && addWebinfClassesResources) {
    WebResource webinfClassesResource = resources.getResource(
        "/WEB-INF/classes/META-INF/resources");
    if (webinfClassesResource.isDirectory()) {
      getResources().createWebResourceSet(
          WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/",
          webinfClassesResource.getURL(), "/");
    }
  }
}

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