开发者

Updating XSLT files in a deployed Java EE app without re-deploying?

开发者 https://www.devze.com 2023-02-19 22:43 出处:网络
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 pa

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消