diff --git a/src/clj/job_streamer/control_bus/component/apps.clj b/src/clj/job_streamer/control_bus/component/apps.clj index 6c66689..8765269 100644 --- a/src/clj/job_streamer/control_bus/component/apps.clj +++ b/src/clj/job_streamer/control_bus/component/apps.clj @@ -51,11 +51,18 @@ classpaths)) proc (.exec (Runtime/getRuntime) cmd)] (log/debug (clojure.string/join " " cmd)) + (letfn [(print-err [] + (with-open [rdr (io/reader (.getErrorStream proc))] + (->> (line-seq rdr) + (map #(log/error %)) + doall)))] + (.start (Thread. print-err))) (with-open [rdr (io/reader (.getInputStream proc))] (->> (line-seq rdr) (map #(clojure.string/split % #":" 2)) (map (fn [[category class-name]] - {(keyword "batch-component" category) class-name})) + (let [c {(keyword "batch-component" category) class-name}] + (log/debugf "%s was scaned." (pr-str c)) c))) (reduce #(merge-with conj %1 %2) {:batch-component/batchlet [] :batch-component/item-reader [] diff --git a/src/java/net/unit8/job_streamer/control_bus/BatchComponentScanner.java b/src/java/net/unit8/job_streamer/control_bus/BatchComponentScanner.java index efe5e17..28f15e1 100644 --- a/src/java/net/unit8/job_streamer/control_bus/BatchComponentScanner.java +++ b/src/java/net/unit8/job_streamer/control_bus/BatchComponentScanner.java @@ -67,8 +67,8 @@ Set jarEntryNames(File zipFile) throws IOException { } String decideRefName(Class clazz) { - System.err.println(clazz); - System.err.println(clazz.getAnnotations()); + System.err.println("decideRefName: clazz: " + clazz); + System.err.println("decideRefName: annotation: " + clazz.getAnnotations()); Annotation[] annotations = clazz.getDeclaredAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof Named && !Strings.isNullOrEmpty(((Named) annotation).value())) { @@ -83,29 +83,41 @@ void pickOverBatchComponent(String resourcePath, ClassLoader cl) { String className = resourcePath .substring(0, resourcePath.lastIndexOf(".class")) .replace('/', '.').replace('\\', '.'); + System.err.println("className: " + className); if (className.startsWith("java.") || className.startsWith("javax.") || className.startsWith("com.sun.") || className.startsWith("sun.") || className.startsWith("clojure.")) { + System.err.println("This is ignored with wrong package name"); return; } try { Class clazz = cl.loadClass(className); if (Batchlet.class.isAssignableFrom(clazz)) { - container.batchlets.add(decideRefName(clazz)); + System.err.println(" This clazz is Batchlet"); + container.batchlets.add(decideRefName(clazz)); } else if (ItemReader.class.isAssignableFrom(clazz)) { - container.itemReaders.add(decideRefName(clazz)); + System.err.println(" This clazz is ItemReader"); + container.itemReaders.add(decideRefName(clazz)); } else if (ItemWriter.class.isAssignableFrom(clazz)) { - container.itemWriters.add(decideRefName(clazz)); + System.err.println(" This clazz is ItemWriter"); + container.itemWriters.add(decideRefName(clazz)); } else if (ItemProcessor.class.isAssignableFrom(clazz)) { - container.itemProcessors.add(decideRefName(clazz)); + System.err.println(" This clazz is ItemProcessor"); + container.itemProcessors.add(decideRefName(clazz)); } else if (isListener(clazz)) { - container.listeners.add(decideRefName(clazz)); + System.err.println(" This clazz is Listener"); + container.listeners.add(decideRefName(clazz)); } else if (Throwable.class.isAssignableFrom(clazz)) { - container.throwables.add(decideRefName(clazz)); + System.err.println(" This clazz is Throwable"); + container.throwables.add(decideRefName(clazz)); + } else { + System.err.println(" This clazz is ignored"); } } catch (ClassNotFoundException | NoClassDefFoundError e) { + System.err.println(" This clazz is ignored with Exception"); + e.printStackTrace(); // ignore } }