
org.zeroturnaround.process.CompositeProcess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zt-process-killer Show documentation
Show all versions of zt-process-killer Show documentation
A library for stopping external processes from Java.
package org.zeroturnaround.process;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Contains other {@link SystemProcess}es preserving their order.
*/
public abstract class CompositeProcess extends AbstractProcess {
protected final List extends SystemProcess> children;
public CompositeProcess(List extends SystemProcess> children) {
this.children = children;
}
@Override
public String getDescription() {
List result = new ArrayList();
for (SystemProcess child : children) {
result.add(child.toString());
}
return result.toString();
}
@Override
public String toString() {
List result = new ArrayList();
for (SystemProcess child : children) {
result.add(child.toString());
}
return getClass().getSimpleName() + result.toString();
}
protected static void invokeDestroy(SystemProcess killer, boolean forceful) throws IOException, InterruptedException {
if (forceful) {
killer.destroyForcefully();
}
else {
killer.destroyGracefully();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy