From 7eef6503004bd11232835e81a0d0f0c96328b598 Mon Sep 17 00:00:00 2001 From: YuriyZ Date: Wed, 18 May 2022 18:10:00 +0300 Subject: [PATCH] feat(jans-core): wip for compiler https://github.com/JanssenProject/jans/issues/318 --- .../custom/script/ExternalTypeCreator.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/jans-core/script/src/main/java/io/jans/service/custom/script/ExternalTypeCreator.java b/jans-core/script/src/main/java/io/jans/service/custom/script/ExternalTypeCreator.java index af6d7e6d764..88345f9bdce 100644 --- a/jans-core/script/src/main/java/io/jans/service/custom/script/ExternalTypeCreator.java +++ b/jans-core/script/src/main/java/io/jans/service/custom/script/ExternalTypeCreator.java @@ -27,11 +27,8 @@ import java.net.URL; import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.Date; import java.util.Map; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; /** * @author Yuriy Zabrovarnyy @@ -107,6 +104,7 @@ private void outputUrls(ClassLoader classLoader) { URL[] urls = ((URLClassLoader) classLoader).getURLs(); for (URL url : urls) { log.info("system url: {}", url.getFile()); + CompilerUtils.addClassPath(url.getFile()); } } catch (Throwable e) { log.error("FAILED to output class loader urls", e); @@ -126,32 +124,25 @@ private void outputTmpDir() { private BaseExternalType createExternalTypeWithJava(CustomScript customScript) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { log.info(" STARTING >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + +// outputUrls(ClassLoader.getSystemClassLoader()); + outputUrls(this.getClass().getClassLoader()); +// outputUrls(Thread.currentThread().getContextClassLoader()); + try { - CompilerUtils.addClassPath("WEB-INF/lib"); - CompilerUtils.addClassPath("WEB-INF/classes"); CachedCompilerA.reset(); } catch (Throwable e) { log.error("FAILED to modify class path"); } - outputUrls(ClassLoader.getSystemClassLoader()); - outputUrls(this.getClass().getClassLoader()); - outputUrls(Thread.currentThread().getContextClassLoader()); - - outputTmpDir(); - Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { - @Override - public void run() { - outputTmpDir(); - } - }, 10, TimeUnit.SECONDS); - +// outputTmpDir(); log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - log.info("SYSTEM properties > java.io.tmpdir: {}", System.getProperties()); - log.info("TMP > java.io.tmpdir: {}", System.getProperty("java.io.tmpdir")); +// log.info("SYSTEM properties > java.io.tmpdir: {}", System.getProperties()); +// log.info("TMP > java.io.tmpdir: {}", System.getProperty("java.io.tmpdir")); log.info("CLASSPATH > java.class.path: {}", System.getProperty("java.class.path")); + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); CustomScriptType customScriptType = customScript.getScriptType(); Class aClass = CachedCompilerA.CACHED_COMPILER.loadFromJava(customScriptType.getClassName(), customScript.getScript());