5050
5151import javax .servlet .ServletContext ;
5252import java .io .IOException ;
53- import java .util .Collection ;
54- import java .util .Iterator ;
55- import java .util .List ;
56- import java .util .Properties ;
53+ import java .util .*;
5754
5855/**
5956 * A class that handles the runtime configuration of the Grails ApplicationContext
@@ -264,13 +261,17 @@ public WebApplicationContext configure(ServletContext context, boolean loadExter
264261
265262 this .pluginManager .registerProvidedArtefacts (application );
266263
264+ registerParentBeanFactoryPostProcessors (springConfig );
265+
267266 this .pluginManager .doRuntimeConfiguration (springConfig );
268267
269268 // configure scaffolding
270269 LOG .debug ("[RuntimeConfiguration] Proccessing additional external configurations" );
271270
272- if (loadExternalBeans )
271+ if (loadExternalBeans ) {
273272 doPostResourceConfiguration (application ,springConfig );
273+ }
274+
274275
275276 // TODO GRAILS-720 this causes plugin beans to be re-created - should get getApplicationContext always call refresh?
276277 WebApplicationContext ctx = (WebApplicationContext ) springConfig .getApplicationContext ();
@@ -289,6 +290,18 @@ public WebApplicationContext configure(ServletContext context, boolean loadExter
289290 return ctx ;
290291 }
291292
293+ private void registerParentBeanFactoryPostProcessors (WebRuntimeSpringConfiguration springConfig ) {
294+ if (parent != null ) {
295+ Map parentPostProcessors = parent .getBeansOfType (BeanFactoryPostProcessor .class );
296+ for (Iterator i = parentPostProcessors .values ().iterator (); i .hasNext ();) {
297+ BeanFactoryPostProcessor postProcessor = (BeanFactoryPostProcessor ) i .next ();
298+ ((ConfigurableApplicationContext ) springConfig .getUnrefreshedApplicationContext ())
299+ .addBeanFactoryPostProcessor (postProcessor );
300+
301+ }
302+ }
303+ }
304+
292305 public void reconfigure (GrailsApplicationContext current , ServletContext servletContext , boolean loadExternalBeans ) {
293306 RuntimeSpringConfiguration springConfig = parent != null ? new DefaultRuntimeSpringConfiguration (parent ) : new DefaultRuntimeSpringConfiguration ();
294307 if (!this .pluginManager .isInitialised ())
0 commit comments