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 TypeMethodDescriptionvoid
handleFailure
(Class<?> factoryType, String factoryImplementationName, Throwable failure) Handle thefailure
that occurred when instantiating thefactoryImplementationName
that was expected to be of the givenfactoryType
.handleMessage
(BiConsumer<Supplier<String>, Throwable> messageHandler) Create a newSpringFactoriesLoader.FailureHandler
that handles errors using a standard formatted message.Create a newSpringFactoriesLoader.FailureHandler
that handles errors by logging trace messages.throwing()
Create a newSpringFactoriesLoader.FailureHandler
that handles errors by throwing anIllegalArgumentException
.throwing
(BiFunction<String, Throwable, ? extends RuntimeException> exceptionFactory) Create a newSpringFactoriesLoader.FailureHandler
that handles errors by throwing an exception.
-
Method Details
-
handleFailure
Handle thefailure
that occurred when instantiating thefactoryImplementationName
that 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
Create a newSpringFactoriesLoader.FailureHandler
that handles errors by throwing anIllegalArgumentException
.- Returns:
- a new
SpringFactoriesLoader.FailureHandler
instance - See Also:
-
throwing
static SpringFactoriesLoader.FailureHandler throwing(BiFunction<String, Throwable, ? extends RuntimeException> exceptionFactory) Create a newSpringFactoriesLoader.FailureHandler
that handles errors by throwing an exception.- Parameters:
exceptionFactory
- factory used to create the exception- Returns:
- a new
SpringFactoriesLoader.FailureHandler
instance
-
logging
Create a newSpringFactoriesLoader.FailureHandler
that handles errors by logging trace messages.- Parameters:
logger
- the logger used to log messages- Returns:
- a new
SpringFactoriesLoader.FailureHandler
instance
-
handleMessage
static SpringFactoriesLoader.FailureHandler handleMessage(BiConsumer<Supplier<String>, Throwable> messageHandler) Create a newSpringFactoriesLoader.FailureHandler
that handles errors using a standard formatted message.- Parameters:
messageHandler
- the message handler used to handle the problem- Returns:
- a new
SpringFactoriesLoader.FailureHandler
instance
-