Class RestOpContext

java.lang.Object
org.apache.juneau.Context
org.apache.juneau.rest.RestOpContext
All Implemented Interfaces:
Comparable<RestOpContext>, AnnotationProvider
Direct Known Subclasses:
RrpcRestOpContext

public class RestOpContext extends Context implements Comparable<RestOpContext>
Represents a single Java servlet/resource method annotated with @RestOp.
Notes:
  • This class is thread safe and reusable.
See Also:
  • Constructor Details

    • RestOpContext

      protected RestOpContext(RestOpContext.Builder builder) throws jakarta.servlet.ServletException
      Context constructor.
      Parameters:
      builder - The builder for this object.
      Throws:
      jakarta.servlet.ServletException - If context could not be created.
  • Method Details

    • create

      public static RestOpContext.Builder create(Method method, RestContext context)
      Creates a new builder for this object.
      Parameters:
      method - The Java method this context belongs to.
      context - The Java class context.
      Returns:
      A new builder.
    • createSession

      Creates a new REST operation session.
      Parameters:
      session - The REST session.
      Returns:
      A new REST operation session.
      Throws:
      Exception - If op session could not be created.
    • createRequest

      Creates a RestRequest object based on the specified incoming HttpServletRequest object.
      Parameters:
      session - The current REST call.
      Returns:
      The wrapped request object.
      Throws:
      Exception - If any errors occur trying to interpret the request.
    • createResponse

      Creates a RestResponse object based on the specified incoming HttpServletResponse object and the request returned by createRequest(RestSession).
      Parameters:
      session - The current REST call.
      req - The REST request.
      Returns:
      The wrapped response object.
      Throws:
      Exception - If any errors occur trying to interpret the request or response.
    • getBeanContext

      Returns the bean context associated with this context.
      Returns:
      The bean context associated with this context.
    • getResponseBeanMeta

      Returns metadata about the specified response object if it's annotated with @Response.
      Parameters:
      o - The response POJO.
      Returns:
      Metadata about the specified response object, or null if it's not annotated with @Response.
    • getResponseHeaderMeta

      Returns metadata about the specified response object if it's annotated with @Header.
      Parameters:
      o - The response POJO.
      Returns:
      Metadata about the specified response object, or null if it's not annotated with @Header.
    • getHttpMethod

      Returns the HTTP method name (e.g. "GET").
      Returns:
      The HTTP method name.
    • getPathPattern

      Returns the path pattern for this method.
      Returns:
      The path pattern.
    • getSerializers

      Returns the serializers to use for this method.
      Returns:
      The serializers to use for this method.
    • getParsers

      Returns the parsers to use for this method.
      Returns:
      The parsers to use for this method.
    • getEncoders

      Returns the compression encoders to use for this method.
      Returns:
      The compression encoders to use for this method.
    • getPartSerializer

      Bean property getter: partSerializer.
      Returns:
      The value of the partSerializer property on this bean, or null if it is not set.
    • getPartParser

      Bean property getter: partParser.
      Returns:
      The value of the partParser property on this bean, or null if it is not set.
    • getJsonSchemaGenerator

      Returns the JSON-Schema generator applicable to this Java method.
      Returns:
      The JSON-Schema generator applicable to this Java method.
    • getJavaMethod

      Returns the underlying Java method that this context belongs to.
      Returns:
      The underlying Java method that this context belongs to.
    • getDefaultRequestHeaders

      Returns the default request headers.
      Returns:
      The default request headers. Never null.
    • getDefaultResponseHeaders

      Returns the default response headers.
      Returns:
      The default response headers. Never null.
    • getDefaultRequestQueryData

      Returns the default request query parameters.
      Returns:
      The default request query parameters. Never null.
    • getDefaultRequestFormData

      Returns the default form data parameters.
      Returns:
      The default form data parameters. Never null.
    • getDefaultRequestAttributes

      Returns the default request attributes.
      Returns:
      The default request attributes. Never null.
    • getDefaultCharset

      Returns the default charset.
      Returns:
      The default charset. Never null.
    • getMaxInput

      public long getMaxInput()
      Returns the max number of bytes to process in the input content.
      Returns:
      The max number of bytes to process in the input content.
    • getSupportedContentTypes

      Returns the list of supported content types.
      Returns:
      An unmodifiable list.
    • getSupportedAcceptTypes

      Returns a list of supported accept types.
      Returns:
      An unmodifiable list.
    • getResponseMeta

      Returns the response bean meta if this method returns a Response-annotated bean.
      Returns:
      The response bean meta or null if it's not a Response-annotated bean.
    • match

      protected int match(RestSession session)
      Identifies if this method can process the specified call.

      To process the call, the following must be true:

      • Path pattern must match.
      • Matchers (if any) must match.
      Parameters:
      session - The call to check.
      Returns:
      One of the following values:
      • 0 - Path doesn't match.
      • 1 - Path matched but matchers did not.
      • 2 - Matches.
    • copy

      Description copied from class: Context
      Creates a builder from this context object.

      Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.

      Overrides:
      copy in class Context
      Returns:
      A new Builder object.
    • compareTo

      public int compareTo(RestOpContext o)
      Specified by:
      compareTo in interface Comparable<RestOpContext>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • properties

      protected JsonMap properties()
      Description copied from class: Context
      Returns the properties on this bean as a map for debugging.
      Overrides:
      properties in class Context
      Returns:
      The properties on this bean as a map for debugging.