The Java Enterprise Edition (Java EE) 6 specification includes the Bean Validation API that is a standard mechanism for validating JavaBeans in all layers of an application.
Before the Bean Validation specification, JavaBeans were validated in each layer. To prevent the reimplementation of validations at each layer, developers bundled validations directly into their classes or copied validation code, which was often cluttered. Having one implementation that is common to all layers of the application simplifies the developers work and saves time.
Bean validation is common to all layers of an application. Specifically, web applications have the following layers:This layer represents how the user interacts with the application and might be built on a thin client or rich client.
This layer coordinates the application, processes commands, makes logical decisions and evaluations and performs calculations. It also moves and processes data between the two other layers. The EJB contains business logic in WebSphere® Application Server.
Your data is stored and retrieved from a database or file system at this layer. The business layer processes the data and sends it in usable form to the user interface. WebSphere Application Server supports several databases and methods of retrieving data. This layer also defines persistence.
For WebSphere Application Server, these layers are built and administered with several components in the product that are necessary for developing and deploying applications.
Enterprise application development involves multiple teams developing numerous applications and modules that are assembled and deployed in an application server environment. The product ensures that each application and module data is validated independently. Validation is performed using only the constraints defined for the application and module.
Bean validation in RAR modules.
The product validates resource adapter archive (RAR) Enterprise JavaBeans (EJB) constraints in compliance with the JCA version 1.6 specification. Resource adapters can use the built-in bean validation constraint annotations or provide a bean validation XML configuration to specify the validation requirements of resource adapter configuration properties to the application server.
A new feature defined by the JPA 2.0 specification is the ability to seamlessly integrate with the Bean Validation API. With minimal effort, JPA 2.0 can be coupled with the validation provider for runtime data validation. By combining these two technologies, you get a standardized persistence solution with the added ability to perform standardized data validation.
JSF previously was able do bean validation, but now it provides built-in support of the Bean Validation specification.
The web container provides an instance of ValidatorFactory and makes it available to JSF implementations by storing it in a servlet context attribute named javax.faces.validator.beanValidator.ValidatorFactory.
In this information ...Related tasks
| IBM Redbooks, demos, education, and more(Index) |