Created
July 3, 2012 12:39
-
-
Save lstoll/3039506 to your computer and use it in GitHub Desktop.
Wrapped Java API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Creates the wrapped object. | |
(def domain (JavaWrapper. (.domainLookupByID (conn "test:///default") 1)) | |
;; Implements ILookup, so you can call getters by invoking a keyword | |
(:name domain) = (.getName domain) | |
;; Implements Associative, so you can invoke setters via assoc | |
(assoc domain autostart true) = (.setAutostart domain true) | |
;; Original Java object accessible via :o key | |
(:o domain) | |
=> #<Domain...> | |
;; Macro provided, to create clojure function that can invoke the Java function on the wrapped object | |
(defwrapperfn create) | |
(create domain) = (.create domain) or the the wrapped case, (.create (:o domain)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment