Class LazyBean<T>
- java.lang.Object
-
- org.springframework.cloud.sleuth.internal.LazyBean<T>
-
public final class LazyBean<T> extends Object
Avoids calling the expensiveBeanFactory.getBean(Class)
many times or throwing an exception.Note: This is an internal class to sleuth and must not be used by external code.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> LazyBean<T>
create(org.springframework.context.ConfigurableApplicationContext springContext, Class<T> requiredType)
T
get()
Attempts to provision from the underlying bean factory, if not already provisioned.T
getOrError()
Attempts to provision from the underlying bean factory, if not already provisioned.
-
-
-
Method Detail
-
create
public static <T> LazyBean<T> create(org.springframework.context.ConfigurableApplicationContext springContext, Class<T> requiredType)
-
get
@Nullable public T get()
Attempts to provision from the underlying bean factory, if not already provisioned.- Returns:
- the bean value or null if there was an exception getting it.
-
getOrError
public T getOrError()
Attempts to provision from the underlying bean factory, if not already provisioned.- Returns:
- the bean value. This variant does not catch exception.
-
-