I've developed a little servlet (not based on VelocityServlet, 600+
lines of dense code) that uses the new Velocity non-signleton model to
do the following:

- handles all .vm pages within an application (it is very application
centric)
- loads beans of application, session, page and request scope into the
velocity context reference 'beans' and initialises them if there is a
method 'public void init(Properties)' by passing the
application.properties to it
- encodes the URI and stores into a reference 'euri'
- if any of the properties files (beans.properties,
application.properties) changed during the execution of the servlet,
it'll reload the properties/beans and initalise the beans again (this
can be configured to happen at certain interval or not at all) - it lets
you dynamically change your app without the need to do anything special
but deploy the files
- all output during template merging goes into an ByteArrayOutputStream,
so none of it is committed before error handling
- error handling is two fold: via Velocity pages (if configured/present)
or as a last resort a built in simple page (error page contains the
description of the error and problem reporting e-mail, Velocity
reference 'hostmaster')

This servlet isn't going to win any coding awards, since it's written in
typical 'Bojan' style, dense and without too many comments. It is meant
to be a page pushing tool, nothing more. But it could help many people
with simple projects, just to get them off the ground quickly and more
importantly in Velocity.

Basically, each application would contain the PumpServlet, (always the
same) web.xml and application.properties, beans.properties and
velocity.properties files. The rest is 'automagically' done by the
servlet itself. The Tomcat/mod_jk configuration is also extremely
primitive.

I license all my code GPL, so anyone is free to use this code in any way
they like, if nothing else to show others as an example of what not to
do.

So, if you guys think there could be Velocity newbies with an interest
in this, let me know and I'll package this thing up with a nice HowTo.

What do I get out of this? Free code inspection, bug fixing, performance
improvements, etc. After all, we all have our own, selfish agenda ;-)

Bojan

Reply via email to