AbstractArchiveResource (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.catalina.webresources, class: AbstractArchiveResource

# Class AbstractArchiveResource

java.lang.Object
org.apache.catalina.webresources.AbstractResource
org.apache.catalina.webresources.AbstractArchiveResource

All Implemented Interfaces:
  `WebResource`

Direct Known Subclasses:
  `AbstractSingleArchiveResource, JarWarResource`

public abstract class AbstractArchiveResource extends AbstractResource
Abstract resource implementation for archive-based resources.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected class`
  `AbstractArchiveResource.JarInputStreamWrapper`
  This wrapper assumes that the InputStream was created from a JarFile obtained from a call to getArchiveResourceSet().openJarFile().

- ## Field Summary

  ### Fields inherited from class AbstractResource

  `sm`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractArchiveResource(AbstractArchiveResourceSet archiveResourceSet, String webAppPath, String baseUrl, JarEntry jarEntry)`
  Deprecated.
  `protected`
  `AbstractArchiveResource(AbstractArchiveResourceSet archiveResourceSet, String webAppPath, String baseUrl, JarEntry jarEntry, String codeBaseUrl)`
  The expectation is that this will be deprecated and then removed once the SecurityManager has been fully removed from the JRE and it has been confirmed that the JRE no longer depends on code base.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `canRead()`
  Checks if this resource can be read.
  `boolean`
  `delete()`
  Deletes this resource.
  `protected final InputStream`
  `doGetInputStream()`
  Returns the input stream for this resource.
  `boolean`
  `exists()`
  Checks if this resource exists.
  `protected AbstractArchiveResourceSet`
  `getArchiveResourceSet()`
  Returns the archive resource set.
  `protected final String`
  `getBase()`
  Returns the base.
  `protected final String`
  `getBaseUrl()`
  Returns the base URL.
  `String`
  `getCanonicalPath()`
  Returns the canonical path of this resource.
  `Certificate[]`
  `getCertificates()`
  Returns the certificates that were used to sign this resource to verify it.
  `URL`
  `getCodeBase()`
  Returns the code base for this resource.
  `final byte[]`
  `getContent()`
  Returns the binary content of this resource.
  `long`
  `getContentLength()`
  Returns the content length of this resource.
  `long`
  `getCreation()`
  Returns the creation time of this resource.
  `protected abstract AbstractArchiveResource.JarInputStreamWrapper`
  `getJarInputStreamWrapper()`
  Returns a wrapper for the input stream of this resource.
  `long`
  `getLastModified()`
  Returns the last modified time.
  `Manifest`
  `getManifest()`
  Returns the manifest associated with this resource.
  `String`
  `getName()`
  Returns the name of this resource.
  `protected final JarEntry`
  `getResource()`
  Returns the resource.
  `URL`
  `getURL()`
  Returns a URL to access this resource.
  `boolean`
  `isDirectory()`
  Checks if this resource is a directory.
  `boolean`
  `isFile()`
  Checks if this resource is a file.
  `boolean`
  `isVirtual()`
  Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additional `WebResourceSet`.

  ### Methods inherited from class AbstractResource

  `getETag, getInputStream, getLastModifiedHttp, getLog, getMimeType, getStrongETag, getWebappPath, getWebResourceRoot, setMimeType`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AbstractArchiveResource

    @Deprecated protected AbstractArchiveResource(AbstractArchiveResourceSet archiveResourceSet, String webAppPath, String baseUrl, JarEntry jarEntry)
    Deprecated.
    Deprecated even though this is the "new" constructor as code needs to call the old constructor for now.
    Parameters:
      `archiveResourceSet` - The archive resource set
      `webAppPath` - The web application path
      `baseUrl` - The base URL
      `jarEntry` - The JAR entry

  - ### AbstractArchiveResource

    protected AbstractArchiveResource(AbstractArchiveResourceSet archiveResourceSet, String webAppPath, String baseUrl, JarEntry jarEntry, String codeBaseUrl)
    The expectation is that this will be deprecated and then removed once the SecurityManager has been fully removed from the JRE and it has been confirmed that the JRE no longer depends on code base. See https://bz.apache.org/bugzilla/show_bug.cgi?id=69426
    Parameters:
      `archiveResourceSet` - The archive resource set
      `webAppPath` - The web application path
      `baseUrl` - The base URL
      `jarEntry` - The JAR entry
      `codeBaseUrl` - The code base URL

- ## Method Details

  - ### getArchiveResourceSet

    protected AbstractArchiveResourceSet getArchiveResourceSet()
    Returns the archive resource set.
    Returns:
      the archive resource set

  - ### getBase

    protected final String getBase()
    Returns the base.
    Returns:
      the base

  - ### getBaseUrl

    protected final String getBaseUrl()
    Returns the base URL.
    Returns:
      the base URL

  - ### getResource

    protected final JarEntry getResource()
    Returns the resource.
    Returns:
      the resource

  - ### getLastModified

    public long getLastModified()
    Description copied from interface: `WebResource`
    Returns the last modified time.
    Returns:
      `File.lastModified()`.

  - ### exists

    public boolean exists()
    Description copied from interface: `WebResource`
    Checks if this resource exists.
    Returns:
      `File.exists()`.

  - ### isVirtual

    public boolean isVirtual()
    Description copied from interface: `WebResource`
    Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additional `WebResourceSet`. For example, if an external directory is mapped to /WEB-INF/lib in an otherwise empty web application, /WEB-INF will be represented as a virtual resource.
    Returns:
      `true` for a virtual resource

  - ### isDirectory

    public boolean isDirectory()
    Description copied from interface: `WebResource`
    Checks if this resource is a directory.
    Returns:
      `File.isDirectory()`.

  - ### isFile

    public boolean isFile()
    Description copied from interface: `WebResource`
    Checks if this resource is a file.
    Returns:
      `File.isFile()`.

  - ### delete

    public boolean delete()
    Description copied from interface: `WebResource`
    Deletes this resource.
    Returns:
      `File.delete()`.

  - ### getName

    public String getName()
    Description copied from interface: `WebResource`
    Returns the name of this resource.
    Returns:
      `File.getName()`.

  - ### getContentLength

    public long getContentLength()
    Description copied from interface: `WebResource`
    Returns the content length of this resource.
    Returns:
      `File.length()`.

  - ### getCanonicalPath

    public String getCanonicalPath()
    Description copied from interface: `WebResource`
    Returns the canonical path of this resource.
    Returns:
      `File.getCanonicalPath()`.

  - ### canRead

    public boolean canRead()
    Description copied from interface: `WebResource`
    Checks if this resource can be read.
    Returns:
      `File.canRead()`.

  - ### getCreation

    public long getCreation()
    Description copied from interface: `WebResource`
    Returns the creation time of this resource.
    Returns:
      The time the file was created. If not available, the result of `WebResource.getLastModified()` will be returned.

  - ### getURL

    public URL getURL()
    Description copied from interface: `WebResource`
    Returns a URL to access this resource.
    Returns:
      a URL to access the resource or `null` if no such URL is available or if the resource does not exist.

  - ### getCodeBase

    public URL getCodeBase()
    Description copied from interface: `WebResource`
    Returns the code base for this resource.

    The expectation is that this will be deprecated and then removed once the SecurityManager has been fully removed from the JRE, and it has been confirmed that the JRE no longer depends on code base.

    Returns:
      the code base for this resource that will be used when looking up the assigned permissions for the code base in the security policy file when running under a security manager.

  - ### getContent

    public final byte[] getContent()
    Description copied from interface: `WebResource`
    Returns the binary content of this resource.
    Returns:
      the binary content of this resource or `null` if it is not available in a byte[] because, for example, it is too big.

  - ### getCertificates

    public Certificate[] getCertificates()
    Description copied from interface: `WebResource`
    Returns the certificates that were used to sign this resource to verify it.
    Returns:
      the certificates that were used to sign this resource to verify it or @null if none.
    See Also:
      - `JarEntry.getCertificates()`

  - ### getManifest

    public Manifest getManifest()
    Description copied from interface: `WebResource`
    Returns the manifest associated with this resource.
    Returns:
      the manifest associated with this resource or @null if none.
    See Also:
      - `JarFile.getManifest()`

  - ### doGetInputStream

    protected final InputStream doGetInputStream()
    Description copied from class: `AbstractResource`
    Returns the input stream for this resource.
    Specified by:
      `doGetInputStream` in class `AbstractResource`
    Returns:
      the input stream for this resource

  - ### getJarInputStreamWrapper

    protected abstract AbstractArchiveResource.JarInputStreamWrapper getJarInputStreamWrapper()
    Returns a wrapper for the input stream of this resource.
    Returns:
      a wrapper for the input stream of this resource