Skip to content

Commit

Permalink
Use WF-native singleton support.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Oct 9, 2015
1 parent 125183d commit ec507d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions core/src/immutant/daemons.clj
Expand Up @@ -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)))
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -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
Expand Down

0 comments on commit ec507d0

Please sign in to comment.