我有一个Clojure库,想在Java中使用,但是我遇到了生成正确类的问题。我希望生成一个有效的类:
public class TokenStore {
public static TokenStore Sns(Map<String, String> services) { /* ... */ }
public String addToken(String token, String username, String service) { /* ... */ }
public String findToken(String username, String service) { /* ... */ }
public String sendNotification(String username, String service, String message) { /* ... */ }
}
我在Clojure中要做的事情如下:
(ns my.lib.token-java
(:require [my.lib.token :refer :all])
(:gen-class
:name my.lib.TokenStore
:methods [#^{:static true} [Sns [java.util.Map] TokenStore]]))
(defprotocol TokenStore
(addToken [this token username service])
(findToken [this username service])
(sendNotification [this username service message]))
(defn -Sns [services]
(let [ts (token-store (apply concat (for [[k v] (into {} coll)] [(keyword k) v]))]
(reify TokenStore
(addToken [this token username service]
(add-token this token username service))
(findToken [this username service]
(find-token this username service))
(sendNotification [this username service message]
(send-notification this username service message)))))
但是当我尝试编译它时,我遇到了以下问题:
: jmglov@alhana; lein jar
Compiling orron-iii.push-java
Exception in thread "main" java.lang.ClassNotFoundException: java.lang.TokenStore, compiling:(orron_iii/push_java.clj:1:1)
能否给我一个简单的例子来说明如何做到这一点?