On Mon, Dec 15, 2014 at 10:12 PM, Thiago H de Paula Figueiredo < thiag...@gmail.com> wrote:
> On Mon, 15 Dec 2014 17:34:10 -0200, Ilya Obshadko <ilya.obsha...@gmail.com> > wrote: > > ServiceBuilder's buildService() receives a ServiceResources instance as a >>> parameter. ServiceResources is an ObjectLocator (i.e. Tapestry-IoC >>> registry). >>> >> >> The wording of my question was not fully correct. tapestry-clojure >> doesn't use ServiceBuilder, but rather its own ClojureBuilder (which does >> the job >> of creating service proxy and binding service interface methods to >> Clojure> functions in a given namespace). >> > > I also noticed, after sending my answer, that it wasn't very good, due to > my lack of Clojure knowledge (yet! :)). > > One way to do that is to have special interface method, bound to Clojure >> function, which can perform necessary injection by using mutable objects >> in Clojure code. But that doesn't look like a functional way. >> > > How are Java objects usually passed to Clojure code? The recommended way? Java objects are passed to Clojure functions in exactly the same way they are passed to Java method (because internally Clojure function is just an implementation of IFn interface, and function call is invoke(...) on its instance). But I don't want to pass services to Clojure functions, I'd like to inject them into Clojure namespace when clojure.core/require is executed. By itself, clojure.core/require doesn't allow passing arbitrary arguments that might be used later inside the namespace. So I'm not yet sure about correct way to approach this. I would like Howard to elaborate on this topic, because I'm currently >> researching various options and yet none of them looks quite right. But I >> don't have much experience in Clojure, so I might be missing something >> obvious. >> > > Your suggested code hints at a Clojure function, provided by Tapestry, > that would somehow provide access to services through the registry. I guess > you're in the right path. -- Ilya Obshadko