Class RestObject

java.lang.Object
org.apache.juneau.rest.servlet.RestObject
Direct Known Subclasses:
BasicRestObject

public abstract class RestObject extends Object
Identical to RestServlet but doesn't extend from HttpServlet.

This is particularly useful in Spring Boot environments that auto-detect servlets to deploy in servlet containers, but you want this resource to be deployed as a child instead.

See Also:
  • Constructor Details

  • Method Details

    • setContext

      protected void setContext(RestContext context) throws jakarta.servlet.ServletException
      Sets the context object for this servlet.
      Parameters:
      context - Sets the context object on this servlet.
      Throws:
      jakarta.servlet.ServletException - If error occurred during post-initialiation.
    • getContext

      protected RestContext getContext()
      Returns the read-only context object that contains all the configuration information about this resource.
      Returns:
      The context information on this servlet.
    • log

      public void log(Level level, String msg, Object... args)
      Log a message.

      Subclasses can intercept the handling of these messages by overriding doLog(Level, Throwable, Supplier).

      Parameters:
      level - The log level.
      msg - The message to log.
      args - Optional MessageFormat-style arguments.
    • log

      public void log(Level level, Throwable cause, String msg, Object... args)
      Log a message.

      Subclasses can intercept the handling of these messages by overriding doLog(Level, Throwable, Supplier).

      Parameters:
      level - The log level.
      cause - The cause.
      msg - The message to log.
      args - Optional MessageFormat-style arguments.
    • doLog

      protected void doLog(Level level, Throwable cause, Supplier<String> msg)
      Main logger method.

      The default behavior logs a message to the Java logger of the class name.

      Subclasses can override this method to implement their own logger handling.

      Parameters:
      level - The log level.
      cause - Optional throwable.
      msg - The message to log.
    • getRequest

      Returns the current thread-local HTTP request.
      Returns:
      The current thread-local HTTP request, or null if it wasn't created.
    • getResponse

      Returns the current thread-local HTTP response.
      Returns:
      The current thread-local HTTP response, or null if it wasn't created.