Class InjectionPointLazyFxControllerAndViewResolver


  • public class InjectionPointLazyFxControllerAndViewResolver
    extends Object
    This class helps to create a generic FxControllerAndView bean factory that can be used for direct injection of FxControllerAndView instances into Spring components, based on generic type inspection.

    To use, define a FxControllerAndView bean factory method like shown below. It is absolutely crucial to define it in prototype scope, since every injection point has to be investigated for its declared generic types!

     @Bean
     public InjectionPointLazyFxControllerAndViewResolver controllerAndViewResolver(FxWeaver fxWeaver) {
         return new InjectionPointLazyFxControllerAndViewResolver(fxWeaver);
     }
    
     @Bean
     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
     public  FxControllerAndView controllerAndView(
             InjectionPointLazyFxControllerAndViewResolver controllerAndViewResolver,
             InjectionPoint injectionPoint) {
         return controllerAndViewResolver.resolve(injectionPoint);
     }
     

    Based on this configuration, a LazyFxControllerAndView instance can be injected directly into a component:

     @Component
     class ArbitraryComponent {
    
         private final FxControllerAndView<SomeController, VBox> someController;
    
         public ArbitraryComponent(FxControllerAndView<SomeController, VBox> someController) {
             this.someController = someController;
         }
     }
     
    Author:
    Rene Gielen