From c9796ca0d99f49d5ae1854d5a4d37219bf5be362 Mon Sep 17 00:00:00 2001 From: Cam Saul Date: Mon, 9 Jul 2018 12:24:12 -0700 Subject: [PATCH] Clojure implementation of DynamicClassLoadHelper Hi, not sure whether you or others might find this handy but here's your example `DynamicClassLoadHelper` class translated to Clojure and working as verified to be working as expected. Personally I'd rather keep my Clojure projects pure Clojure when possible so perhaps adding this implementation as a reference could save others the trouble from having to figure out how to do it --- articles/durable_quartz_stores.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/articles/durable_quartz_stores.md b/articles/durable_quartz_stores.md index 5ff6fe1..d0fc4dd 100644 --- a/articles/durable_quartz_stores.md +++ b/articles/durable_quartz_stores.md @@ -61,26 +61,25 @@ To allow Quartz to see classes the Clojure compiler generates, we must provide a custom implementation of the ClassLoadHelper class which Quartz uses for discovering classes. A working implementation is below: -``` java -// Example package -package oceania.myservice.quartz; +```clj +;; example namespace +(ns oceania.myservice.quartz.DynamicClassLoadHelper + (:gen-class + :extends clojure.lang.DynamicClassLoader + :exposes-methods {loadClass superLoadClass} + :implements [org.quartz.spi.ClassLoadHelper])) -import clojure.lang.DynamicClassLoader; -import org.quartz.spi.ClassLoadHelper; +(defn -initialize [_]) -public class DynamicClassLoadHelper extends DynamicClassLoader implements ClassLoadHelper { - public void initialize() {} +(defn -loadClass + ([^oceania.myservice.quartz.DynamicClassLoadHelper this, ^String class-name] + (.superLoadClass this class-name true)) ; loadClass(String name, boolean resolve) + ([^oceania.myservice.quartz.DynamicClassLoadHelper this, ^String class-name, _] + (.superLoadClass this class-name true))) - @SuppressWarnings("unchecked") - public Class loadClass(String name, Class clazz) - throws ClassNotFoundException { - return (Class) loadClass(name); - } +(defn -getClassLoader [this] + this) - public ClassLoader getClassLoader() { - return this; - } -} ```