On Sun, Dec 14, 2014 at 9:17 PM, Thiago H de Paula Figueiredo < thiag...@gmail.com> wrote:
> On Sat, 13 Dec 2014 17:48:09 -0200, Ilya Obshadko <ilya.obsha...@gmail.com> > wrote: > > I have a question regarding potential Clojure integration in my >> application >> service layer. As of now, standard Tapestry mechanism of dependency >> injection won't work for Clojure-based services, because it's constructed >> using ServiceBuilder and there is no implementation class. >> > > 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). 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. 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. > I understand that it probably cannot be solved directly, but what >> alternative scenarios do we have at our disposal? >> >> One of them is probably a custom service builder. Any others? >> > > You can use builder methods (YourService buildYourService()) or > bind(Class<T> serviceInterface, ServiceBuilder<T> builder). Pass the > services you want to your Clojure code as objects. -- Ilya Obshadko