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

# Class JarWarResourceSet

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.webresources.AbstractResourceSet
org.apache.catalina.webresources.AbstractArchiveResourceSet
org.apache.catalina.webresources.JarWarResourceSet

All Implemented Interfaces:
  `Lifecycle, WebResourceSet`

public class JarWarResourceSet extends AbstractArchiveResourceSet
Represents a `WebResourceSet` based on a JAR file that is nested inside a packed WAR file. This is only intended for internal use within Tomcat and therefore cannot be created via configuration.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Lifecycle

  `Lifecycle.SingleUse`

- ## Field Summary

  ### Fields inherited from class AbstractArchiveResourceSet

  `archive, archiveEntries, archiveLock, archiveUseCount, jarContents, retainBloomFilterForArchives`

  ### Fields inherited from class AbstractResourceSet

  `sm`

  ### Fields inherited from interface Lifecycle

  `AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JarWarResourceSet(WebResourceRoot root, String webAppMount, String base, String archivePath, String internalPath)`
  Creates a new `WebResourceSet` based on a JAR file that is nested inside a WAR.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected WebResource`
  `createArchiveResource(JarEntry jarEntry, String webAppPath, Manifest manifest)`
  Creates an archive resource.
  `protected Map<String,JarEntry>`
  `getArchiveEntries(boolean single)`
  Obtain the map of entries in the archive.
  `protected JarEntry`
  `getArchiveEntry(String pathInArchive)`
  Obtain a single entry from the archive.
  `protected void`
  `initInternal()`
  Subclasses implement this method to perform any instance initialisation required.
  `protected boolean`
  `isMultiRelease()`
  Checks if this is a multi-release JAR.
  `protected JarFile`
  `openJarFile()`
  `protected void`
  `processArchivesEntriesForMultiRelease()`
  Process archive entries for multi-release JAR support.

  ### Methods inherited from class AbstractArchiveResourceSet

  `closeJarFile, gc, getAllowLinking, getBaseUrl, getBaseUrlString, getResource, isReadOnly, list, listWebAppPaths, mkdir, setAllowLinking, setBaseUrl, setReadOnly, write`

  ### Methods inherited from class AbstractResourceSet

  `checkPath, destroyInternal, getBase, getClassLoaderOnly, getInternalPath, getManifest, getRoot, getStaticOnly, getWebAppMount, isPathMounted, setBase, setClassLoaderOnly, setInternalPath, setManifest, setRoot, setStaticOnly, setWebAppMount, startInternal, stopInternal`

  ### Methods inherited from class LifecycleBase

  `addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

  ### Methods inherited from class Object

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

  ### Methods inherited from interface Lifecycle

  `addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop`

- ## Constructor Details

  - ### JarWarResourceSet

    public JarWarResourceSet(WebResourceRoot root, String webAppMount, String base, String archivePath, String internalPath) throws IllegalArgumentException
    Creates a new `WebResourceSet` based on a JAR file that is nested inside a WAR.
    Parameters:
      `root` - The `WebResourceRoot` this new `WebResourceSet` will be added to.
      `webAppMount` - The path within the web application at which this `WebResourceSet` will be mounted.
      `base` - The absolute path to the WAR file on the file system in which the JAR is located.
      `archivePath` - The path within the WAR file where the JAR file is located.
      `internalPath` - The path within this new `WebResourceSet` where resources will be served from. E.g. for a resource JAR, this would be "META-INF/resources"
    Throws:
      `IllegalArgumentException` - if the webAppMount or internalPath is not valid (valid paths must start with '/')

- ## Method Details

  - ### createArchiveResource

    protected WebResource createArchiveResource(JarEntry jarEntry, String webAppPath, Manifest manifest)
    Description copied from class: `AbstractArchiveResourceSet`
    Creates an archive resource.
    Specified by:
      `createArchiveResource` in class `AbstractArchiveResourceSet`
    Parameters:
      `jarEntry` - The JAR entry
      `webAppPath` - The web application path
      `manifest` - The manifest
    Returns:
      the archive resource

  - ### getArchiveEntries

    protected Map<String,JarEntry> getArchiveEntries(boolean single)
    Obtain the map of entries in the archive. May return null in which case `AbstractArchiveResourceSet.getArchiveEntry(String)` should be used.

    JarWar can't optimise for a single resource so the Map is always returned.

    Specified by:
      `getArchiveEntries` in class `AbstractArchiveResourceSet`
    Parameters:
      `single` - Is this request being make to support a single lookup? If false, a map will always be returned. If true, implementations may use this as a hint in determining the optimum way to respond.
    Returns:
      The archives entries mapped to their names or null if `AbstractArchiveResourceSet.getArchiveEntry(String)` should be used.

  - ### openJarFile

    protected JarFile openJarFile() throws IOException

    JarWar needs to generate jarContents for the inner JAR, not the outer WAR.

    Overrides:
      `openJarFile` in class `AbstractArchiveResourceSet`
    Throws:
      `IOException`

  - ### processArchivesEntriesForMultiRelease

    protected void processArchivesEntriesForMultiRelease()
    Process archive entries for multi-release JAR support.

  - ### getArchiveEntry

    protected JarEntry getArchiveEntry(String pathInArchive)
    Obtain a single entry from the archive. For performance reasons, `AbstractArchiveResourceSet.getArchiveEntries(boolean)` should always be called first and the archive entry looked up in the map if one is returned. Only if that call returns null should this method be used.

    Should never be called since `getArchiveEntries(boolean)` always returns a Map.

    Specified by:
      `getArchiveEntry` in class `AbstractArchiveResourceSet`
    Parameters:
      `pathInArchive` - The path in the archive of the entry required
    Returns:
      The specified archive entry or null if it does not exist

  - ### isMultiRelease

    protected boolean isMultiRelease()
    Description copied from class: `AbstractArchiveResourceSet`
    Checks if this is a multi-release JAR.
    Specified by:
      `isMultiRelease` in class `AbstractArchiveResourceSet`
    Returns:
      true if this is a multi-release JAR, false otherwise

  - ### initInternal

    protected void initInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses implement this method to perform any instance initialisation required.
    Specified by:
      `initInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - If the initialisation fails