diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java index c336f051..00957e55 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.Set; import java.util.jar.JarInputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -29,4 +30,16 @@ public void pushJarFile(JarInputStream input) throws IOException { e = input.getNextEntry(); } } + public void pushJarFile(JarInputStream input, Set blacklist) throws IOException { + ZipEntry e = input.getNextEntry(); + while (e != null) { + if(blacklist.contains(e.getName())){ + e = input.getNextEntry(); + continue; + } + output.putNextEntry(e); + IOHelper.transfer(input,output); + e = input.getNextEntry(); + } + } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java index 77d5a0cf..4668bc97 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -2,36 +2,35 @@ import java.io.IOException; -import javassist.CannotCompileException; -import javassist.ClassPool; -import javassist.CtClass; -import javassist.CtConstructor; -import javassist.NotFoundException; +import javassist.*; public class JAConfigurator implements AutoCloseable { ClassPool pool = ClassPool.getDefault(); CtClass ctClass; CtConstructor ctConstructor; + CtMethod initModuleMethod; String classname; StringBuilder body; + StringBuilder moduleBody; int autoincrement; public JAConfigurator(Class configclass) throws NotFoundException { classname = configclass.getName(); ctClass = pool.get(classname); ctConstructor = ctClass.getDeclaredConstructor(null); - body = new StringBuilder("{"); + initModuleMethod = ctClass.getDeclaredMethod("initModules"); + body = new StringBuilder("{ isInitModules = false; "); autoincrement = 0; } public void addModuleClass(String fullName) { - body.append("ru.gravit.launcher.modules.Module mod"); - body.append(autoincrement); - body.append(" = new "); - body.append(fullName); - body.append("();"); - body.append("ru.gravit.launcher.Launcher.modulesManager.registerModule( mod"); - body.append(autoincrement); - body.append(" , true );"); + moduleBody.append("ru.gravit.launcher.modules.Module mod"); + moduleBody.append(autoincrement); + moduleBody.append(" = new "); + moduleBody.append(fullName); + moduleBody.append("();"); + moduleBody.append("ru.gravit.launcher.Launcher.modulesManager.registerModule( mod"); + moduleBody.append(autoincrement); + moduleBody.append(" , true );"); autoincrement++; } @Override @@ -41,6 +40,7 @@ public void close() { public byte[] getBytecode() throws IOException, CannotCompileException { body.append("}"); ctConstructor.setBody(body.toString()); + initModuleMethod.insertAfter(moduleBody.toString()); return ctClass.toBytecode(); } public String getZipEntryPath() @@ -60,4 +60,8 @@ public void setPort(int port) body.append(port); body.append(";"); } + public ClassPool getPool() + { + return pool; + } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 65efa0dc..566177ed 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -381,7 +381,7 @@ public static Process launch( @LauncherAPI public static void main(String... args) throws Throwable { Launcher.modulesManager = new ClientModuleManager(null); - LauncherConfig.getAutogenConfig(); //INIT + LauncherConfig.getAutogenConfig().initModules(); //INIT Launcher.modulesManager.preInitModules(); if (JVMHelper.OS_TYPE == OS.MUSTDIE) { AvanguardStarter.loadVared(); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java index e08f5c03..25d75d7e 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/AutogenConfig.java @@ -4,7 +4,12 @@ public class AutogenConfig { public String projectname; public String address; public int port; + private boolean isInitModules; AutogenConfig() { } + public void initModules() + { + if(isInitModules) return; + } }