Bindings, Platforms, and Innovation
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
Tracking change and innovation in the enterprise software development community
Posted by Charles Humble on Apr 09, 2008 02:33 PM
In most enterprise applications data constraints will exist in two places:Led by Hibernate Validator lead developer Emmanuel Bernard, JSR-303 aims to standardize the constraints metadata model for Java EE 6. An early draft of the specification has been released and the expert group are keen to solicit feedback. As part of this a forum has been set up, and Bernard has begun to publish a series of articles (part 1, part 2) on the Hibernate blog describing how the API works.
Unsurprisingly given its parentage, JSR-303 is heavily influenced by the JBoss' Hibernate Validations although a number of the other validator frameworks (Xwork and the Apache Commons Validator for instance) have also influenced the specification. It uses annotations for the majority of cases and provides standard APIs for runtime validation and to query the metadata. Each constraint annotation must define a message of type String which is used to create an error message. Error messages support internationalisation. Constraints may be declared on an object's fields, getters, class, superclass and interfaces and validating an object will validate all of its constraints. For example the following code creates a String called street1 which has a maximum length of fifty characters and is mandatory:
@NotEmpty @Max(50)
private String street1;
The framework is designed to be extensible so that an application can easily define its own additional set of constraints. From the first blog entry:
"A constraint is comprised of:
• an annotation
• a constraint validation implementation
While the annotation expresses the constraint on the domain model, the validation implementation decides whether a given value passes the constraint or not."
As well as supporting instance validation the specification supports validation of an object graph, so for example if a bean ClientDetails contains an Address bean with one or more @Valid annotations the validator will validate the contents of the Address bean when the ClientDetails bean is validated.
One significant difference between the spec and the Hibernate Validator is the concept of groups, which provide a means for creating subsets of validations. Groups have an associated sequence (set via an @GroupSequence annotation) so that a developer can force one set of constraints to pass without error before the next set executes. Groups also allow a partial validation of the JavaBean. The draft specification suggests two scenarios where this might be useful:
"• the second group depends on a stable state to run properlyA number of different pieces of technology in the Java EE 6 platform should be able to take advantage of JSR-303. For example DDL updates when generated via an ORM tool, entity validation on insertion/update by the Java Persistence API, the new WebBeans API, and JavaServerFaces components all look to be obvious candidates.
• the second group is a heavy consumer of time, CPU or memory and should be avoided if possible"
Download the Free Adobe® Flex® Builder 3 Trial
Adobe® Rich Internet Application Project Portal
Effective Management of Static Analysis Vulnerabilities and Defects
SOAsocial.com - See what the SOA community is Talking About
The Agile Business Analyst: Skills and Techniques needed for Agile
I have just written a blog entry on groups here.
Emmanuel Bernard
It would be highly interesting if there was an implementation that could automatically map from JSR-303 metadata to other validation schemes, e.g. XML Forms types, client side JavaScript etc. Anything like that?
The spec is written in such a way and exposes metadata APIs so that your client side JS library, your XML Forms type consumer and so on can go and extract the info from the domain model. The next step is to talk to the JPA 2 and JSF 2 expert groups to match this integration in the respective specifications. Specific converters are not part of the spec because as you pointed out there are gazillions of validation schemes :)
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.
This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.
This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.
This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.
After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.
IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.
Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.
3 comments
Watch Thread Reply