Bean Validation ComponentAvailable as of Camel 2.3 The Validation component performs bean validation of the message body using the Java Bean Validation API (JSR 303). Camel uses the reference implementation, which is Hibernate Validator. Maven users will need to add the following dependency to their URI formator Where label is an arbitrary text value describing the endpoint. URI Options
ServiceMix4/OSGi Deployment.The bean-validator when deployed in an OSGi environment requires a little help to accommodate the resource loading specified in JSR303, this was fixed in Servicemix-Specs 1.6-SNAPSHOT. The other way to load Hibernate Validator in the OSGi environment is to use dedicated Using HibernateValidationProviderResolver ExampleAssumed we have a java bean with the following annotations Car.java and an interface definition for our custom validation group OptionalChecks.java with the following Camel route, only the @NotNull constraints on the attributes manufacturer and licensePlate will be validated (Camel uses the default group If you want to check the constraints from the group If you want to check the constraints from both groups, you have to define a new interface first AllChecks.java and then your route definition should looks like this And if you have to provide your own message interpolator, traversable resolver and constraint validator factory, you have to write a route like this It's also possible to describe your constraints as XML and not as Java annotations. In this case, you have to provide the file validation.xml and the constraints-car.xml See Also |