Фикс log4j

This commit is contained in:
Gravit 2018-09-19 20:42:17 +07:00
parent 8f76bfdf03
commit f53ed9be52
3 changed files with 3 additions and 7 deletions

View file

@ -19,6 +19,7 @@ public JAConfigurator(Class<?> configclass) throws NotFoundException {
ctConstructor = ctClass.getDeclaredConstructor(null);
initModuleMethod = ctClass.getDeclaredMethod("initModules");
body = new StringBuilder("{ isInitModules = false; ");
moduleBody = new StringBuilder("{ isInitModules = true; ");
autoincrement = 0;
}
public void addModuleClass(String fullName)
@ -39,6 +40,7 @@ public void close() {
}
public byte[] getBytecode() throws IOException, CannotCompileException {
body.append("}");
moduleBody.append("}");
ctConstructor.setBody(body.toString());
initModuleMethod.insertAfter(moduleBody.toString());
return ctClass.toBytecode();

View file

@ -190,7 +190,7 @@ private void setScriptBindings() {
@LauncherAPI
public void start(String... args) throws Throwable {
Launcher.modulesManager = new ClientModuleManager(this);
LauncherConfig.getAutogenConfig(); //INIT
LauncherConfig.getAutogenConfig().initModules(); //INIT
Launcher.modulesManager.preInitModules();
Objects.requireNonNull(args, "args");
if (started.getAndSet(true))

View file

@ -20,12 +20,6 @@
public class ServerWrapper {
public static ModulesManager modulesManager;
public static void main(String[] args) throws Throwable {
if(System.getProperty("log4j.configurationFile") == null)
try(InputStream stream = IOHelper.newInput(IOHelper.getResourceURL("log4j2.xml"))) {
System.setProperty("log4j.configurationFile", "launcher/log4j2.xml,log4j2.xml");
} catch (Exception e) {
System.setProperty("log4j.configurationFile", "ru/gravit/launcher/log4j2.xml");
}
ServerWrapper wrapper = new ServerWrapper();
modulesManager = new ModulesManager(wrapper);
modulesManager.autoload(Paths.get("modules"));