| 1 | /* |
| 2 | * Created on Sep 22, 2004 |
| 3 | * |
| 4 | * FIXME To change the template for this generated file go to |
| 5 | * Window - Preferences - Java - Code Style - Code Templates |
| 6 | */ |
| 7 | package biz.xsoftware.buildtemplate; |
| 8 | |
| 9 | import java.util.logging.Level; |
| 10 | import java.util.logging.Logger; |
| 11 | |
| 12 | |
| 13 | public class Shutdown extends Thread { |
| 14 | private static final Logger log = Logger.getLogger(Shutdown.class.getName()); |
| 15 | |
| 16 | private BuildTemplate template; |
| 17 | private RunAnt ant; |
| 18 | private boolean wantCompress; |
| 19 | public Shutdown(BuildTemplate template, RunAnt ant, boolean wantCompress) { |
| 20 | this.template = template; |
| 21 | this.ant = ant; |
| 22 | this.wantCompress = wantCompress; |
| 23 | } |
| 24 | public void run() { |
| 25 | System.err.println(); |
| 26 | System.err.println("Running shutdown hook to recompress template"); |
| 27 | System.err.println("Powerd by http://buildtemplate.sourceforge.net & ant"); |
| 28 | System.err.flush(); |
| 29 | log.info("Running shutdown hook to recompress template"); |
| 30 | try { |
| 31 | //stop ant if it is running first so it unlocks all the jars |
| 32 | //we need to delete! |
| 33 | ant.destroy(); |
| 34 | |
| 35 | //do we need to wait for ant??? |
| 36 | //unextract the template now |
| 37 | if(wantCompress) |
| 38 | template.compress(); |
| 39 | } catch(Throwable e) { |
| 40 | log.log(Level.WARNING, "Exception on shutdown", e); |
| 41 | } |
| 42 | } |
| 43 | } |