From f99e25259b16637fb07284832861033912a42858 Mon Sep 17 00:00:00 2001 From: Sweidan Omar Date: Wed, 8 Dec 2021 13:12:23 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C32515 --- .../server/IJobEngineConfiguration.java | 2 +- .../server/JobEngineConfiguration.java | 48 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/IJobEngineConfiguration.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/IJobEngineConfiguration.java index 9c18761e..2d9bdbd3 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/IJobEngineConfiguration.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/IJobEngineConfiguration.java @@ -31,7 +31,7 @@ public interface IJobEngineConfiguration { void loadSchedules() throws Exception; - String loadTemplateXml(String template); + String loadTemplateJson(String template); void resetStepClassLoader(); 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 dc591b01..c4873390 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 @@ -74,9 +74,9 @@ 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()); - // } + // for (File f : libFiles) { + // logger.info("GroovyClassLoader source {}", f.getAbsolutePath()); + // } GroovyClassLoader gcl = new GroovyClassLoader(stepsClassLoader) { @@ -84,8 +84,8 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { 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)); + // loadStepSources(result, Paths.get(stepsDir, "shared")); + // loadStepSources(result, Paths.get(stepsDir)); return result; } @@ -151,7 +151,7 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { URL[] urls = { path.toUri().toURL() }; stepsClassLoader = URLClassLoader.newInstance(urls, Thread.currentThread().getContextClassLoader()); } catch (FileNotFoundException e) { - //nincs jobs/classes mappa + // nincs jobs/classes mappa URL[] urls = {}; stepsClassLoader = URLClassLoader.newInstance(urls, Thread.currentThread().getContextClassLoader()); } @@ -253,9 +253,10 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { Path path = Paths.get(stepsDir, className); File classFile = null; - //Windows alatt az eleresi utak irasmodja egyforma kell legyen. - //A GroovyClassLoader - //ld. createGroovyClassLoader a new File(path.toFile().getCanonicalPath())-al operal. + // 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()); @@ -285,11 +286,11 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { if (!executors.containsKey(unitName)) { logger.info("Executor now registered for {}", unitName); executors.put(unitName, executor); - //az uj vegrehajtokat el is kell inditani + // az uj vegrehajtokat el is kell inditani if (autoStart) executor.startup(); } else { - //logger.info("Executor already registered for {}", unitName); + // logger.info("Executor already registered for {}", unitName); IJobStepExecutor stepExecutor = executors.get(unitName); int currentMaxConcurrent = stepExecutor.getMaxConcurrent(); int newMaxConcurrent = executor.getMaxConcurrent(); @@ -316,7 +317,7 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { @Override public void loadSchedules() throws Exception { - //a kulcs nem lehet a template, mert kulonbozo parameterekkel is benne lehet! + // a kulcs nem lehet a template, mert kulonbozo parameterekkel is benne lehet! schedules.clear(); String configFilePath = systemConfig.getConfig(JobEngineConfiguration.CONF_SCHEDULES); logger.info("Loading scheduler configuration file {}", configFilePath); @@ -326,9 +327,9 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { scheduleJobs.forEach(o -> { try { BasicDBObject j = (BasicDBObject) o; - String template = j.getString("template"); - String xml = loadTemplateXml(template); - j.put("xml", xml); + String template = j.getString("schedules"); + String json = loadTemplateJson(template); + j.put("json", json); schedules.put(template, j); } catch (Exception e) { logger.error("Scheduled job error! {}", e.getMessage()); @@ -353,8 +354,9 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { try { if (add) { - //ha a betoltendo osztaly eleresi utja korabban mas kapitalissal kerul feldolgozasra, hibat kapunk - //ld. loadClassFromSourceCode + // 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); } @@ -373,9 +375,9 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { private void loadTemplate(Path config) { InputStream stream = null; try { - // byte[] xmlBytes = Files.readAllBytes(config); - // String xml = new String(xmlBytes); - // stream = new ByteArrayInputStream(xmlBytes); + // byte[] xmlBytes = Files.readAllBytes(config); + // String xml = new String(xmlBytes); + // stream = new ByteArrayInputStream(xmlBytes); stream = Files.newInputStream(config); String fileName = config.getFileName().toString(); Parser parser = new Parser(stream); @@ -419,12 +421,12 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { } @Override - public String loadTemplateXml(String template) { + public String loadTemplateJson(String template) { String result = null; try { Path templatesPath = Paths.get(systemConfig.getConfig(DIR_TEMPLATES)); - byte[] xmlBytes = Files.readAllBytes(Paths.get(templatesPath.toString(), template)); - result = new String(xmlBytes); + byte[] jsonBytes = Files.readAllBytes(Paths.get(templatesPath.toString(), template)); + result = new String(jsonBytes); } catch (Exception e) { logger.error(e.getClass().getSimpleName() + ": " + e.getMessage()); } -- 2.54.0