@Produces
@FXMLLoaderParams
FXMLLoader createCdiFXMLLoader(final InjectionPoint injectionPoint) {
final Annotated annotated = injectionPoint.getAnnotated();
final Class<?> declaringClass = injectionPoint.getMember().getDeclaringClass();
final FXMLLoader loader = new FXMLLoader() {
};
// Uses the currently loaded CDI implementation to look up controller classes
// that have been specified via "fx:controller='...'" in our FXML files.
loader.setControllerFactory((aClass) -> CDI.current().select(aClass));
// If an annotation of type @FXMLLoaderParams can be found, use it's parameters
// to configure the FXMLLoader instance that shall be used to perform the loading
// of the FXML file.
final FXMLLoaderParams fxmlLoaderParams = annotated.getAnnotation(FXMLLoaderParams.class);
if (fxmlLoaderParams != null) {
// Checks the location that has been specified (if any) and uses the default
// class loader to create an URL that points to a FXML file on the classpath.
final String location = fxmlLoaderParams.location();