Toshiaki Maki opened SPR-15219 and commented
Router functions are actually available without ApplicationContext for very small footprint applications, but UrlBasedViewResolver calls getApplicationContext().getAutowireCapableBeanFactory().
This causes NullPointerException if i use router functions and freemaker without ApplicationContext.
private View applyLifecycleMethods(String viewName, AbstractView view) {
return (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
}
|
private View applyLifecycleMethods(String viewName, AbstractView view) { |
|
return (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName); |
|
} |
I'd be happy if these are decoupled.
Easiest way might be using lifecycleMethods as a BiFunction like following:
private BiFunction<String, AbstractView, View> lifecycleMethods = (viewName,
view) -> (View) getApplicationContext().getAutowireCapableBeanFactory()
.initializeBean(view, viewName);
public void setLifecycleMethods(
BiFunction<String, AbstractView, View> lifecycleMethods) {
this.lifecycleMethods = lifecycleMethods;
}
private View applyLifecycleMethods(String viewName, AbstractView view) {
return lifecycleMethods.apply(viewName, view);
}
I'm using this hack as a workarround.
https://github.com/making/ik.am/tree/622b1c289ea4273210d4bc0a1a905fa890e8b1b7/src/main/java/am/ik/FreeMarkerConfig.java
https://github.com/making/ik.am/blob/622b1c289ea4273210d4bc0a1a905fa890e8b1b7/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java
Affects: 5.0 M4
Issue Links:
Referenced from: commits 14161d1
1 votes, 3 watchers
Toshiaki Maki opened SPR-15219 and commented
Router functions are actually available without
ApplicationContextfor very small footprint applications, butUrlBasedViewResolvercallsgetApplicationContext().getAutowireCapableBeanFactory().This causes
NullPointerExceptionif i use router functions and freemaker withoutApplicationContext.spring-framework/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java
Lines 250 to 252 in fafd2d2
I'd be happy if these are decoupled.
Easiest way might be using
lifecycleMethodsas aBiFunctionlike following:I'm using this hack as a workarround.
https://github.com/making/ik.am/tree/622b1c289ea4273210d4bc0a1a905fa890e8b1b7/src/main/java/am/ik/FreeMarkerConfig.java
https://github.com/making/ik.am/blob/622b1c289ea4273210d4bc0a1a905fa890e8b1b7/src/main/java/org/springframework/web/reactive/result/view/UrlBasedViewResolver.java
Affects: 5.0 M4
Issue Links:
Referenced from: commits 14161d1
1 votes, 3 watchers