Validation of objects and object graphs is a cross cutting concern and used within several architectural layers, and therefore should be separated from the business logic. The JSR349 specification describes a mechanism using annotations. At the time of writing, the latest reference implementation of the JSR 349 spec is the Hibernate Validator version 5.4.2.Final. The metadata API can be configured by XML, and the constraints can be extended by creating custom validation annotations.
Hibernate Validator requires special handling on OSGi, a proof of concept is located under net.betzel.javax.osgi.beanvalidation. Build the project and drop the produced Karaf archive file into the Karaf deploy folder to see the mechanism in action.
Readables:
http://beanvalidation.org
http://www.baeldung.com/javax-validation
No comments:
Post a Comment