Class ServletFilterRegistration.Builder

java.lang.Object
org.apache.juneau.microservice.ServletFilterRegistration.Builder
Enclosing class:
ServletFilterRegistration

public static final class ServletFilterRegistration.Builder extends Object
  • Method Details

    • urlPatterns

      Sets the URL patterns the filter is mapped to.

      Replaces any patterns set before. At least one is required. Duplicates are dropped, keeping the first. Each pattern must be one of:

      • A path prefix: /.../* (including "/*"), where the trailing * is the only one.
      • An extension: *.ext, with no /.
      • An exact path: starts with / and contains no *.
      • The empty string "": the context root.
      Anything else is rejected, including a bare "/" (the default servlet, which a filter should not be mapped to), a blank (non-empty) pattern, and Jetty-only path-spec syntax such as regex:... or ^.... Rejecting these keeps a typo such as "/console*" from silently mapping a boundary to nothing.
      Parameters:
      value - The URL patterns. Cannot be null.
      Returns:
      This object.
    • dispatcherTypes

      public ServletFilterRegistration.Builder dispatcherTypes(jakarta.servlet.DispatcherType... value)
      Sets the dispatcher types the filter is mapped to.

      Replaces the default of DispatcherType.REQUEST, so list REQUEST explicitly when it is wanted. A filter mapped to ASYNC only does not run for the plain request. Add FORWARD, ASYNC and ERROR for a boundary that must also see internal dispatches.

      Parameters:
      value - The dispatcher types. At least one is required, and none can be null.
      Returns:
      This object.
    • order

      Sets the order: lower values run first (further out).

      Defaults to ServletFilterRegistration.DEFAULT_ORDER. See ServletFilterRegistration for how it relates to authentication.

      Parameters:
      value - The order.
      Returns:
      This object.
    • asyncSupported

      Sets whether the filter supports asynchronous request processing.

      Defaults to true. A filter in the chain that does not support it makes request.isAsyncSupported() false for every request it covers.

      Parameters:
      value - Whether async is supported.
      Returns:
      This object.
    • name

      Sets the container filter name.

      Optional; when absent the component generates a unique one. An explicit name must be unique among the registrations.

      Parameters:
      value - The filter name. Can be null (generate one), but not blank.
      Returns:
      This object.
    • build

      Validates and builds the registration.
      Returns:
      A new immutable registration.
      Throws:
      IllegalArgumentException - If there is no URL pattern, a pattern is malformed, or there is no dispatcher type or a null one.