|
From: Kariem H. <kar...@gm...> - 2014-06-23 19:51:44
|
Hi,
I have some problems with configuring whether I want to validate the
payload provided by the client using the bean validation 1.1 provider.
According to the documentation [1], I only have to declare my own provider
and override whatever I want. I decided to just override
"isMethodValidatable":
---- start
public class AnnotatedMethodValidator extends GeneralValidatorImpl {
...
@Override
public boolean isMethodValidatable(Method m) {
return m.getAnnotation(Valid.class) != null && super.isMethodValidatable(m);
}
}
---- end
As you can see, I only want to perform validation, if the method is annoted
with @javax.validation.Valid.
This class is initialized from a custom registered provider (implementing
ContextResolver<GeneralValidator>). The only problem I have now is that
instead of using my custom implementation, the default implementation
(....validation.ValidatorContextResolver) is still used.
When debugging the code, I saw that
ResteasyProviderFactory.getContextResolver [2] just loads the first context
resolver for the type, which happens to be the default implementation
instead of mine. Is there a non-dirty method I have overseen to put mine in
the front or override the default implementation?
I have tried using META-INF/services//javax.ws.rs.Providers and registering
the provider in my Guice module.
Thank you very much for your help.
Bye,
Kariem
[1]
https://docs.jboss.org/resteasy/docs/3.0.7.Final/userguide/html/Validation.html#d4e2476
[2]
https://github.com/resteasy/Resteasy/blob/3.0.8.Final/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/ResteasyProviderFactory.java#L2143
|