ProcessRef launch(JavaCommand command) {
Process process = null;
try {
- ProcessCommands commands = allProcessesCommands.getProcessCommand(command.getProcessIndex(), true);
+ ProcessCommands commands = allProcessesCommands.createAfterClean(command.getProcessIndex());
ProcessBuilder processBuilder = create(command);
LoggerFactory.getLogger(getClass()).info("Launch process[{}]: {}",
}
}
- public ProcessCommands getProcessCommand(int processNumber, boolean clean) {
+ public ProcessCommands create(int processNumber) {
+ return createForProcess(processNumber, false);
+ }
+
+ public ProcessCommands createAfterClean(int processNumber) {
+ return createForProcess(processNumber, true);
+ }
+
+ private ProcessCommands createForProcess(int processNumber, boolean clean) {
checkProcessNumber(processNumber);
ProcessCommands processCommands = new ProcessCommandsImpl(processNumber);
if (clean) {
public DefaultProcessCommands(File directory, int processNumber, boolean clean) {
this.allProcessesCommands = new AllProcessesCommands(directory);
- this.delegate = allProcessesCommands.getProcessCommand(processNumber, clean);
+ this.delegate = clean ? allProcessesCommands.createAfterClean(processNumber) : allProcessesCommands.create(processNumber);
}
@Override
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Process number " + processNumber + " is not valid");
- allProcessesCommands.getProcessCommand(processNumber, true);
+ allProcessesCommands.createAfterClean(processNumber);
}
@Test
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Process number " + processNumber + " is not valid");
- allProcessesCommands.getProcessCommand(processNumber, true);
+ allProcessesCommands.createAfterClean(processNumber);
}
}