Package net.rgielen.fxweaver.spring
Class InjectionPointLazyFxControllerAndViewResolver
- java.lang.Object
-
- net.rgielen.fxweaver.spring.InjectionPointLazyFxControllerAndViewResolver
-
public class InjectionPointLazyFxControllerAndViewResolver extends Object
This class helps to create a genericFxControllerAndViewbean factory that can be used for direct injection ofFxControllerAndViewinstances into Spring components, based on generic type inspection. To use, define aFxControllerAndViewbean 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) publicFxControllerAndView controllerAndView( InjectionPointLazyFxControllerAndViewResolver controllerAndViewResolver, InjectionPoint injectionPoint) { return controllerAndViewResolver.resolve(injectionPoint); } Based on this configuration, a
LazyFxControllerAndViewinstance 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
-
-
Constructor Summary
Constructors Constructor Description InjectionPointLazyFxControllerAndViewResolver(FxWeaver fxWeaver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <C,V extends javafx.scene.Node>
FxControllerAndView<C,V>resolve(org.springframework.beans.factory.InjectionPoint injectionPoint)Resolve generic type classes of aFxControllerAndViewInjectionPointand return aLazyFxControllerAndViewembedding theFxWeaver.load(Class)method for instance creation.
-
-
-
Constructor Detail
-
InjectionPointLazyFxControllerAndViewResolver
public InjectionPointLazyFxControllerAndViewResolver(FxWeaver fxWeaver)
-
-
Method Detail
-
resolve
public <C,V extends javafx.scene.Node> FxControllerAndView<C,V> resolve(org.springframework.beans.factory.InjectionPoint injectionPoint)
Resolve generic type classes of aFxControllerAndViewInjectionPointand return aLazyFxControllerAndViewembedding theFxWeaver.load(Class)method for instance creation.- Parameters:
injectionPoint- the actual injection point for theFxControllerAndViewto inject- Throws:
IllegalArgumentException- when types could not be resolved from the given injection point
-
-