01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: private String database = null;
30: private String port = null;
31:
32: public void execute() throws BuildException {
33: if (database != null) {
34: Thread server = new Thread() {
35: public void run() {
36: System.out.println("Starting HSQLDB");
37: String[] args = { "-database", database, "-port",
38: port, "-no_system_exit", "true" };
39: Server.main(args);
40: }
41: };
42: server.start();
43: }
44: try {
45: Thread.sleep(2000);
46: } catch (Exception ignored) {
47: }
48: }
49:
50: /**
51: * @return Returns the database.
52: */
53: public String getDatabase() {
54: return database;
55: }
56:
57: /**
58: * @param database The database to set.
59: */
60: public void setDatabase(String database) {
61: this .database = database;
62: }
63:
64: /**
65: * @return Returns the port.
66: */
67: public String getPort() {
68: return port;
69: }
70:
71: /**
72: * @param port The port to set.
73: */
74: public void setPort(String port) {
75: this.port = port;
76: }
77: }
|