lodi 0.1.0 released

Along with SQLsheet, I'm open sourcing another library that I've written: lodi (Local Dispatch).

A lot of my work lately has relied on generating XML using templates (I'm using Velocity). The XML is mostly used to either drive an ETL process, specify some XHTML to get rendered, or to configure some internal subsystem.

It gets complicated, though:

  • Sometimes that XML gets consumed outside the VM via HTTP, and sometimes it gets consumed inside the VM.
  • In either case, I need to be able to embed template parameters in a URL (i.e., query stirng).
  • I want a uniform method for addressing the templates (inside or outside the VM)
  • I want a uniform method for processing and organizing the templates in the webapp
  • Some of the templates I want locked down from the outside - I don't want them served out over HTTP
  • ...except that sometimes I do. For debugging, it turns out to be really handy to be able to peek at template instantiations in my browser.

My solution was to create a backdoor URL dispatcher for internal clients. So, from outside I can access a template as

http://localhost/foo/bar/baz.vm?name=roger

whereas from inside the VM (and only inside the VM) I can access it as

myapp:/foo/bar/baz.vm?name=roger

One nice thing about this is that the myapp URL will bypass the container security. This means that I can be free of having to authenticate when calling internally without having to do unnatural things to my web.xml security configuration to lock it down from outside.

Another nice benefit is that the servlet request gets processed in the caller's thread. This lets me propagate any Exceptions encountered while directly back to the caller, which makes debugging and error handling a lot simpler when there are problems in a template.

(more...)

Comments are closed.