KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > ant > StartHsqldbTask


1 package org.roller.ant;
2
3 import org.apache.tools.ant.BuildException;
4 import org.apache.tools.ant.Task;
5 import org.hsqldb.Server;
6
7 /**
8  * Ant Task to start HSQLDB
9  * @author Dave Johnson
10  */

11 public class StartHsqldbTask extends Task
12 {
13     private String JavaDoc database = null;
14     private String JavaDoc port = null;
15     public void execute() throws BuildException
16     {
17         if (database != null) {
18             Thread JavaDoc server = new Thread JavaDoc() {
19                 public void run() {
20                     System.out.println("Starting HSQLDB");
21                     String JavaDoc[] args = {
22                         "-database", database,
23                         "-port", port,
24                         "-no_system_exit", "true" };
25                     Server.main(args);
26                 }
27             };
28             server.start();
29         }
30         try {Thread.sleep(2000);} catch (Exception JavaDoc ignored) {}
31     }
32     /**
33      * @return Returns the database.
34      */

35     public String JavaDoc getDatabase()
36     {
37         return database;
38     }
39     /**
40      * @param database The database to set.
41      */

42     public void setDatabase(String JavaDoc database)
43     {
44         this.database = database;
45     }
46     /**
47      * @return Returns the port.
48      */

49     public String JavaDoc getPort()
50     {
51         return port;
52     }
53     /**
54      * @param port The port to set.
55      */

56     public void setPort(String JavaDoc port)
57     {
58         this.port = port;
59     }
60 }
61
Popular Tags