Interface SpringFactoriesLoader.FailureHandler
- Enclosing class:
- SpringFactoriesLoader
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy for handling a failure that occurs when instantiating a factory.
- Since:
- 6.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidhandleFailure(Class<?> factoryType, String factoryImplementationName, Throwable failure) Handle thefailurethat occurred when instantiating thefactoryImplementationNamethat was expected to be of the givenfactoryType.handleMessage(BiConsumer<Supplier<String>, Throwable> messageHandler) Return a newSpringFactoriesLoader.FailureHandlerthat handles errors with using a standard formatted message.Return a newSpringFactoriesLoader.FailureHandlerthat handles errors by logging trace messages.throwing()Return a newSpringFactoriesLoader.FailureHandlerthat handles errors by throwing anIllegalArgumentException.throwing(BiFunction<String, Throwable, ? extends RuntimeException> exceptionFactory) Return a newSpringFactoriesLoader.FailureHandlerthat handles errors by throwing an exception.
-
Method Details
-
handleFailure
Handle thefailurethat occurred when instantiating thefactoryImplementationNamethat was expected to be of the givenfactoryType.- Parameters:
factoryType- the type of the factoryfactoryImplementationName- the name of the factory implementationfailure- the failure that occurred- See Also:
-
throwing
Return a newSpringFactoriesLoader.FailureHandlerthat handles errors by throwing anIllegalArgumentException.- Returns:
- a new
SpringFactoriesLoader.FailureHandlerinstance
-
throwing
static SpringFactoriesLoader.FailureHandler throwing(BiFunction<String, Throwable, ? extends RuntimeException> exceptionFactory) Return a newSpringFactoriesLoader.FailureHandlerthat handles errors by throwing an exception.- Parameters:
exceptionFactory- factory used to create the exception- Returns:
- a new
SpringFactoriesLoader.FailureHandlerinstance
-
logging
Return a newSpringFactoriesLoader.FailureHandlerthat handles errors by logging trace messages.- Parameters:
logger- the logger used to log message- Returns:
- a new
SpringFactoriesLoader.FailureHandlerinstance
-
handleMessage
static SpringFactoriesLoader.FailureHandler handleMessage(BiConsumer<Supplier<String>, Throwable> messageHandler) Return a newSpringFactoriesLoader.FailureHandlerthat handles errors with using a standard formatted message.- Parameters:
messageHandler- the message handler used to handle the problem- Returns:
- a new
SpringFactoriesLoader.FailureHandlerinstance
-