Class RestOpContext
- All Implemented Interfaces:
Comparable<RestOpContext>
- Direct Known Subclasses:
RrpcRestOpContext
@RestOp.
Notes:
- This class is thread safe and reusable.
See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final RestContextprotected final Map<Class<?>,ResponsePartMeta> protected final Methodprotected final MethodInfoprotected final Map<Class<?>,ResponseBeanMeta> Fields inherited from class org.apache.juneau.marshall.Context
CONTEXT_APPLY_FILTER -
Constructor Summary
ConstructorsConstructorDescriptionRestOpContext(Method method, RestContext context) 2-arg positional context constructor.RestOpContext(Method method, RestContext context, Supplier<Object> resourceSupplier) 3-arg positional context constructor. -
Method Summary
Modifier and TypeMethodDescriptionintcopy()Creates a builder from this context object.createRequest(RestSession session) Creates aRestRequestobject based on the specified incomingHttpServletRequestobject.createResponse(RestSession session, RestRequest req) Creates aRestResponseobject based on the specified incomingHttpServletResponseobject and the request returned bycreateRequest(RestSession).createSession(RestSession session) Creates a new REST operation session.booleanReturns the parser session-option keys allowed for this operation.Returns the serializer session-option keys allowed for this operation.Returns the effectiveExecutorfor routingCompletableFuturecompletion callbacks on this operation, ornullwhen neither the op nor the resource configures an executor (natural completion thread).longReturns the configured async-response timeout (milliseconds) for this operation, or-1when no value was supplied at the op or resource level — in which case the default 30-second fallback applies inAsyncResponseProcessor.Returns theRestContextthat owns this operation 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.Returns the per-operation logger used for debug capture.Returns the marshalling context associated with this context.longReturns the max number of bytes to process in the input content.Returns the per-op metric name override from@RestOp(metricName).Returns the per-op additional metric tags from@RestOp(metricTags).Returns the optional matchers for this operation.Returns the parsers to use for this method.Bean property getter:partParser .Bean property getter:partSerializer .Returns the URL path matchers for this operation.Returns the path pattern for this method.Returns the required matchers for this operation.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.List<AnnotationInfo<?>>Returns allRestOp-group annotations on this operation method, in child-to-parent order.Returns the serializers to use for this method.Returns a list of supported accept types.Returns the list of supported content types.inthashCode()booleanReturns whether REST-driven serializer/parser debug behavior is enabled for this operation.protected booleanisInherited(String property) Returnstrueif context-level values for the given property should be merged.booleanReturns whether the observability block is enabled for this operation.booleanReturns whether this operation emits RFC 7807application/problem+jsonresponses.booleanisRead()Returns whether this operation is declaredread=true.booleanReturns whether this operation opts into per-request virtual-thread dispatch on Java 21+.protected intmatch(RestSession session) Identifies if this method can process the specified call.Returns the properties on this bean as a map for debugging.Methods inherited from class org.apache.juneau.marshall.Context
createBuilder, createSession, getAnnotationProvider, getSession, init, isDebug, toString
-
Field Details
-
responseBeanMetas
-
headerPartMetas
-
method
-
mi
-
context
-
-
Constructor Details
-
RestOpContext
2-arg positional context constructor.All operation-level configuration is resolved from
RestOp-group annotations on the method and inherited from the parentRestContext.- Parameters:
method- The Java method this context represents. Must not benull .context- The owningRestContext. Must not benull .- Throws:
jakarta.servlet.ServletException- If context could not be created.- Since:
- 9.2.1
-
RestOpContext
public RestOpContext(Method method, RestContext context, Supplier<Object> resourceSupplier) throws jakarta.servlet.ServletException 3-arg positional context constructor.- Parameters:
method- The Java method this context represents. Must not benull .context- The owningRestContext. Must not benull .resourceSupplier- Supplier that returns the invocation target for this operation.- Throws:
jakarta.servlet.ServletException- If context could not be created.
-
-
Method Details
-
getContext
Returns theRestContextthat owns this operation context.For operations declared directly on the host resource class, returns the host context. For operations registered through a
@Rest(mixins=...)mixin, returns the per-mixin sub-context (parent-linked to the host's context viaRestContext.getParentContext()). Callers can use this to identify whether the operation was contributed by a mixin (viaRestContext.isMixinContext()).- Returns:
- The owning
RestContextfor this operation. - Since:
- 10.0.0
-
getRestOpAnnotations
Returns allRestOp-group annotations on this operation method, in child-to-parent order.- Returns:
- An unmodifiable list, never
null.
-
isInherited
Returnstrueif context-level values for the given property should be merged.- Parameters:
property- The annotation attribute name (e.g."allowedParserOptions","defaultCharset","maxInput").- Returns:
trueifnoInheritdoes not contain this property.
-
getAllowedParserOptions
Returns the parser session-option keys allowed for this operation.- Returns:
- An unmodifiable case-insensitive sorted set, never
null.
-
getAllowedSerializerOptions
Returns the serializer session-option keys allowed for this operation.- Returns:
- An unmodifiable case-insensitive sorted set, never
null.
-
compareTo
- Specified by:
compareToin interfaceComparable<RestOpContext>
-
copy
Description copied from class:ContextCreates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
-
createRequest
Creates aRestRequestobject based on the specified incomingHttpServletRequestobject.- Parameters:
session- The current REST call.- Returns:
- The wrapped request object.
- Throws:
Exception- If any errors occur trying to interpret the request.
-
createResponse
Creates aRestResponseobject based on the specified incomingHttpServletResponseobject 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.
-
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.
-
equals
-
getMarshallingContext
Returns the marshalling context associated with this context.- Returns:
- The marshalling context associated with this context.
-
getDefaultCharset
Returns the default charset.- Returns:
- The default charset. Never
null .
-
getDefaultRequestAttributes
Returns the default request attributes.- Returns:
- The default request attributes. Never
null .
-
getDefaultRequestFormData
Returns the default form data parameters.- Returns:
- The default form data parameters. Never
null .
-
getDefaultRequestHeaders
Returns the default request headers.- Returns:
- The default request headers. Never
null .
-
getDefaultRequestQueryData
Returns the default request query parameters.- Returns:
- The default request query parameters. Never
null .
-
getDefaultResponseHeaders
Returns the default response headers.- Returns:
- The default response headers. Never
null .
-
getEncoders
Returns the compression encoders to use for this method.- Returns:
- The compression encoders to use for this method.
-
getHttpMethod
Returns the HTTP method name (e.g."GET" ).- Returns:
- The HTTP method name.
-
isRead
Returns whether this operation is declaredread=true.A read operation may be reached by overriding a safe request (
GET ,HEAD ,OPTIONS ,TRACE ) to its custom method.- Returns:
true if this operation is declared a read.- Throws:
InternalServerError- Ifread= is declared on an inheritedtrue @RestOp that names no method.- Since:
- 10.0.0
-
getJavaMethod
Returns the underlying Java method that this context belongs to.- Returns:
- The underlying Java method that this context belongs to.
-
getJsonSchemaGenerator
Returns the JSON-Schema generator applicable to this Java method.- Returns:
- The JSON-Schema generator applicable to this Java method.
-
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.
-
isProblemDetails
Returns whether this operation emits RFC 7807application/problem+jsonresponses.Tri-state inheritance semantics: an explicit
"true"or"false"on the operation annotation wins; otherwise the value is inherited fromRestContext.isProblemDetails()(resource-level@Rest(problemDetails)).See Also:
- Returns:
true if RFC 7807 problem-details responses are enabled on this operation.
-
isDebugMarshalling
Returns whether REST-driven serializer/parser debug behavior is enabled for this operation.Resolved via the tri-state
@RestOp-groupdebugMarshallingattribute ("true"wins,"false"opts out,""inherits the resource-level@Rest(debugMarshalling)), independent of the JUL logger level.See Also:
- Returns:
true if REST-driven marshalling debug is enabled for this operation.
-
isVirtualThreadsEnabled
Returns whether this operation opts into per-request virtual-thread dispatch on Java 21+.The op-level
@RestOp(virtualThreads)value (when non-blank) wins; otherwise the value is inherited fromRestContext.isVirtualThreadsEnabled()(resource-level@Rest(virtualThreads)). Honored only when the resource-levelRestContext.getVirtualThreadExecutor()is non-null(Java 21+).- Returns:
true if virtual-thread dispatch is configured on this operation.
-
isObservabilityEnabled
Returns whether the observability block is enabled for this operation.Returns
falsewhen the effective resolved attribute is"false"(explicit opt-out). Returnstruein all other cases ("true"strict opt-in or empty/null default).Note: the default behavior (empty/null attribute) still runs the observability block, but silently falls back to
NoOpMetricsRecorderwhen no backend is wired. Only"false"completely short-circuits the block.- Returns:
false when this operation has explicitly opted out of observability.- See Also:
-
getMetricName
Returns the per-op metric name override from@RestOp(metricName).- Returns:
- The metric name override, or an empty string when not set.
- See Also:
-
getMetricTags
Returns the per-op additional metric tags from@RestOp(metricTags).- Returns:
- The tags string (comma-separated
key=valuepairs), or empty string when not set. - See Also:
-
getAsyncTimeoutMillis
Returns the configured async-response timeout (milliseconds) for this operation, or-1when no value was supplied at the op or resource level — in which case the default 30-second fallback applies inAsyncResponseProcessor.- Returns:
- The async timeout in milliseconds, or
-1when unset.
-
getAsyncCompletionExecutor
Returns the effectiveExecutorfor routingCompletableFuturecompletion callbacks on this operation, ornullwhen neither the op nor the resource configures an executor (natural completion thread).- Returns:
- The executor, or
nullif no async-completion executor is configured. - Since:
- 10.0.0
-
getParsers
Returns the parsers to use for this method.- Returns:
- The parsers to use for this method.
-
getPartParser
Bean property getter:partParser .- Returns:
- The value of the
partParser property on this bean, ornull if it is not set.
-
getPartSerializer
Bean property getter:partSerializer .- Returns:
- The value of the
partSerializer property on this bean, ornull if it is not set.
-
getPathPattern
Returns the path pattern for this method.- Returns:
- The path pattern.
-
getPathMatchers
Returns the URL path matchers for this operation.- Returns:
- The URL path matchers for this operation.
Nevernull .
The returned list is an immutable, cached view.
-
getOptionalMatchers
Returns the optional matchers for this operation.- Returns:
- The optional matchers for this operation.
Nevernull .
The returned list is an immutable, cached view.
-
getRequiredMatchers
Returns the required matchers for this operation.- Returns:
- The required matchers for this operation.
Nevernull .
The returned list is an immutable, cached view.
-
getLogger
Returns the per-operation logger used for debug capture.A hierarchical child of the host resource's resolved logger (
<hostLoggerName>.<methodName>) — see theloggermemoizer for how the host's bean-store-overriddenRichLogger(if any) is honored.- Returns:
- The per-operation logger.
Nevernull .
-
getResponseBeanMeta
Returns metadata about the specified response object if it's annotated with@Response.- Parameters:
o- The response POJO. Can benull (returnsnull ).- 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. Can benull (returnsnull ).- Returns:
- Metadata about the specified response object, or
null if it's not annotated with@Header.
-
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.
-
getSerializers
Returns the serializers to use for this method.- Returns:
- The serializers to use for this method.
-
getSupportedAcceptTypes
Returns a list of supported accept types.- Returns:
- An unmodifiable list.
-
getSupportedContentTypes
Returns the list of supported content types.- Returns:
- An unmodifiable list.
-
hashCode
-
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.
-
properties
Description copied from class:ContextReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classContext- Returns:
- The properties on this bean as a map for debugging.
-