[FEATURE] API создания модулей до старта LauncherEngine(Wrapper Phase)

This commit is contained in:
Gravit 2019-09-18 03:25:59 +07:00
parent e2d3e3068f
commit 0e2c19f79c
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 23 additions and 0 deletions

View file

@ -8,6 +8,7 @@
import java.util.List; import java.util.List;
import pro.gravit.launcher.client.ClientLauncher; import pro.gravit.launcher.client.ClientLauncher;
import pro.gravit.launcher.client.ClientModuleManager;
import pro.gravit.launcher.client.DirBridge; import pro.gravit.launcher.client.DirBridge;
import pro.gravit.utils.helper.EnvHelper; import pro.gravit.utils.helper.EnvHelper;
import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.IOHelper;
@ -26,6 +27,9 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
JVMHelper.verifySystemProperties(Launcher.class, true); JVMHelper.verifySystemProperties(Launcher.class, true);
EnvHelper.checkDangerousParams(); EnvHelper.checkDangerousParams();
LauncherConfig config = Launcher.getConfig(); LauncherConfig config = Launcher.getConfig();
LauncherEngine.modulesManager = new ClientModuleManager();
LauncherConfig.getAutogenConfig().initModules();
LogHelper.info("Launcher for project %s", config.projectname); LogHelper.info("Launcher for project %s", config.projectname);
if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) {
if (System.getProperty(LogHelper.DEBUG_PROPERTY) != null) { 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, "-cp");
Collections.addAll(args, pathLauncher); Collections.addAll(args, pathLauncher);
Collections.addAll(args, LauncherEngine.class.getName()); Collections.addAll(args, LauncherEngine.class.getName());
LauncherEngine.modulesManager.callWrapper(processBuilder, args);
EnvHelper.addEnv(processBuilder); EnvHelper.addEnv(processBuilder);
LogHelper.debug("Commandline: " + args); LogHelper.debug("Commandline: " + args);
processBuilder.command(args); processBuilder.command(args);

View file

@ -2,6 +2,7 @@
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collection;
import pro.gravit.launcher.modules.LauncherModule; import pro.gravit.launcher.modules.LauncherModule;
import pro.gravit.launcher.modules.impl.SimpleModuleManager; 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 { public LauncherModule loadModule(Path file) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public void callWrapper(ProcessBuilder processBuilder, Collection<String> jvmArgs)
{
for(LauncherModule module : modules)
{
if(module instanceof ClientWrapperModule)
{
((ClientWrapperModule) module).wrapperPhase(processBuilder, jvmArgs);
}
}
}
} }

View file

@ -0,0 +1,7 @@
package pro.gravit.launcher.client;
import java.util.Collection;
public interface ClientWrapperModule {
void wrapperPhase(ProcessBuilder processBuilder, Collection<String> jvmArgs);
}