We need to do some pre-processing of the DTOs before the handler. In our case, this needs to happen after deserialization and validation. As far as I was able to determine, there is no extension point at this stage. Filter
s and HandlerInterceptor
s run before deserialization and RequestBodyAdvice
s and @InitBinder
s run before validation.
The way we achieved this in our application was by providing our own InvocableHandlerMethod
and overriding doInvoke
to run our middleware layer before proceeding with the invocation.
Is this the suggested way of achieving this? Would it make sense to consider adding an extension point for this use case?
Comment From: snicoll
Is this the suggested way of achieving this?
This is the only hook point I've found. We don't have any extension point that I am aware that lets you handle and potentially transforms a value object after it has been validated. Doing this for the web layer and not for other part of the framework feels inconsistent. I also wonder about the use case that is quite specific. If you want this to be transparent to the controller, this feels like the most powerful way of doing things at the moment.
Flagging for team attention to see if someone else on the team feels differently.
Comment From: rstoyanchev
Indeed no such specific interception point. An AOP interceptor is another alternative and a general mechanism providing access to the actual arguments passed in and returned.
Comment From: snicoll
thanks Rossen. Given how specific this is, we believe this is best handled via AOP or the extension point that you're already using.