Hello all, long time listener first time caller.
I've got a situation where I'm trying to apply some Groovy code
against a clojure hashmap.
I've got:
(ns neat
(:import (java.sql Timestamp)
(groovy.lang Binding GroovyShell)
(oracle.sql TIMESTAMP Datum)
(java.util.concurrent Executors ThreadFactory ThreadPoolExecutor
TimeUnit LinkedBlockingQueue ArrayBlockingQueue FutureTask)
(java.util TreeMap TreeSet Map Set List ArrayList Calendar
GregorianCalendar TimeZone))
(:use (clojure.contrib sql string def logging)))
to bring in GroovyShell and binding objects.
I try to use this as:
(defn execute-groovy [event current-rule rule-list]
(let [groovy_script (:groovy_script current-rule)]
(if (nil? groovy_script)
event
(let [groovy-binding (new Binding)]
(.setVariable groovy-binding "rule" current-rule)
(.setVariable groovy-binding "update" (:response event {}))
(.setVariable groovy-binding "event" event)
(.setVariable groovy-binding "ruleList" rule-list)
(let [groovy-shell (new GroovyShell groovy-binding)]
(.evaluate groovy-shell groovy_script)
(merge event {:response (merge (:response event {})
{:groovy_script (conj (:groovy_script
(:response event {})
(list)) (:id current-rule))}
(.getVariable groovy-binding
"update"))})
)))))
This worked in one version of the code where I didn't use an ns but instead did:
(import '(groovy.lang Binding GroovyShell))
into user.
The problem is I get the following error when I use it within the namespace:
No matching method found: evaluate for class groovy.lang.GroovyShell
I don't think this has anything to do with Groovy. For some reason the
code doesn't want to use groovy-shell as a GroovyShell.
I can also do:
(.evaluate (GroovyShell.) "1+1")
in the REPL while in the neat ns.
Any ideas?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en