KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 package org.apache.roller.ant;
19
20 import org.apache.tools.ant.BuildException;
21 import org.apache.tools.ant.Task;
22 import org.hsqldb.Server;
23
24 /**
25  * Ant Task to start HSQLDB
26  * @author Dave Johnson
27  */

28 public class StartHsqldbTask extends Task
29 {
30     private String JavaDoc database = null;
31     private String JavaDoc port = null;
32     public void execute() throws BuildException
33     {
34         if (database != null) {
35             Thread JavaDoc server = new Thread JavaDoc() {
36                 public void run() {
37                     System.out.println("Starting HSQLDB");
38                     String JavaDoc[] args = {
39                         "-database", database,
40                         "-port", port,
41                         "-no_system_exit", "true" };
42                     Server.main(args);
43                 }
44             };
45             server.start();
46         }
47         try {Thread.sleep(2000);} catch (Exception JavaDoc ignored) {}
48     }
49     /**
50      * @return Returns the database.
51      */

52     public String JavaDoc getDatabase()
53     {
54         return database;
55     }
56     /**
57      * @param database The database to set.
58      */

59     public void setDatabase(String JavaDoc database)
60     {
61         this.database = database;
62     }
63     /**
64      * @return Returns the port.
65      */

66     public String JavaDoc getPort()
67     {
68         return port;
69     }
70     /**
71      * @param port The port to set.
72      */

73     public void setPort(String JavaDoc port)
74     {
75         this.port = port;
76     }
77 }
78
Popular Tags