Friday, 9 January 2009

Migrating to the Bean Validation Framework

Yesterday, I had a good look around to see if the conflict between Spring and Commons Validator had been resolved from either side. I didn't find any evidence, so have attempted to contact Colin Yates who announced the last SM 0.9 release.

To give myself a solid base, I've upgraded my old versions of SM and Commons Validator to their current releases (0.9 and 1.3.1). It was nice to see that the Commons team do thank people in person for their contributions, in my case a fix to the DTD for version 1.2.0.

These upgrades needed a little API tweaking. The package org.springmodules.commons.validator was renamed to org.springmodules.validation.commons, so my derived classes and XML needed a quick search and replace, but that was about it.

Sure enough, when I deployed my build to Tomcat, the old problem exists, so it's time to crack on with migration.

My strategy is to use the power of Spring's dependency injection. I have a number of Spring Validators, including our own custom validators for multi-page forms. For now, though, I'll start with the easy test, of migrating the DefaultBeanValidator to the Bean Validation Framework. In each of these cases, I'm going to leave the old code and configuration intact, and just inject the new validators in place of the old. This way, backing out will be as simple as reverting just my bean definition XML.  And, naturally, the one other thing.  The difference between using [] for access to maps and ()!

No comments:

Post a Comment