0

I'm developing a plugin and trying to properly decouple as much as possible. How would I get the application context of the grails-app that is including my plugin? I have a doWithWebDescriptor that is including a servlet which is being included at the main grails-app context:

/MainApp/servlet-url-pattern

I would like to reference this in the plugin's GSP. What is the appropriate way?

Brandon Lorenz
  • 211
  • 2
  • 13

2 Answers2

1

Add this line to your bootstrap.groovy in init

ApplicationContext appContext = (ApplicationContext)
servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT);

You can also set the context from bootstrap in the class that you are using the app context.

YourClassName.setContext(appContext);
COD3BOY
  • 11,964
  • 1
  • 38
  • 56
srjit
  • 526
  • 11
  • 25
0

I might be wrong here, but I think that doWithWebDescriptor is used to generate the web.xml file. This file is necessary to start up the application. If your application is not up, you can't have a spring context yet.

Luis Muñiz
  • 4,649
  • 1
  • 27
  • 43