git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorvasary.daniel <TFS\vasary.daniel>
Mon, 20 Sep 2021 13:19:46 +0000 (13:19 +0000)
committervasary.daniel <TFS\vasary.daniel>
Mon, 20 Sep 2021 13:19:46 +0000 (13:19 +0000)
server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java

index a82cd32e91af51bef9d6ad9b9b64ae91d48bc6fe..dc591b012dd235db0baa4c91c427784d3c4165ba 100644 (file)
@@ -67,29 +67,6 @@ public class JobEngineConfiguration implements IJobEngineConfiguration {
                }\r
        }\r
 \r
-       private GroovyClassLoader createGroovyClassLoader(URLClassLoader stepsClassLoader, String excludeFileName)\r
-                       throws FileNotFoundException {\r
-               String stepsDir = systemConfig.getConfig(DIR_STEPS);\r
-\r
-               Set<File> sharedFiles = getJavaFileList(Paths.get(stepsDir, "shared"), excludeFileName);\r
-               Set<File> libFiles = getJavaFileList(Paths.get(stepsDir), excludeFileName);\r
-               libFiles.addAll(sharedFiles);\r
-\r
-               GroovyClassLoader gcl = new GroovyClassLoader(stepsClassLoader) {\r
-\r
-                       @Override\r
-                       protected CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource source) {\r
-                               CompilationUnit result = new CompilationUnit(config, source, this);\r
-                               libFiles.forEach(f -> result.addSource(f));\r
-                               //loadStepSources(result, Paths.get(stepsDir, "shared"));\r
-                               //loadStepSources(result, Paths.get(stepsDir));\r
-                               return result;\r
-                       }\r
-\r
-               };\r
-               return gcl;\r
-       }\r
-\r
        private GroovyClassLoader createGroovyClassLoader(URLClassLoader stepsClassLoader) throws FileNotFoundException {\r
                String stepsDir = systemConfig.getConfig(DIR_STEPS);\r
 \r
@@ -97,6 +74,10 @@ public class JobEngineConfiguration implements IJobEngineConfiguration {
                Set<File> libFiles = getJavaFileList(Paths.get(stepsDir), null);\r
                libFiles.addAll(sharedFiles);\r
 \r
+               //              for (File f : libFiles) {\r
+               //                      logger.info("GroovyClassLoader source {}", f.getAbsolutePath());\r
+               //              }\r
+\r
                GroovyClassLoader gcl = new GroovyClassLoader(stepsClassLoader) {\r
 \r
                        @Override\r
@@ -149,9 +130,6 @@ public class JobEngineConfiguration implements IJobEngineConfiguration {
                Class<IJobStep> stepClass = null;\r
 \r
                if (isGroovyClass) {\r
-                       //kozos classloader hasznalata\r
-                       //GroovyClassLoader gcl = createGroovyClassLoader(stepsClassLoader, stepUnitName);\r
-\r
                        stepClass = (Class<IJobStep>) loadClassFromSourceCode(groovyClassLoader, stepUnitName);\r
                } else\r
                        stepClass = (Class<IJobStep>) stepsClassLoader.loadClass(stepUnitName);\r
@@ -273,10 +251,18 @@ public class JobEngineConfiguration implements IJobEngineConfiguration {
 \r
                String stepsDir = systemConfig.getConfig(DIR_STEPS);\r
                Path path = Paths.get(stepsDir, className);\r
-               if (!path.toFile().exists())\r
+               File classFile = null;\r
+\r
+               //Windows alatt az eleresi utak irasmodja egyforma kell legyen.\r
+               //A GroovyClassLoader\r
+               //ld. createGroovyClassLoader a new File(path.toFile().getCanonicalPath())-al operal.\r
+               classFile = new File(path.toFile().getCanonicalPath());\r
+               logger.info("Class path is normalized to {}", classFile.getCanonicalPath());\r
+\r
+               if (!classFile.exists())\r
                        return result;\r
 \r
-               result = gcl.parseClass(path.toFile());\r
+               result = gcl.parseClass(classFile);\r
                if (result != null)\r
                        logger.info("Class for {} successfully loaded", className);\r
                return result;\r
@@ -358,10 +344,23 @@ public class JobEngineConfiguration implements IJobEngineConfiguration {
                                        && file.getFileName().toString().endsWith(".java");\r
                        try (Stream<Path> stream = Files.list(path)) {\r
                                stream.filter(filter).forEach(p -> {\r
+\r
+                                       boolean add = false;\r
                                        if (excludeFileName == null)\r
-                                               result.add(p.toFile());\r
+                                               add = true;\r
                                        else if (!excludeFileName.equals(p.getFileName().toString()))\r
-                                               result.add(p.toFile());\r
+                                               add = true;\r
+\r
+                                       try {\r
+                                               if (add) {\r
+                                                       //ha a betoltendo osztaly eleresi utja korabban mas kapitalissal kerul feldolgozasra, hibat kapunk\r
+                                                       //ld. loadClassFromSourceCode\r
+                                                       File classFile = new File(p.toFile().getCanonicalPath());\r
+                                                       result.add(classFile);\r
+                                               }\r
+                                       } catch (IOException e) {\r
+                                               logger.catching(e);\r
+                                       }\r
 \r
                                });\r
                        } catch (Exception e) {\r
@@ -371,20 +370,6 @@ public class JobEngineConfiguration implements IJobEngineConfiguration {
                return result;\r
        }\r
 \r
-       private void loadStepSources(CompilationUnit compilationUnit, Path path) {\r
-               if (path.toFile().isDirectory()) {\r
-                       Predicate<Path> filter = file -> !Files.isDirectory(file)\r
-                                       && file.getFileName().toString().endsWith(".java");\r
-                       try (Stream<Path> stream = Files.list(path)) {\r
-                               stream.filter(filter).forEach(p -> {\r
-                                       compilationUnit.addSource(p.toFile());\r
-                               });\r
-                       } catch (Exception e) {\r
-                       }\r
-\r
-               }\r
-       }\r
-\r
        private void loadTemplate(Path config) {\r
                InputStream stream = null;\r
                try {\r