From ec507d04fc9aaec2a6d85378c9ecccd36e6947e8 Mon Sep 17 00:00:00 2001 From: Toby Crawley Date: Wed, 7 Oct 2015 13:33:31 -0400 Subject: [PATCH] Use WF-native singleton support. --- core/src/immutant/daemons.clj | 26 +++++++++++++++----------- project.clj | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/src/immutant/daemons.clj b/core/src/immutant/daemons.clj index 522f1975..3ef4b9ea 100644 --- a/core/src/immutant/daemons.clj +++ b/core/src/immutant/daemons.clj @@ -38,14 +38,18 @@ If used outside of WildFly, or in a WildFly instance not in a cluster, it behaves as if the cluster size is 1, and starts immediatey." [daemon-name start-fn stop-fn] - (doto ^DaemonContext - (WunderBoss/findOrCreateComponent DaemonContext - (name daemon-name) - ;; TODO: expose :stop-timeout - (o/extract-options {:singleon true} - DaemonContext$CreateOption)) - (.setAction start-fn) - (.setStopCallback (reify DaemonContext$StopCallback - (notify [_ _] - (stop-fn)))) - .start)) + (let [actually-ran? (atom false)] + (doto ^DaemonContext + (WunderBoss/findOrCreateComponent DaemonContext + (name daemon-name) + ;; TODO: expose :stop-timeout + (o/extract-options {:singleon true} + DaemonContext$CreateOption)) + (.setAction (fn [] + (reset! actually-ran? true) + (start-fn))) + (.setStopCallback (reify DaemonContext$StopCallback + (notify [_ _] + (when @actually-ran? + (stop-fn))))) + .start))) diff --git a/project.clj b/project.clj index 0079db30..43821780 100644 --- a/project.clj +++ b/project.clj @@ -92,7 +92,7 @@ environ "1.0.0" ;; org.projectodd.wunderboss "0.9.0" - org.projectodd.wunderboss "1.x.incremental.291" + org.projectodd.wunderboss "1.x.incremental.292" ;; org.projectodd.wunderboss "0.9.1-SNAPSHOT" org.immutant :version