1

I have a Java EE application that takes XML and applies XSLT to it to generate HTML. This process happens in a custom servlet. This is typically used to build portions of the content on certain web pages. Since the actual data is already stored as XML it made sense to just do transformations in a servlet.

This was actually modeled on how CruiseControl does it's build reports. The servlet caches the generated HTML to keep from incurring the costs of transformation every time. The DOM representing the XSL file is also cached in memory.

Right now the XSLT is deployed inside the WAR file. We would like to support a default XSLT deployed in the WAR file, but also the ability to update just the XSLT without re-deploying the entire app. I'm hoping some folks might have some good ideas for solving this sort of problem.


Update

From the comment(s) I've received I realize there are some server specific ways to do this. But I'm hoping to solve it in a more generic way. I need to make sure I'm able to keep the following features...

  1. Once a new XSLT is detected, cache the XSLT itself (until a new version is detected)
  2. Keep cached versions of the generated HTML, updating them when there is a new XSLT.
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
bconneen
  • 146
  • 2
  • 12
  • Hm.. I believe answers to this question might be server specific, as how the server organizes the deployed (unarchived) content can vary. I know that if you deploy using a .EAR on a WebLogic server, this kind of functionality is possible. See: http://download.oracle.com/docs/cd/E13222_01/wls/docs90/deployment/redeploy.html#1025739 – Kai Mar 27 '11 at 23:24
  • @Kai I can definitely understand there are server specific ways to replace the actual content of the WAR/EAR, but I was hoping to solve this in a generic way. – bconneen Mar 28 '11 at 01:02
  • Not about XSLT, but web application deployment. Rettaging. –  Mar 28 '11 at 15:54

1 Answers1

2

Rather than putting the XSLT inside the war file, I would choose to have a configurable xslt-folder outside of my war; by "configurable" I mean that there's a configuration file (properties or other formats) that tells the webapp the path of xslt-folder. Then you can periodically monitor the content of that folder, and if any XSLT changes, then you invalidate the corresponding cache, reload the XSLT, and start using the new one. You must also be careful with atomicity of operations: invalidating the cache and reloading XSLT may disrupt an ongoing service request for content generated by that XSLT.

MarcoS
  • 13,386
  • 7
  • 42
  • 63
  • Perhaps a combination of both? Defaults get deployed with the WAR, and we monitor a directory for new versions? – bconneen Mar 28 '11 at 11:12