Embedding swank-clojure in java program

前端 未结 1 1222
难免孤独
难免孤独 2021-02-09 19:47

Based on the Embedding section of http://github.com/technomancy/swank-clojure, I\'m using the following to test it out. Is there a better way to do this that doesn\'t use Com

1条回答
  •  太阳男子
    2021-02-09 19:55

    Would it be acceptable to you to implement the Embed class in Clojure? You could do that with gen-class (see Meikel Brandmeyer's tutorial for details) and AOT compilation.

    The code could go something like

    (ns your-app.Embed
      (:require [swank.swank :as swank])
      (:gen-class
       :methods [[startSwank [] void]]))
    
    (defn -startSwank []
      (swank/start-repl))
    

    (add anything else you require); then in the Java part of your application, you could import your Clojure-prepared class, instantiate it and call .startSwank() on the instance.

    Not sure about programmatically stopping Swank... I'd be curious to know of a good way to do that myself. (And I'll be back with an update if I figure it out; otherwise, I'd love to read somebody else's answer detailing how to go about that.)

    0 讨论(0)
提交回复
热议问题