Friday, March 12, 2010

Advanced Grails stuff

http://agileice.blogspot.com/2009/11/injecting-resources-in-easyb-grails.html

http://archive.grails.codehaus.org/lists/user@grails.codehaus.org/msg/40a20b40710050951w42793b24h9b0c9f80ca66e29c@mail.gmail.com

http://solveme.wordpress.com/2008/08/27/unable-to-install-breakpoint-due-to-missing-line-number-attributes/

http://www.grails.org/doc/1.0.x/ref/Domain%20Classes/save.html

http://www.javaworld.com/community/node/3017  :RESTing easy with Groovy’s HTTPBuilder/RESTClient


http://groovy.codehaus.org/modules/http-builder/doc/index.html :almost all about HttpBuilder


http://mrhaki.blogspot.com/2010/01/grails-goodness-access-grails.html :Access Grails Application in BootStrapAccess Grails Application in BootStrap



Q: How do I get access to the application context from sources in src/groovy?

There is no ApplicationContextHolder class equivalent to ApplicationHolder. To access to a service class called EmailService from a Groovy class in src/groovy, access the Spring bean using:
import org.codehaus.groovy.grails.web.context.ServletContextHolder as SCH
import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes as GA
def ctx = SCH.servletContext.getAttribute(GA.APPLICATION_CONTEXT) def emailService = ctx.emailService
In 1.1 this is simpler:
import org.codehaus.groovy.grails.commons.ApplicationHolder as AH
def ctx = AH.application.mainContext
def emailService = ctx.emailService

No comments:

Post a Comment