在java程序中嵌入swank-clojure
基于 http://github.com/technomancy/swank-clojure 的嵌入部分, 我正在使用以下内容来测试它。有更好的方法吗 这个不使用编译器吗?有没有办法以编程方式 停止炫耀?看来 start-repl 控制了线程。什么 将是为其生成另一个线程并能够的好方法 以编程方式杀死该线程。
import clojure.lang.Compiler;
import java.io.StringReader;
public class Embed {
public static void main(String[] args) throws Exception {
final String startSwankScript =
"(ns my-app\n" +
" (:use [swank.swank :as swank]))\n" +
"(swank/start-repl) ";
Compiler.load(new StringReader(startSwankScript));
}
}
非常感谢任何帮助, 呵呵
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 Compiler? Is there a way to programmatically
stop swank? It seems start-repl takes control of the thread. What
would be a good way to spawn off another thread for it and be able to
kill that thread programatically.
import clojure.lang.Compiler;
import java.io.StringReader;
public class Embed {
public static void main(String[] args) throws Exception {
final String startSwankScript =
"(ns my-app\n" +
" (:use [swank.swank :as swank]))\n" +
"(swank/start-repl) ";
Compiler.load(new StringReader(startSwankScript));
}
}
Any help much appreciated,
hhh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以接受在 Clojure 中实现
Embed
类吗?您可以使用gen-class
来做到这一点(请参阅 Meikel Brandmeyer 的教程了解详细信息)和AOT编译。代码可能类似于
(添加您需要的其他任何内容);然后在应用程序的 Java 部分中,您可以导入 Clojure 准备的类,实例化它并在实例上调用
.startSwank()
。不确定如何以编程方式阻止 Swank...我很想知道自己有什么好方法来做到这一点。 (如果我弄清楚了,我会回来更新;否则,我很想阅读其他人的答案,详细说明如何解决这个问题。)
Would it be acceptable to you to implement the
Embed
class in Clojure? You could do that withgen-class
(see Meikel Brandmeyer's tutorial for details) and AOT compilation.The code could go something like
(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.)