forked from j62/ctbrec
Set the name in the default constructor
This commit is contained in:
parent
888046676f
commit
7c16006870
|
@ -12,11 +12,13 @@ public class PlaySound extends Action {
|
||||||
|
|
||||||
private URL url;
|
private URL url;
|
||||||
|
|
||||||
public PlaySound() {}
|
public PlaySound() {
|
||||||
|
name = "play sound";
|
||||||
|
}
|
||||||
|
|
||||||
public PlaySound(URL url) {
|
public PlaySound(URL url) {
|
||||||
|
this();
|
||||||
this.url = url;
|
this.url = url;
|
||||||
name = "play sound";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package ctbrec.event;
|
package ctbrec.event;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -13,11 +15,13 @@ public class ExecuteProgram extends Action {
|
||||||
|
|
||||||
private String executable;
|
private String executable;
|
||||||
|
|
||||||
public ExecuteProgram() {}
|
public ExecuteProgram() {
|
||||||
|
name = "execute program";
|
||||||
|
}
|
||||||
|
|
||||||
public ExecuteProgram(String executable) {
|
public ExecuteProgram(String executable) {
|
||||||
|
this();
|
||||||
this.executable = executable;
|
this.executable = executable;
|
||||||
name = "execute program";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,8 +29,12 @@ public class ExecuteProgram extends Action {
|
||||||
Runtime rt = Runtime.getRuntime();
|
Runtime rt = Runtime.getRuntime();
|
||||||
Process process = null;
|
Process process = null;
|
||||||
try {
|
try {
|
||||||
String[] args = {executable}; // TODO fill args array
|
String[] args = evt.getExecutionParams();
|
||||||
process = rt.exec(args, OS.getEnvironment());
|
String[] cmd = new String[args.length+1];
|
||||||
|
cmd[0] = executable;
|
||||||
|
System.arraycopy(args, 0, cmd, 1, args.length);
|
||||||
|
LOG.debug("Executing {}", Arrays.toString(cmd));
|
||||||
|
process = rt.exec(cmd, OS.getEnvironment());
|
||||||
|
|
||||||
// create threads, which read stdout and stderr of the player process. these are needed,
|
// create threads, which read stdout and stderr of the player process. these are needed,
|
||||||
// because otherwise the internal buffer for these streams fill up and block the process
|
// because otherwise the internal buffer for these streams fill up and block the process
|
||||||
|
@ -40,7 +48,7 @@ public class ExecuteProgram extends Action {
|
||||||
err.start();
|
err.start();
|
||||||
|
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
LOG.debug("{} finished", name);
|
LOG.debug("executing {} finished", executable);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error while processing {}", e);
|
LOG.error("Error while processing {}", e);
|
||||||
}
|
}
|
||||||
|
@ -50,4 +58,9 @@ public class ExecuteProgram extends Action {
|
||||||
public void configure(ActionConfiguration config) {
|
public void configure(ActionConfiguration config) {
|
||||||
executable = (String) config.getConfiguration().get("file");
|
executable = (String) config.getConfiguration().get("file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "execute " + executable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue