I have a lot of spring beans that enscapsulate existing business logic. Now I am looking to re-use those Spring Beans from within my new Clojure Compojure application. How do I do this ?
What I am looking for is Clojure equivalent of this
Context context = new ClassPathXmlApplicationContext(....);
MyBean mybean = context.get("mybean", MyBean.class)
Is there a Clojure way of doing this ?
(let [context (ClassPathXmlApplicationContext. ...)
mybean (.get context "mybean" MyBean)]
...)
is the Clojure equivalent of your Java code. ...
is whatever you want to do next. Or if you want to return mybean
as the value of the whole thing (perhaps this will be wrapped in a function):
(let [context (ClassPathXmlApplicationContext. ...)]
(.get context "mybean" MyBean))
Note the dot at the end of ClassPathXmlApplicationContext.
; that's shorthand for new
, as in (new ClassPathXmlApplicationContext ...)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With