#998 - WebMvcHateoasConfiguration now delays a beans-of-type lookup.

We now delay the lookup of RepresentationModelProcessor instances in WebMvcHateoasConfiguration so that the BeanPostProcessor registered does now not trigger eager initialization of downstream beans.
This commit is contained in:
Oliver Drotbohm
2019-06-05 19:50:11 +02:00
parent c12ed413da
commit 6575a8ddae
3 changed files with 26 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ import lombok.RequiredArgsConstructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.function.Supplier;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
@@ -60,7 +61,7 @@ public class RepresentationModelProcessorHandlerMethodReturnValueHandler impleme
}
private final @NonNull HandlerMethodReturnValueHandler delegate;
private final @NonNull RepresentationModelProcessorInvoker invoker;
private final @NonNull Supplier<RepresentationModelProcessorInvoker> invoker;
private boolean rootLinksAsHeaders = false;
@@ -122,7 +123,7 @@ public class RepresentationModelProcessorHandlerMethodReturnValueHandler impleme
targetType = returnValueType;
}
RepresentationModel<?> result = invoker.invokeProcessorsFor((RepresentationModel) value, targetType);
RepresentationModel<?> result = invoker.get().invokeProcessorsFor((RepresentationModel) value, targetType);
delegate.handleReturnValue(rewrapResult(result, returnValue), returnType, mavContainer, webRequest);
}