I have often thought that the inte­gra­tion with Veloc­ity cur­rently pro­vided by Spring, whilst ade­quate, could be sig­nif­i­cantly improved so, recently, I spent a fun week­end cre­at­ing a cus­tom inte­gra­tion wrap­per, which I am call­ing spring-velocity for using Veloc­ity with Spring (sur­pris­ingly enough).

I had 4 main aims in this exercise:

  1. Sup­port the changes to Veloc­ity & Veloc­ity Tools (esp. tools) since 1.5 and 2.0 (new tool­box for­mat, no dep­re­ca­tion mes­sages etc)
  2. Pro­vide a stan­dard, Spring-style means to utilise Spring con­text sup­port to aug­ment veloc­ity tools infra­struc­ture (@ViewHelper anno­ta­tion as a com­po­nent stereo­type which can have a Spring @Scope spec­i­fied auto­mat­i­cally added to Veloc­ity context)
  3. Most impor­tantly: work nicely with ContentNegotiatingViewResolver so that a sin­gle velocity-based Spring View can be used to gen­er­ate mul­ti­ple text-based for­mats sim­ply by drop­ping in addi­tional tem­plates (+ spec­i­fy­ing in ContentNegotiatingViewResolver’s medi­aTypes map)
  4. Get all of the above to work trans­par­ently, out-of-the-box via anno­ta­tions, and cor­rectly deter­mine what sort of “con­text” the app is run­ning in (e.g. web app [access to servlet con­text] or plain token replacer with/without toolbox)

The source code and bina­ries can be down­loaded from my maven repos­i­tory.

It is cur­rently released under the GPL3 licence. How­ever, if any­one in the “real world” finds it use­ful and this licence becomes too restric­tive, I may switch to an Apache licence (in line with both Spring and Veloc­ity) in a future release, if there are any. Sim­i­larly, if it seems to other peo­ple that this is some­thing that may be gen­er­ally use­ful, I would prob­a­bly also move the source to github.

Any thoughts or feed­back would be most wel­come … and, of course, feel free to use.