I have a Clojure library that I would like to use in Java, but I'm having trouble getting the correct class generated. I would like to generate a class that is effectively:
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) { /* ... */ }
}
Here's what I'm trying to do in 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)))))
But when I try to compile it, I get:
: 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)
Can anybody give me a simple example of how to do this?