KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > bootstrappers > LockFileBootstrapper


1 package net.sourceforge.cruisecontrol.bootstrappers;
2
3 import java.io.File JavaDoc;
4 import java.io.IOException JavaDoc;
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 JavaDoc path;
13
14     public void bootstrap() throws CruiseControlException {
15         File JavaDoc lock = new File JavaDoc(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 JavaDoc 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 JavaDoc path) {
32         this.path = path;
33     }
34 }
35
Popular Tags