From 0e2c19f79c821c656c487bb96721159b2dcf52b6 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 18 Sep 2019 03:25:59 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20API=20=D1=81=D0=BE=D0=B7=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=B4=D0=BE=20=D1=81=D1=82=D0=B0=D1=80=D1=82=D0=B0=20?= =?UTF-8?q?LauncherEngine(Wrapper=20Phase)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/gravit/launcher/ClientLauncherWrapper.java | 5 +++++ .../gravit/launcher/client/ClientModuleManager.java | 11 +++++++++++ .../gravit/launcher/client/ClientWrapperModule.java | 7 +++++++ 3 files changed, 23 insertions(+) create mode 100644 Launcher/src/main/java/pro/gravit/launcher/client/ClientWrapperModule.java diff --git a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java index 97ec06bc..d3d431a9 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java @@ -8,6 +8,7 @@ import java.util.List; import pro.gravit.launcher.client.ClientLauncher; +import pro.gravit.launcher.client.ClientModuleManager; import pro.gravit.launcher.client.DirBridge; import pro.gravit.utils.helper.EnvHelper; import pro.gravit.utils.helper.IOHelper; @@ -26,6 +27,9 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep JVMHelper.verifySystemProperties(Launcher.class, true); EnvHelper.checkDangerousParams(); LauncherConfig config = Launcher.getConfig(); + LauncherEngine.modulesManager = new ClientModuleManager(); + LauncherConfig.getAutogenConfig().initModules(); + LogHelper.info("Launcher for project %s", config.projectname); if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { if (System.getProperty(LogHelper.DEBUG_PROPERTY) != null) { @@ -59,6 +63,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep Collections.addAll(args, "-cp"); Collections.addAll(args, pathLauncher); Collections.addAll(args, LauncherEngine.class.getName()); + LauncherEngine.modulesManager.callWrapper(processBuilder, args); EnvHelper.addEnv(processBuilder); LogHelper.debug("Commandline: " + args); processBuilder.command(args); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java index 90e66237..a5f6343f 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.Collection; import pro.gravit.launcher.modules.LauncherModule; import pro.gravit.launcher.modules.impl.SimpleModuleManager; @@ -25,4 +26,14 @@ public void autoload(Path dir) throws IOException { public LauncherModule loadModule(Path file) throws IOException { throw new UnsupportedOperationException(); } + public void callWrapper(ProcessBuilder processBuilder, Collection jvmArgs) + { + for(LauncherModule module : modules) + { + if(module instanceof ClientWrapperModule) + { + ((ClientWrapperModule) module).wrapperPhase(processBuilder, jvmArgs); + } + } + } } diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientWrapperModule.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientWrapperModule.java new file mode 100644 index 00000000..4381e6e0 --- /dev/null +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientWrapperModule.java @@ -0,0 +1,7 @@ +package pro.gravit.launcher.client; + +import java.util.Collection; + +public interface ClientWrapperModule { + void wrapperPhase(ProcessBuilder processBuilder, Collection jvmArgs); +}