Monday, February 16, 2009

Spring Modules Valang

I've been working on adding enhancements to Spring Modules Valang. I've added a number of new features so far and I have two versions uploaded to the Spring by Example Maven Repository (org.springbyexample.validation:sbe-validation). I have it under a different group id and artifact name so there aren't' any collisions in the future with Spring Modules releases.

I'm also working on documentation, but that's going to take a little longer to finish.

Version 0.91

  • Bytecode generation added to DefaultVisitor as a replacement for reflection accessing simple properties (BeanPropertyFunction) for a significant performance improvement.
  • Basic enum comparison support. In the expression below the personType is an enum and the value STUDENT will be convereted to an enum for comparison. The value must match an enum value on the type being compared or an exception will be thrown.

    personType EQUALS ['STUDENT']
    For better performance the full class name can be specified so the enum can be retrieved during parsing. The first example is for standard enum and the second one is for an inner enum class .

    personType EQUALS ['org.springmodules.validation.example.PersonType.STUDENT']

    personType EQUALS ['org.springmodules.validation.example.Person$PersonType.STUDENT']
  • Where clause support. In the expression below, the part of the expression price will only be evaluated if the personType is 'STUDENT'. Otherwise the validation will be skipped.

    price < 100 WHERE personType EQUALS ['STUDENT']
  • Improved performance of 'IN'/'NOT IN' if comparing a value to a java.util.Set it will use Set.contains(value). Static lists of Strings (ex: 'A', 'B', 'C') are now stored in a Set instead of an ArrayList.
  • Functions can be configured in Spring, but need to have their scope set as prototype and use a FunctionWrapper that is also a prototype bean with set on it.
  • Removed servlet dependency from Valang project except for the custom JSP tag ValangValidateTag needing it, but running Valang no longer requires it. This involved removing ServletContextAware from it's custom dependency injection. If someone was using this in a custom function, the function can now be configured directly in Spring and Spring can inject any "aware" values.

Version 0.92

  • Removed custom dependency injection since functions can be configured in Spring.
  • Added auto-discovery of FunctionWrapper beans from the Spring context to go with existing auto-discovery of FunctionDefinition beans.

3 comments:

Toolman said...

You could consider contributing to:

http://groups.google.com/group/spring-modules-fork

dinh said...

would you submit valang to spring extensions since modules is now dead (i think)? i really like valang and found it to be very useful.

David Winterfeldt said...

It's all under the Apache 2.0 License and I didn't change that. So anyone can take what I've done and work on it more. I don't have time to manage it as a separate Spring Extensions project right now, and I'm not sure if I'll work on it more in the future.