Package org.apache.juneau.rest
Class RestOpContext
java.lang.Object
org.apache.juneau.Context
org.apache.juneau.rest.RestOpContext
- All Implemented Interfaces:
Comparable<RestOpContext>
,AnnotationProvider
- Direct Known Subclasses:
RrpcRestOpContext
Represents a single Java servlet/resource method annotated with
@RestOp
.
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.apache.juneau.Context
CONTEXT_APPLY_FILTER
Fields inherited from interface org.apache.juneau.AnnotationProvider
DEFAULT, DISABLE_ANNOTATION_CACHING
-
Constructor Summary
ModifierConstructorDescriptionprotected
RestOpContext
(RestOpContext.Builder builder) Context constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
copy()
Creates a builder from this context object.static RestOpContext.Builder
create
(Method method, RestContext context) Creates a new builder for this object.createRequest
(RestSession session) Creates aRestRequest
object based on the specified incomingHttpServletRequest
object.createResponse
(RestSession session, RestRequest req) Creates aRestResponse
object based on the specified incomingHttpServletResponse
object and the request returned bycreateRequest(RestSession)
.createSession
(RestSession session) Creates a new REST operation session.boolean
Returns the bean context associated with this context.Returns the default charset.Returns the default request attributes.Returns the default form data parameters.Returns the default request headers.Returns the default request query parameters.Returns the default response headers.Returns the compression encoders to use for this method.Returns the HTTP method name (e.g.Returns the underlying Java method that this context belongs to.Returns the JSON-Schema generator applicable to this Java method.long
Returns the max number of bytes to process in the input content.Returns the parsers to use for this method.Bean property getter:partParser .Bean property getter:partSerializer .Returns the path pattern for this method.Returns metadata about the specified response object if it's annotated with@Response
.Returns metadata about the specified response object if it's annotated with@Header
.Returns the response bean meta if this method returns aResponse
-annotated bean.Returns the serializers to use for this method.Returns a list of supported accept types.Returns the list of supported content types.int
hashCode()
protected int
match
(RestSession session) Identifies if this method can process the specified call.protected JsonMap
Returns the properties on this bean as a map for debugging.Methods inherited from class org.apache.juneau.Context
createBuilder, createSession, firstAnnotation, firstAnnotation, firstAnnotation, firstAnnotation, firstDeclaredAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachDeclaredAnnotation, getSession, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, init, isDebug, lastAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastDeclaredAnnotation, toString
-
Constructor Details
-
RestOpContext
Context constructor.- Parameters:
builder
- The builder for this object.- Throws:
jakarta.servlet.ServletException
- If context could not be created.
-
-
Method Details
-
create
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 aRestRequest
object based on the specified incomingHttpServletRequest
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 aRestResponse
object based on the specified incomingHttpServletResponse
object and the request returned bycreateRequest(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, ornull if it is not set.
-
getPartParser
Bean property getter:partParser .- Returns:
- The value of the
partParser property on this bean, ornull 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
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 aResponse
-annotated bean.- Returns:
- The response bean meta or
null if it's not aResponse
-annotated bean.
-
match
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.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<RestOpContext>
-
equals
-
hashCode
-
properties
Description copied from class:Context
Returns the properties on this bean as a map for debugging.- Overrides:
properties
in classContext
- Returns:
- The properties on this bean as a map for debugging.
-