Skip to content

Commit 66c306c

Browse files
author
graeme
committed
fix for GRAILS-1756
git-svn-id: https://svn.codehaus.org/grails/trunk@6702 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent fb360ea commit 66c306c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/commons/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@
5050

5151
import javax.servlet.ServletContext;
5252
import 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

Comments
 (0)