6 Spring Beans For Namespaces
Version: 2.0.0.RC4
6 Spring Beans For Namespaces
The plugin can create Spring beans that provide access to Clojure functions. Each function namespace can be associated with a different Spring bean.Function namespaces are associated with Spring bean names that are defined inapplication.yml
. Key value pairs under grails.clojure.namespaceBeans
associate function namespaces with Spring bean names.;; src/main/clj/mathematics.clj (ns math)(def doit [] ;; doit code here )
;; src/main/clj/reporting.clj (ns report)(def doit [] ;; doit code here )
# grails-app/conf/application.ymlgrails: clojure: namespaceBeans: math: mathHelper report: reportHelper
mathHelper
and reportHelper
which are associated with the math
and report
namespaces respectively.// grails-app/controllers/demo/DemoController.groovy package democlass DemoController { def mathHelper def reportHelper def someAction() { // this will invoke the doit function in the math namespace mathHelper.doit() // … } def someOtherAction() { // this will invoke the doit function in the report namespace reportHelper.doit() // … }}