mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] clearLauncherPackages, LaunchServerControlHolder
This commit is contained in:
parent
3e8c1adebe
commit
8cd43b0324
6 changed files with 54 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package pro.gravit.launchserver;
|
package pro.gravit.launchserver;
|
||||||
|
|
||||||
|
import pro.gravit.launchserver.holder.LaunchServerControlHolder;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.launch.ClassLoaderControl;
|
import pro.gravit.utils.launch.ClassLoaderControl;
|
||||||
import pro.gravit.utils.launch.LaunchOptions;
|
import pro.gravit.utils.launch.LaunchOptions;
|
||||||
|
@ -54,7 +55,6 @@ public static void main(String[] args) throws Throwable {
|
||||||
unpackLog4j();
|
unpackLog4j();
|
||||||
ModuleLaunch launch = new ModuleLaunch();
|
ModuleLaunch launch = new ModuleLaunch();
|
||||||
LaunchOptions options = new LaunchOptions();
|
LaunchOptions options = new LaunchOptions();
|
||||||
options.disablePackageDelegateSupport = true;
|
|
||||||
options.moduleConf = new LaunchOptions.ModuleConf();
|
options.moduleConf = new LaunchOptions.ModuleConf();
|
||||||
List<Path> libraries;
|
List<Path> libraries;
|
||||||
try(Stream<Path> files = Files.walk(Path.of("libraries"), FileVisitOption.FOLLOW_LINKS)) {
|
try(Stream<Path> files = Files.walk(Path.of("libraries"), FileVisitOption.FOLLOW_LINKS)) {
|
||||||
|
@ -73,7 +73,12 @@ public static void main(String[] args) throws Throwable {
|
||||||
options.moduleConf.modulePath.addAll(modulepath);
|
options.moduleConf.modulePath.addAll(modulepath);
|
||||||
options.moduleConf.modules.add("ALL-MODULE-PATH");
|
options.moduleConf.modules.add("ALL-MODULE-PATH");
|
||||||
ClassLoaderControl control = launch.init(classpath, "natives", options);
|
ClassLoaderControl control = launch.init(classpath, "natives", options);
|
||||||
|
control.clearLauncherPackages();
|
||||||
|
control.addLauncherPackage("pro.gravit.utils.launch");
|
||||||
|
control.addLauncherPackage("pro.gravit.launchserver.holder");
|
||||||
ModuleLayer.Controller controller = (ModuleLayer.Controller) control.getJava9ModuleController();
|
ModuleLayer.Controller controller = (ModuleLayer.Controller) control.getJava9ModuleController();
|
||||||
|
LaunchServerControlHolder.setControl(control);
|
||||||
|
LaunchServerControlHolder.setController(controller);
|
||||||
launch.launch("pro.gravit.launchserver.LaunchServerStarter", null, Arrays.asList(args));
|
launch.launch("pro.gravit.launchserver.LaunchServerStarter", null, Arrays.asList(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package pro.gravit.launchserver.holder;
|
||||||
|
|
||||||
|
import pro.gravit.utils.launch.ClassLoaderControl;
|
||||||
|
|
||||||
|
public class LaunchServerControlHolder {
|
||||||
|
private static ClassLoaderControl control;
|
||||||
|
private static ModuleLayer.Controller controller;
|
||||||
|
|
||||||
|
public static ClassLoaderControl getControl() {
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setControl(ClassLoaderControl control) {
|
||||||
|
LaunchServerControlHolder.control = control;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModuleLayer.Controller getController() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setController(ModuleLayer.Controller controller) {
|
||||||
|
LaunchServerControlHolder.controller = controller;
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,6 +56,11 @@ public void addLauncherPackage(String prefix) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearLauncherPackages() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTransformer(ClassTransformer transformer) {
|
public void addTransformer(ClassTransformer transformer) {
|
||||||
if (instrumentation == null) {
|
if (instrumentation == null) {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
public interface ClassLoaderControl {
|
public interface ClassLoaderControl {
|
||||||
void addLauncherPackage(String prefix);
|
void addLauncherPackage(String prefix);
|
||||||
|
void clearLauncherPackages();
|
||||||
void addTransformer(ClassTransformer transformer);
|
void addTransformer(ClassTransformer transformer);
|
||||||
void addURL(URL url);
|
void addURL(URL url);
|
||||||
void addJar(Path path);
|
void addJar(Path path);
|
||||||
|
|
|
@ -126,6 +126,10 @@ public void addAllowedPackage(String pkg) {
|
||||||
packages.add(pkg);
|
packages.add(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearAllowedPackages() {
|
||||||
|
packages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private LegacyClassLoaderControl makeControl() {
|
private LegacyClassLoaderControl makeControl() {
|
||||||
return new LegacyClassLoaderControl();
|
return new LegacyClassLoaderControl();
|
||||||
}
|
}
|
||||||
|
@ -137,6 +141,11 @@ public void addLauncherPackage(String prefix) {
|
||||||
addAllowedPackage(prefix);
|
addAllowedPackage(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearLauncherPackages() {
|
||||||
|
clearAllowedPackages();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTransformer(ClassTransformer transformer) {
|
public void addTransformer(ClassTransformer transformer) {
|
||||||
transformers.add(transformer);
|
transformers.add(transformer);
|
||||||
|
|
|
@ -264,6 +264,10 @@ public void addAllowedPackage(String pkg) {
|
||||||
packages.add(pkg);
|
packages.add(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearAllowedPackages() {
|
||||||
|
packages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private ModuleClassLoaderControl makeControl() {
|
private ModuleClassLoaderControl makeControl() {
|
||||||
return new ModuleClassLoaderControl();
|
return new ModuleClassLoaderControl();
|
||||||
}
|
}
|
||||||
|
@ -275,6 +279,11 @@ public void addLauncherPackage(String prefix) {
|
||||||
addAllowedPackage(prefix);
|
addAllowedPackage(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearLauncherPackages() {
|
||||||
|
clearAllowedPackages();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTransformer(ClassTransformer transformer) {
|
public void addTransformer(ClassTransformer transformer) {
|
||||||
transformers.add(transformer);
|
transformers.add(transformer);
|
||||||
|
|
Loading…
Reference in a new issue