凑巧使用了jetty后,为了解决每次jetty都可以清除war包解压后的临时文件,所以强制指定了-Djava.io.tmpdir=${jetty_server}/tmp/ , 模拟了jboss_server的方式,所有的jetty运行的信息都会保存到一个${jetty_server}目录下,每次重启都会清空该目录。避免上一次的结果对下一次启动的影响,以前遇到过部署内容一直被缓存的问题,所以采取了这样的一种暴力删除的方式。
war解压临时目录算法如下:
/**
* Get a temporary directory in which to unpack the war etc etc.
* The algorithm for determining this is to check these alternatives
* in the order shown:
*
* <p>A. Try to use an explicit directory specifically for this webapp:</p>
* <ol>
* <li>
* Iff an explicit directory is set for this webapp, use it. Do NOT set
* delete on exit.
* </li>
* <li>
* Iff javax.servlet.context.tempdir context attribute is set for
* this webapp && exists && writeable, then use it. Do NOT set delete on exit.
* </li>
* </ol>
*
* <p>B. Create a directory based on global settings. The new directory
* will be called "Jetty_"+host+"_"+port+"__"+context+"_"+virtualhost
* Work out where to create this directory:
* <ol>
* <li>
* Iff $(jetty.home)/work exists create the directory there. Do NOT
* set delete on exit. Do NOT delete contents if dir already exists.
* </li>
* <li>
* Iff WEB-INF/work exists create the directory there. Do NOT set
* delete on exit. Do NOT delete contents if dir already exists.
* </li>
* <li>
* Else create dir in $(java.io.tmpdir). Set delete on exit. Delete
* contents if dir already exists.
* </li>
* </ol>
**/