Class WebParamParameterResolver
- All Implemented Interfaces:
ParameterResolver<HasMessage>
WebParam
.
This resolver targets parameters in methods that handle MessageType.WEBREQUEST
messages.
It looks for parameters annotated with a concrete annotation that is itself meta-annotated with @WebParam
,
such as @PathParam
, @QueryParam
, or other custom parameter annotations used in web APIs.
The resolver extracts the desired parameter value from the associated WebRequestContext
using the rules and source defined by the meta-annotation (e.g. from the path, query string, or headers).
To determine the parameter name to resolve, the following resolution strategy is used:
- If
@WebParam.value()
is set, it is used directly. - Otherwise, if Java parameter names are available (compiled with
-parameters
) or if the method was compiled from Kotlin source, the parameter name is used. - If neither is available, the name is resolved from a generated
ParameterRegistry
class.
If the parameter cannot be found in the request, null
is returned.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
matches
(Parameter parameter, Annotation methodAnnotation, HasMessage value) Determines if this resolver is applicable to a given method parameter.resolve
(Parameter p, Annotation methodAnnotation) Resolves the parameter value from aWebRequestContext
using the metadata provided by a parameter annotation that is meta-annotated withWebParam
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.handling.ParameterResolver
determinesSpecificity, filterMessage
-
Constructor Details
-
WebParamParameterResolver
public WebParamParameterResolver()
-
-
Method Details
-
resolve
Resolves the parameter value from aWebRequestContext
using the metadata provided by a parameter annotation that is meta-annotated withWebParam
.The parameter name is determined based on the annotation value, Java reflection, or a generated
ParameterRegistry
, and the value is extracted from the request using the declaredWebParameterSource
(e.g. QUERY, PATH, HEADER).- Specified by:
resolve
in interfaceParameterResolver<HasMessage>
- Parameters:
p
- the method parameter to resolvemethodAnnotation
- the handler method annotation (not used here)- Returns:
- a function that resolves the argument from the incoming
HasMessage
-
matches
Determines if this resolver is applicable to a given method parameter.This returns
true
if:- The incoming message is a
DeserializingMessage
- The message type is
MessageType.WEBREQUEST
- The parameter is annotated with an annotation that is meta-annotated with
WebParam
- Specified by:
matches
in interfaceParameterResolver<HasMessage>
- Parameters:
parameter
- the method parametermethodAnnotation
- the enclosing method annotation (not used here)value
- the message passed to the handler- Returns:
true
if the parameter is eligible for resolution
- The incoming message is a
-