Package io.fluxcapacitor.javaclient.web
Class WebHandlerMatcher
java.lang.Object
io.fluxcapacitor.javaclient.web.WebHandlerMatcher
- All Implemented Interfaces:
HandlerMatcher<Object,
DeserializingMessage>
public class WebHandlerMatcher
extends Object
implements HandlerMatcher<Object,DeserializingMessage>
Specialized
HandlerMatcher
that routes DeserializingMessage
s of type MessageType.WEBREQUEST
to matching handler methods based on annotated URI patterns, HTTP methods, and optional origins.
This matcher is created internally by the HandlerFactory
when registering a handler class that contains
methods annotated for web request handling (e.g., @HandleWeb
).
Routing Logic
The matcher builds aRouter
that maps:
- HTTP method (e.g., GET, POST)
- Normalized path (optionally prefixed by
@Path
at class or package level) - Optional request origin (e.g., scheme and host) when specified in the handler method
DefaultWebRequestContext
is used to extract the URI path, method, and origin
from the incoming request metadata.
WebPattern Matching
Each handler method may be associated with one or moreWebPattern
s, derived from WebParameters
annotations. These patterns define the matchable paths and methods.
Support for @Path Annotations
This matcher also respects@Path
annotations on the method, declaring class, or package level,
combining those with the WebPattern#getPath()
when routing requests.
Fallback to ANY Method
If no handler matches the exact request method, but any handlers exist that declareHttpRequestMethod.ANY
,
these are checked as a fallback.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
WebHandlerMatcher
(Object handler, List<HandlerInspector.MethodHandlerMatcher<DeserializingMessage>> methodHandlerMatchers) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(DeserializingMessage message) Returns whether the given message can be handled by a handler instance of typeT
.protected static WebHandlerMatcher
create
(Object handler, Class<?> type, List<ParameterResolver<? super DeserializingMessage>> parameterResolvers, HandlerConfiguration<DeserializingMessage> config) static WebHandlerMatcher
create
(Object handler, List<ParameterResolver<? super DeserializingMessage>> parameterResolvers, HandlerConfiguration<DeserializingMessage> config) getInvoker
(Object target, DeserializingMessage message) Attempts to resolve aHandlerInvoker
for the given target instance and message.matchingMethods
(DeserializingMessage message) Returns a stream of methods from the target class that match the given message.methodMatcher
(DeserializingMessage message) 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.HandlerMatcher
or
-
Constructor Details
-
WebHandlerMatcher
protected WebHandlerMatcher(Object handler, List<HandlerInspector.MethodHandlerMatcher<DeserializingMessage>> methodHandlerMatchers)
-
-
Method Details
-
create
public static WebHandlerMatcher create(Object handler, List<ParameterResolver<? super DeserializingMessage>> parameterResolvers, HandlerConfiguration<DeserializingMessage> config) -
create
protected static WebHandlerMatcher create(Object handler, Class<?> type, List<ParameterResolver<? super DeserializingMessage>> parameterResolvers, HandlerConfiguration<DeserializingMessage> config) -
canHandle
Description copied from interface:HandlerMatcher
Returns whether the given message can be handled by a handler instance of typeT
. This is a lightweight check and may be used for fast filtering or diagnostics.- Specified by:
canHandle
in interfaceHandlerMatcher<Object,
DeserializingMessage> - Parameters:
message
- the message to check- Returns:
true
if the matcher may be able to produce an invoker for the given message
-
matchingMethods
Description copied from interface:HandlerMatcher
Returns a stream of methods from the target class that match the given message. Typically used for diagnostics or documentation tools.- Specified by:
matchingMethods
in interfaceHandlerMatcher<Object,
DeserializingMessage> - Parameters:
message
- the message to match against- Returns:
- a stream of matching
Executable
handler methods
-
getInvoker
Description copied from interface:HandlerMatcher
Attempts to resolve aHandlerInvoker
for the given target instance and message.- Specified by:
getInvoker
in interfaceHandlerMatcher<Object,
DeserializingMessage> - Parameters:
target
- the handler objectmessage
- the message to be handled- Returns:
- an optional invoker if the message is supported by the target; empty otherwise
-
methodMatcher
protected Optional<HandlerInspector.MethodHandlerMatcher<DeserializingMessage>> methodMatcher(DeserializingMessage message)
-