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
ParameterRegistryclass.
If the parameter cannot be found in the request, null is returned.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(Parameter parameter, Annotation methodAnnotation, HasMessage value) Determines if this resolver is applicable to a given method parameter.booleanmayApply(Executable method, Class<?> targetClass) Returnstrueif this resolver might apply to the given method.resolve(Parameter p, Annotation methodAnnotation) Resolves the parameter value from aWebRequestContextusing the metadata provided by a parameter annotation that is meta-annotated withWebParam.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ParameterResolver
determinesSpecificity, test
-
Constructor Details
-
WebParamParameterResolver
public WebParamParameterResolver()
-
-
Method Details
-
resolve
Resolves the parameter value from aWebRequestContextusing 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:
resolvein 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
trueif:- 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:
matchesin interfaceParameterResolver<HasMessage>- Parameters:
parameter- the method parametermethodAnnotation- the enclosing method annotation (not used here)value- the message passed to the handler- Returns:
trueif the parameter is eligible for resolution
- The incoming message is a
-
mayApply
Description copied from interface:ParameterResolverReturnstrueif this resolver might apply to the given method. Implementations should perform only inexpensive checks and never throw.- Specified by:
mayApplyin interfaceParameterResolver<HasMessage>- Parameters:
method- the handler method or constructortargetClass- the declaring or target class- Returns:
trueif this resolver could apply,falseotherwise
-