开发者

Development deployment: how to achive edit-and-reload with JSP pages?

Out project uses WebLogic as web-server and uses mostly JSP for user interface. With standard setup it is possible to copy edited JSP files into the exploded deployment directory and WebLogic will automatically pick them up, recompile开发者_Python百科 and serve new content through HTTP. However, is it possible to avoid copying at all, so that I just save a file in my editor and it is immediately (well, after a couple of seconds for recompilation) visible?

The project uses Apache Ant as building tool. I would imagine what I want would be possible with symlinks (since this is for deployment only I don't care about cross-platformity), but then I don't see how it is possible to symlink lots of files at once with Ant.

So, how do I achieve save-JSP-hit-F5-in-browser functionality either

  • with some setting in WebLogic; or
  • with symlinking JSPs using Apache Ant (instead of copying them as is done now); or
  • something else completely?


A cron job could be setup to watch the source directories of your JSP files and copy them to the target directory on the server. Continuous Integration tools do this sort of thing to have builds triggered by the checkin of code. SourceForge has a server that does it and CruiseControl is another.


In the end, I had to use Ant's exec tool, because its symlink is very inconvenient. Additionally, delete follows symbolic links by default, which I find a horrible design decision (luckily I didn't delete anything not recoverable from VCS). If it is instructed to not follow links, then it doesn't delete them either (there's a flag for it in 1.8 but I have to use an older version). So, I had to replace clean target's delete with exec that essentially just runs rm -r — it is easier than 20+ lines of Ant mumbo-jumbo.

Also, if anyone is going to do something similar: don't forget to use -t option to ln if creating symlinks to directories. Otherwise, a repetetive run will create another link inside the directory symlink points to.

All in all it is working now, but I'm disappointed with Ant. I guess this all comes from Java's absent symlink support, but still...


You can put all your JSP files under a jsp folder and then symlink that folder into your WEB-INF folder in the exploded deployment directory.

Ant has an optinal task for creating single symlinks. The task can kind of create directories of symlinks, but works by recording what symlinks are there and then later re-creating those at a later time. (E.g. you could use shell script to initially create your symlinks in your jsp source, use Ant to record the links created, which is stored in a text file with your source folder, and then use this text file to later recreate the links.)

http://ant.apache.org/manual/Tasks/symlink.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜