From: vasary.daniel Date: Mon, 20 Sep 2021 13:19:46 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=6eb4abe90c99371a0bd9bfa4ce8e14412a88bb0e;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C32338 --- diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java index a82cd32e..dc591b01 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java @@ -67,29 +67,6 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { } } - private GroovyClassLoader createGroovyClassLoader(URLClassLoader stepsClassLoader, String excludeFileName) - throws FileNotFoundException { - String stepsDir = systemConfig.getConfig(DIR_STEPS); - - Set sharedFiles = getJavaFileList(Paths.get(stepsDir, "shared"), excludeFileName); - Set libFiles = getJavaFileList(Paths.get(stepsDir), excludeFileName); - libFiles.addAll(sharedFiles); - - GroovyClassLoader gcl = new GroovyClassLoader(stepsClassLoader) { - - @Override - protected CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource source) { - CompilationUnit result = new CompilationUnit(config, source, this); - libFiles.forEach(f -> result.addSource(f)); - //loadStepSources(result, Paths.get(stepsDir, "shared")); - //loadStepSources(result, Paths.get(stepsDir)); - return result; - } - - }; - return gcl; - } - private GroovyClassLoader createGroovyClassLoader(URLClassLoader stepsClassLoader) throws FileNotFoundException { String stepsDir = systemConfig.getConfig(DIR_STEPS); @@ -97,6 +74,10 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { Set libFiles = getJavaFileList(Paths.get(stepsDir), null); libFiles.addAll(sharedFiles); + // for (File f : libFiles) { + // logger.info("GroovyClassLoader source {}", f.getAbsolutePath()); + // } + GroovyClassLoader gcl = new GroovyClassLoader(stepsClassLoader) { @Override @@ -149,9 +130,6 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { Class stepClass = null; if (isGroovyClass) { - //kozos classloader hasznalata - //GroovyClassLoader gcl = createGroovyClassLoader(stepsClassLoader, stepUnitName); - stepClass = (Class) loadClassFromSourceCode(groovyClassLoader, stepUnitName); } else stepClass = (Class) stepsClassLoader.loadClass(stepUnitName); @@ -273,10 +251,18 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { String stepsDir = systemConfig.getConfig(DIR_STEPS); Path path = Paths.get(stepsDir, className); - if (!path.toFile().exists()) + File classFile = null; + + //Windows alatt az eleresi utak irasmodja egyforma kell legyen. + //A GroovyClassLoader + //ld. createGroovyClassLoader a new File(path.toFile().getCanonicalPath())-al operal. + classFile = new File(path.toFile().getCanonicalPath()); + logger.info("Class path is normalized to {}", classFile.getCanonicalPath()); + + if (!classFile.exists()) return result; - result = gcl.parseClass(path.toFile()); + result = gcl.parseClass(classFile); if (result != null) logger.info("Class for {} successfully loaded", className); return result; @@ -358,10 +344,23 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { && file.getFileName().toString().endsWith(".java"); try (Stream stream = Files.list(path)) { stream.filter(filter).forEach(p -> { + + boolean add = false; if (excludeFileName == null) - result.add(p.toFile()); + add = true; else if (!excludeFileName.equals(p.getFileName().toString())) - result.add(p.toFile()); + add = true; + + try { + if (add) { + //ha a betoltendo osztaly eleresi utja korabban mas kapitalissal kerul feldolgozasra, hibat kapunk + //ld. loadClassFromSourceCode + File classFile = new File(p.toFile().getCanonicalPath()); + result.add(classFile); + } + } catch (IOException e) { + logger.catching(e); + } }); } catch (Exception e) { @@ -371,20 +370,6 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { return result; } - private void loadStepSources(CompilationUnit compilationUnit, Path path) { - if (path.toFile().isDirectory()) { - Predicate filter = file -> !Files.isDirectory(file) - && file.getFileName().toString().endsWith(".java"); - try (Stream stream = Files.list(path)) { - stream.filter(filter).forEach(p -> { - compilationUnit.addSource(p.toFile()); - }); - } catch (Exception e) { - } - - } - } - private void loadTemplate(Path config) { InputStream stream = null; try {