1 package net.sourceforge.cruisecontrol.bootstrappers; 2 3 import java.io.File ; 4 import java.io.IOException ; 5 6 import net.sourceforge.cruisecontrol.Bootstrapper; 7 import net.sourceforge.cruisecontrol.CruiseControlException; 8 import net.sourceforge.cruisecontrol.util.ValidationHelper; 9 10 public class LockFileBootstrapper implements Bootstrapper { 11 12 private String path; 13 14 public void bootstrap() throws CruiseControlException { 15 File lock = new File (path); 16 try { 17 if (!lock.createNewFile()) { 18 throw new CruiseControlException("lock file already exits, aborting build attempt"); 19 } else { 20 lock.deleteOnExit(); 21 } 22 } catch (IOException e) { 23 throw new CruiseControlException(e); 24 } 25 } 26 27 public void validate() throws CruiseControlException { 28 ValidationHelper.assertIsSet(path, "lockfile", LockFileBootstrapper.class); 29 } 30 31 public void setLockFile(String path) { 32 this.path = path; 33 } 34 } 35 | Popular Tags |