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

# Class AbstractFileResourceSet

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.webresources.AbstractResourceSet
org.apache.catalina.webresources.AbstractFileResourceSet

All Implemented Interfaces:
  `Lifecycle, WebResourceSet`

Direct Known Subclasses:
  `DirResourceSet, FileResourceSet`

public abstract class AbstractFileResourceSet extends AbstractResourceSet
Abstract implementation of `WebResourceSet` that is based on a directory on a file system.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Lifecycle

  `Lifecycle.SingleUse`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final String[]`
  `EMPTY_STRING_ARRAY`
  An empty string array.

  ### 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
  Modifier
  Constructor
  Description
  `protected`
  `AbstractFileResourceSet(String internalPath)`
  Constructs a new abstract file resource set.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract void`
  `checkType(File file)`
  Checks the type of the specified file.
  `protected final File`
  `file(String name, boolean mustExist)`
  Return a File for the specified resource name.
  `void`
  `gc()`
  Implementations may cache some information to improve performance.
  `boolean`
  `getAllowLinking()`
  Determine if this `ResourceSet` allows the use of symbolic links.
  `URL`
  `getBaseUrl()`
  Obtain the base URL for this set of resources.
  `protected final File`
  `getFileBase()`
  Returns the file base for this resource set.
  `protected void`
  `initInternal()`
  Subclasses implement this method to perform any instance initialisation required.
  `boolean`
  `isReadOnly()`
  Obtains the current value of the read-only setting for this set of resources.
  `protected void`
  `logIgnoredSymlink(String contextPath, String absPath, String canPath)`
  Logs a message about an ignored symlink.
  `void`
  `setAllowLinking(boolean allowLinking)`
  Configure if this `ResourceSet` allows the use of symbolic links.
  `void`
  `setReadOnly(boolean readOnly)`
  Configures whether or not this set of resources is read-only.

  ### 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`

  ### Methods inherited from interface WebResourceSet

  `getResource, list, listWebAppPaths, mkdir, write`

- ## Field Details

  - ### EMPTY_STRING_ARRAY

    protected static final String[] EMPTY_STRING_ARRAY
    An empty string array.

- ## Constructor Details

  - ### AbstractFileResourceSet

    protected AbstractFileResourceSet(String internalPath)
    Constructs a new abstract file resource set.
    Parameters:
      `internalPath` - The internal path

- ## Method Details

  - ### getFileBase

    protected final File getFileBase()
    Returns the file base for this resource set.
    Returns:
      the file base

  - ### setReadOnly

    public void setReadOnly(boolean readOnly)
    Description copied from interface: `WebResourceSet`
    Configures whether or not this set of resources is read-only.
    Parameters:
      `readOnly` - `true` if this set of resources should be configured to be read-only

  - ### isReadOnly

    public boolean isReadOnly()
    Description copied from interface: `WebResourceSet`
    Obtains the current value of the read-only setting for this set of resources.
    Returns:
      `true` if this set of resources is configured to be read-only, otherwise `false`

  - ### setAllowLinking

    public void setAllowLinking(boolean allowLinking)
    Description copied from interface: `WebResourceSet`
    Configure if this `ResourceSet` allows the use of symbolic links.
    Parameters:
      `allowLinking` - `true` if symbolic links are allowed.

  - ### getAllowLinking

    public boolean getAllowLinking()
    Description copied from interface: `WebResourceSet`
    Determine if this `ResourceSet` allows the use of symbolic links. If `WebResourceSet.setAllowLinking(boolean)` has not been called for this instance, the value of `WebResourceRoot.getAllowLinking()` is returned.
    Returns:
      `true` if symbolic links are allowed

  - ### file

    protected final File file(String name, boolean mustExist)
    Return a File for the specified resource name.
    Parameters:
      `name` - Name of the resource
      `mustExist` - Whether the file must exist
    Returns:
      the file for the specified resource

  - ### logIgnoredSymlink

    protected void logIgnoredSymlink(String contextPath, String absPath, String canPath)
    Logs a message about an ignored symlink.
    Parameters:
      `contextPath` - The context path
      `absPath` - The absolute path
      `canPath` - The canonical path

  - ### getBaseUrl

    public URL getBaseUrl()
    Description copied from interface: `WebResourceSet`
    Obtain the base URL for this set of resources. One of the uses of this is to grant read permissions to the resources when running under a security manager.
    Returns:
      The base URL for this set of resources

  - ### gc

    public void gc()
    Implementations may cache some information to improve performance. This method triggers the clean-up of those resources.

    This is a NO-OP by default for File based resource sets.

  - ### 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

  - ### checkType

    protected abstract void checkType(File file)
    Checks the type of the specified file.
    Parameters:
      `file` - The file to check
    Throws:
      `IllegalArgumentException` - if the file is not of the expected type