Hi Brice
On 30/10/12 10:01, Brice Dutheil wrote:
Hi just a quick question, I'm wondering where would be the best place
RequestHandler, Interceptor, Invoker, ... to validate the unmarhsalled form
of the parameters.
I have in mind something like applying custom JSR 303 validation on the
passed parameters. I could retrieve JSR 303 annotations on the Method
parameter, and process the unmarshalled args.
- From what I read here and there, I don't think RequestHandler is the
right place, it doesn't seems like the parameters / arguments are
unmarshalled yet. In this class exploring message didn't reveal
interesting stuff for what I'd like to achieve :
message.getExchange().get(OperationResourceInfo.class).getParameters()
message.get(URITemplate.TEMPLATE_PARAMETERS) // I'm not sure about this
one, I believe it only represents the string value of the parameters
- At the moment of this writing I think an 'In' interceptor looked the
best place to achieve the validation; maybe in the PRE_INVOKE phase and
have a look at message.getContent(List.class), are we sure this list
contains only the passed parameters ?
Also I know there might be some other form of parameter injection, like
injecting in a setter like 'setSomePathParam', it would be interesting to
handle these cases too.
I think either RequestHandler (ContainerRequestFilter in 2.7.0) or
custom invoker will be the best place to support it at the moment.
In the custom invoker you have the objects available that will be passed
to the actual resource method,
In request handler/filter, these method parameters are available at
message.getContent(List.class);
Those parameters that can be injected as properties are a bit trickier
to 'intercept'. I guess, at the moment, the simplest is to inject
"@Context UriInfo" into custom RequestHandler and use it to get to the
list of all path, matrix, header, query and cookie parameters,
Let me know please if some more info is needed
Thanks, Sergey
Thx in advance for your input.
Cheers,
-- Brice
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com