KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > ant > Launcher


1 package org.jbpm.ant;
2
3 import java.io.BufferedReader JavaDoc;
4 import java.io.IOException JavaDoc;
5 import java.io.InputStreamReader JavaDoc;
6
7 import org.apache.tools.ant.BuildException;
8 import org.apache.tools.ant.Task;
9
10 public class Launcher extends Thread JavaDoc {
11
12   Task task;
13   String JavaDoc command;
14   String JavaDoc endMsg;
15
16   public Launcher(Task task, String JavaDoc command, String JavaDoc endMsg) {
17     this.task = task;
18     this.command = command;
19     this.endMsg = endMsg;
20   }
21
22   public void run() {
23     try {
24       task.log("starting '" + command + "'...");
25       Process JavaDoc process = Runtime.getRuntime().exec(command);
26       BufferedReader JavaDoc reader = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getInputStream()));
27       String JavaDoc line = "";
28       while (line.indexOf(endMsg) == -1) {
29         line = reader.readLine();
30         task.log(line);
31       }
32       task.log("'" + command + "' started.");
33     } catch (IOException JavaDoc e) {
34       throw new BuildException("couldn't start '" + command + "'", e);
35     }
36   }
37
38 }
39
Popular Tags