Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.core.ResolvableType;

import java.util.Optional;
import java.util.ResourceBundle;

/**
* This class helps to create a generic {@link FxControllerAndView} bean factory that can be used for direct injection
Expand Down Expand Up @@ -48,10 +49,17 @@
*/
public class InjectionPointLazyFxControllerAndViewResolver {

private final FxWeaver fxWeaver;
protected final FxWeaver fxWeaver;

public InjectionPointLazyFxControllerAndViewResolver(FxWeaver fxWeaver) {
protected final ResourceBundle resourceBundle;

public InjectionPointLazyFxControllerAndViewResolver(FxWeaver fxWeaver, ResourceBundle resourceBundle) {
this.fxWeaver = fxWeaver;
this.resourceBundle = resourceBundle;
}

public InjectionPointLazyFxControllerAndViewResolver(FxWeaver fxWeaver) {
this(fxWeaver, null);
}

/**
Expand All @@ -69,14 +77,14 @@ public <C, V extends Node> FxControllerAndView<C, V> resolve(InjectionPoint inje
}
try {
Class<C> controllerClass = (Class<C>) resolvableType.getGenerics()[0].resolve();
return new LazyFxControllerAndView<>(() -> fxWeaver.load(controllerClass));
return new LazyFxControllerAndView<>(() -> fxWeaver.load(controllerClass, resourceBundle));
} catch (Exception e) {
throw new IllegalArgumentException(
"Generic controller type not resolvable for injection point " + injectionPoint, e);
}
}

private ResolvableType findResolvableType(InjectionPoint injectionPoint) {
protected ResolvableType findResolvableType(InjectionPoint injectionPoint) {
return Optional.ofNullable(injectionPoint.getMethodParameter())
.map(ResolvableType::forMethodParameter)
// TODO: Refactor the following to use .or() when dropping Java 8 support
Expand Down