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

# Class ValveBase

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.valves.ValveBase

All Implemented Interfaces:
  `MBeanRegistration, Contained, JmxEnabled, Lifecycle, Valve`

Direct Known Subclasses:
  `AbstractAccessLogValve, AuthenticatorBase, CrawlerSessionManagerValve, ErrorReportValve, FilterValve, HealthCheckValve, JDBCAccessLogValve, JvmRouteBinderValve, LoadBalancerDrainingValve, ParameterLimitValve, PersistentValve, RemoteIpValve, ReplicationValve, RequestFilterValve, RewriteValve, SemaphoreValve, SingleSignOn, SSLValve, StuckThreadDetectionValve`

public abstract class ValveBase extends LifecycleMBeanBase implements Contained, Valve
Convenience base class for implementations of the Valve interface. A subclass MUST implement an `invoke()` method to provide the required functionality, and MAY implement the `Lifecycle` interface to provide configuration management and lifecycle support.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Lifecycle

  `Lifecycle.SingleUse`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected boolean`
  `asyncSupported`
  Does this valve support Servlet 3+ async requests?
  `protected Container`
  `container`
  The Container whose pipeline this Valve is a component of.
  `protected Log`
  `containerLog`
  Container log
  `protected Valve`
  `next`
  The next Valve in the pipeline this Valve is a component of.
  `protected static final StringManager`
  `sm`
  StringManager for internationalized strings.

  ### 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
  `ValveBase()`
  Constructs a new ValveBase with async support disabled.
  `ValveBase(boolean asyncSupported)`
  Constructs a new ValveBase.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `backgroundProcess()`
  Execute a periodic task, such as reloading, etc.
  `Container`
  `getContainer()`
  Get the `Container` with which this instance is associated.
  `String`
  `getDomainInternal()`
  Method implemented by subclasses to identify the domain in which MBeans should be registered.
  `Valve`
  `getNext()`
  Returns the next Valve in this pipeline, or `null` if this is the last Valve in the pipeline.
  `String`
  `getObjectNameKeyProperties()`
  Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
  `protected void`
  `initInternal()`
  Subclasses implement this method to perform any instance initialisation required.
  `boolean`
  `isAsyncSupported()`
  Returns whether this Valve supports Servlet 3+ async requests.
  `void`
  `setAsyncSupported(boolean asyncSupported)`
  Sets whether this valve supports Servlet 3+ async requests.
  `void`
  `setContainer(Container container)`
  Set the `Container` with which this instance is associated.
  `void`
  `setNext(Valve valve)`
  Set the next Valve in the pipeline containing this Valve.
  `protected void`
  `startInternal()`
  Start this component and implement the requirements of `LifecycleBase.startInternal()`.
  `protected void`
  `stopInternal()`
  Stop this component and implement the requirements of `LifecycleBase.stopInternal()`.
  `String`
  `toString()`

  ### Methods inherited from class LifecycleMBeanBase

  `destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister`

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

  ### Methods inherited from interface Valve

  `invoke`

- ## Field Details

  - ### sm

    protected static final StringManager sm
    StringManager for internationalized strings.

  - ### asyncSupported

    protected boolean asyncSupported
    Does this valve support Servlet 3+ async requests?

  - ### container

    protected Container container
    The Container whose pipeline this Valve is a component of.

  - ### containerLog

    protected Log containerLog
    Container log

  - ### next

    protected Valve next
    The next Valve in the pipeline this Valve is a component of.

- ## Constructor Details

  - ### ValveBase

    public ValveBase()
    Constructs a new ValveBase with async support disabled.

  - ### ValveBase

    public ValveBase(boolean asyncSupported)
    Constructs a new ValveBase.
    Parameters:
      `asyncSupported` - Whether this valve supports async requests

- ## Method Details

  - ### getContainer

    public Container getContainer()
    Description copied from interface: `Contained`
    Get the `Container` with which this instance is associated.
    Specified by:
      `getContainer` in interface `Contained`
    Returns:
      The Container with which this instance is associated or `null` if not associated with a Container

  - ### setContainer

    public void setContainer(Container container)
    Description copied from interface: `Contained`
    Set the `Container` with which this instance is associated.
    Specified by:
      `setContainer` in interface `Contained`
    Parameters:
      `container` - The Container instance with which this instance is to be associated, or `null` to disassociate this instance from any Container

  - ### isAsyncSupported

    public boolean isAsyncSupported()
    Description copied from interface: `Valve`
    Returns whether this Valve supports Servlet 3+ async requests.
    Specified by:
      `isAsyncSupported` in interface `Valve`
    Returns:
      `true` if async is supported, `false` otherwise

  - ### setAsyncSupported

    public void setAsyncSupported(boolean asyncSupported)
    Sets whether this valve supports Servlet 3+ async requests.
    Parameters:
      `asyncSupported` - Whether this valve supports async requests

  - ### getNext

    public Valve getNext()
    Description copied from interface: `Valve`
    Returns the next Valve in this pipeline, or `null` if this is the last Valve in the pipeline.
    Specified by:
      `getNext` in interface `Valve`
    Returns:
      the next Valve in the pipeline containing this Valve, or `null` if this is the last Valve in the pipeline.

  - ### setNext

    public void setNext(Valve valve)
    Description copied from interface: `Valve`
    Set the next Valve in the pipeline containing this Valve.
    Specified by:
      `setNext` in interface `Valve`
    Parameters:
      `valve` - The new next valve, or `null` if none

  - ### backgroundProcess

    public void backgroundProcess()
    Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.

    The default implementation is NO-OP.

    Specified by:
      `backgroundProcess` in interface `Valve`

  - ### initInternal

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

  - ### startInternal

    protected void startInternal() throws LifecycleException
    Start this component and implement the requirements of `LifecycleBase.startInternal()`.
    Specified by:
      `startInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - if this component detects a fatal error that prevents this component from being used

  - ### stopInternal

    protected void stopInternal() throws LifecycleException
    Stop this component and implement the requirements of `LifecycleBase.stopInternal()`.
    Specified by:
      `stopInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - if this component detects a fatal error that prevents this component from being used

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getObjectNameKeyProperties

    public String getObjectNameKeyProperties()
    Description copied from class: `LifecycleMBeanBase`
    Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
    Specified by:
      `getObjectNameKeyProperties` in class `LifecycleMBeanBase`
    Returns:
      The string representation of the key properties component of the desired `ObjectName`

  - ### getDomainInternal

    public String getDomainInternal()
    Description copied from class: `LifecycleMBeanBase`
    Method implemented by subclasses to identify the domain in which MBeans should be registered.
    Specified by:
      `getDomainInternal` in class `LifecycleMBeanBase`
    Returns:
      The name of the domain to use to register MBeans.