Monday, June 30, 2014

Grails get bean/service from service or other class

import org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib
import grails.util.Holders
import org.codehaus.groovy.grails.commons.GrailsApplication

public static GrailsApplication grailsApplication = Holders.grailsApplication;
public static ServletContext servletContext = Holders.servletContext;
public static ApplicationTagLib g = Holders.applicationContext.getBean("org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib")

def bean = Holders.applicationContext.getBean(beanIdentifier);
// beanIdentifier = userService, groupService etc...

No comments:

Post a Comment