mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(runner): apply execution policy wrapping before command execution in OriginExecutionService
This commit is contained in:
@@ -2,8 +2,13 @@ package work.slhaf.partner.core.action.runner.execution;
|
||||
|
||||
import work.slhaf.partner.core.action.entity.MetaAction;
|
||||
import work.slhaf.partner.core.action.runner.RunnerClient;
|
||||
import work.slhaf.partner.core.action.runner.policy.ExecutionPolicyRegistry;
|
||||
import work.slhaf.partner.core.action.runner.policy.WrappedLaunchSpec;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OriginExecutionService {
|
||||
|
||||
@@ -17,7 +22,11 @@ public class OriginExecutionService {
|
||||
RunnerClient.RunnerResponse response = new RunnerClient.RunnerResponse();
|
||||
File file = new File(metaAction.getLocation());
|
||||
String[] commands = commandExecutionService.buildCommands(metaAction.getLauncher(), metaAction.getParams(), file.getAbsolutePath());
|
||||
CommandExecutionService.Result execResult = commandExecutionService.exec(commands);
|
||||
WrappedLaunchSpec wrapped = ExecutionPolicyRegistry.INSTANCE.prepare(Arrays.stream(commands).toList());
|
||||
List<String> wrappedCommands = new ArrayList<>();
|
||||
wrappedCommands.add(wrapped.getCommand());
|
||||
wrappedCommands.addAll(wrapped.getArgs());
|
||||
CommandExecutionService.Result execResult = commandExecutionService.exec(wrappedCommands);
|
||||
response.setOk(execResult.isOk());
|
||||
response.setData(execResult.getTotal());
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user