3939import org .codehaus .groovy .grails .documentation .DocumentationContext ;
4040import org .springframework .beans .BeanWrapper ;
4141import org .springframework .beans .BeanWrapperImpl ;
42+ import org .springframework .beans .factory .config .BeanFactoryPostProcessor ;
43+ import org .springframework .beans .factory .config .ConfigurableListableBeanFactory ;
4244import org .springframework .context .ApplicationContext ;
45+ import org .springframework .context .support .GenericApplicationContext ;
4346import org .springframework .core .io .Resource ;
4447import org .springframework .core .io .support .PathMatchingResourcePatternResolver ;
4548import org .springframework .core .type .filter .TypeFilter ;
@@ -1043,6 +1046,16 @@ private void callEvent(Closure closureHook, Map event) {
10431046 private void invokeOnChangeListener (Map event ) {
10441047 onChangeListener .setDelegate (this );
10451048 onChangeListener .call (new Object []{event });
1049+
1050+ // Apply any factory post processors in case the change listener has changed any
1051+ // bean definitions (GRAILS-5763)
1052+ if (applicationContext instanceof GenericApplicationContext ) {
1053+ GenericApplicationContext ctx = (GenericApplicationContext ) applicationContext ;
1054+ ConfigurableListableBeanFactory beanFactory = ctx .getBeanFactory ();
1055+ for (BeanFactoryPostProcessor postProcessor : ctx .getBeanFactoryPostProcessors ()) {
1056+ postProcessor .postProcessBeanFactory (beanFactory );
1057+ }
1058+ }
10461059 }
10471060
10481061 public void doArtefactConfiguration () {
@@ -1090,4 +1103,4 @@ public Collection<? extends TypeFilter> getTypeFilters() {
10901103 return this .typeFilters ;
10911104 }
10921105
1093- }
1106+ }
0 commit comments