code: public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
          this.applicationContext = applicationContext;
          setGrailsApplication(applicationContext.getBean(GrailsApplication.APPLICATION_ID, GrailsApplication.class));
          setPluginManager( applicationContext.containsBean(GrailsPluginManager.BEAN_NAME) ? applicationContext.getBean(GrailsPluginManager.BEAN_NAME, GrailsPluginManager.class) : null);
      }
docs: Set the ApplicationContext that this object runs in.
  Normally this call will be used to initialize the object.
  <p>Invoked after population of normal bean properties but before an init callback such
  as {@link org.springframework.beans.factory.InitializingBean#afterPropertiesSet()}
  or a custom init-method. Invoked after {@link org.springframework.context.ResourceLoaderAware#setResourceLoader},
  {@link org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher} and
  {@link org.springframework.context.MessageSourceAware}, if applicable.
  
  @param applicationContext the ApplicationContext object to be used by this object
  @throws org.springframework.context.ApplicationContextException
  in case of context initialization errors
  @throws org.springframework.beans.BeansException
  if thrown by application context methods
  @see org.springframework.beans.factory.BeanInitializationException