On May 14, 2011 wrote: A Different Way to Integrate Velocity with Spring
I have often thought that the integration with Velocity currently provided by Spring, whilst adequate, could be significantly improved so, recently, I spent a fun weekend creating a custom integration wrapper, which I am calling spring-velocity for using Velocity with Spring (surprisingly enough).
I had 4 main aims in this exercise:
- Support the changes to Velocity & Velocity Tools (esp. tools) since 1.5 and 2.0 (new toolbox format, no deprecation messages etc)
- Provide a standard, Spring-style means to utilise Spring context support to augment velocity tools infrastructure (
@ViewHelperannotation as a component stereotype which can have a Spring@Scopespecified automatically added to Velocity context) - Most importantly: work nicely with
ContentNegotiatingViewResolverso that a single velocity-based SpringViewcan be used to generate multiple text-based formats simply by dropping in additional templates (+ specifying in ContentNegotiatingViewResolver’s mediaTypes map) - Get all of the above to work transparently, out-of-the-box via annotations, and correctly determine what sort of “context” the app is running in (e.g. web app [access to servlet context] or plain token replacer with/without toolbox)
The source code and binaries can be downloaded from my maven repository.
It is currently released under the GPL3 licence. However, if anyone in the “real world” finds it useful and this licence becomes too restrictive, I may switch to an Apache licence (in line with both Spring and Velocity) in a future release, if there are any. Similarly, if it seems to other people that this is something that may be generally useful, I would probably also move the source to github.
Any thoughts or feedback would be most welcome … and, of course, feel free to use.