TemplateAttributeDefinition
Rod Widdowson
rdw at steadingsoftware.com
Thu Apr 18 07:13:06 EDT 2013
[Apologies if this is a duplicate]
This is a general FYI, but may be of particular interest to those who need
to incorporate Velocity into other parts of the system.
As part of the parsing work for the TemplateAttributeDefinition, I made some
structural changes to the way in which the definition is built and works.
Two were to do with aligning the definition more with V2, either in
behaviour or the schema. These changes actually made both the definition
and parsing code much simpler, significantly so in one case. I can go into
details if people wish, but it feels pretty non controversial.
The other change was also aimed at making the definition and parsing
simpler; whilst it also aligns the definition more with the schema it may
requires a wider visibility.
If you don't care about velocity engines now would be a good time to stop
reading..
Originally the TemplateAttributeDefinition bean could have a
net.shibboleth.utilities.java.support.velocity.Template injected. This
object is a encapsulation of Velocity stuff (as opposed to the V2 equivalent
which appears to have been more to do with working round bugs in early
velocity implementations). It certainly hides a lot of details. These
objects are created by a static method which takes the text, the
VelocityEngine, and an optional character set encoding.
I pushed the creation of this object from parsing into the initialization
code for the definition and instead the text and the VelocityEngine are
injected. This aligns better with the schema (where the VelocityEngine
reference is already present as a "fixed" attribute) and in general makes
for cleaner code. It does however come at the cost that there is no way of
specifying the character encoding for the template. Actually as I type this
I wonder whether the XML processing will not have already done that; either
way this behaviour is consistent with V2.
This change means that other subsystems can assume that an injectable
VelocityEngine will be available and can be used to summon up
net.shibboleth.utilities.java.support.velocity.Template instances as
appropriate.
Rod
More information about the dev
mailing list