Class DebugEnablement

java.lang.Object
org.apache.juneau.rest.debug.DebugEnablement
Direct Known Subclasses:
BasicDebugEnablement, DebugEnablement.Void

public abstract class DebugEnablement extends Object
Interface used for selectively turning on debug per request.
See Also:
  • Constructor Details

    • DebugEnablement

      public DebugEnablement(BeanStore beanStore)
      Constructor.

      Subclasses typically override the init(BeanStore) method when using this constructor.

      Parameters:
      beanStore - The bean store containing injectable beans for this enablement.
    • DebugEnablement

      Constructor.
      Parameters:
      builder - The builder for this enablement.
  • Method Details

    • create

      public static DebugEnablement.Builder create(BeanStore beanStore)
      Static creator.
      Parameters:
      beanStore - The bean store to use for creating beans.
      Returns:
      A new builder for this object.
    • init

      protected DebugEnablement.Builder init(BeanStore beanStore)
      Initializer.

      Subclasses should override this method to make modifications to the builder used to create this logger.

      Parameters:
      beanStore - The bean store containing injectable beans for this logger.
      Returns:
      A new builder object.
    • isDebug

      public boolean isDebug(RestContext context, jakarta.servlet.http.HttpServletRequest req)
      Returns true if debug is enabled on the specified class and request.

      This enables debug mode on requests once the matched class is found and before the Java method is found.

      Parameters:
      context - The context of the Rest-annotated class.
      req - The HTTP request.
      Returns:
      true if debug is enabled on the specified method and request.
    • isDebug

      public boolean isDebug(RestOpContext context, jakarta.servlet.http.HttpServletRequest req)
      Returns true if debug is enabled on the specified method and request.

      This enables debug mode after the Java method is found and allows you to enable debug on individual Java methods instead of the entire class.

      Parameters:
      context - The context of the RestOp-annotated method.
      req - The HTTP request.
      Returns:
      true if debug is enabled on the specified method and request.
    • isConditionallyEnabled

      protected boolean isConditionallyEnabled(jakarta.servlet.http.HttpServletRequest req)
      Returns true if debugging is conditionally enabled on the specified request.

      This method only gets called when the enablement value resolves to CONDITIONAL.

      Subclasses can override this method to provide their own implementation. The default implementation is provided by DebugEnablement.Builder.conditional(Predicate) which has a default predicate of x -> "true".equalsIgnoreCase(x.getHeader("Debug").

      Parameters:
      req - The incoming HTTP request.
      Returns:
      true if debugging is conditionally enabled on the specified request.
    • toString

      public String toString()
      Overrides:
      toString in class Object