R
- the return type of onBreak method of the created BreakHandler
. This must be the same return
type as the of of executed Taskpublic interface BreakHandlerFactory<R> extends BreakHandler<R>
makeHandler(Task, ExecutionContext)
method which returns instance of a BreakHandler
. The
returned instance should be shareable between different executions of the target-method (between execution of
different tasks). This means that the implementation should conform to one of following statements:
ConcurrentModificationException
when accessed by different threadsConcurrentModificationException
when accessed by different threads)OnePerExecutionHandlerFactory
should be used.Modifier and Type | Method and Description |
---|---|
BreakHandler<R> |
makeHandler(Task<R> task,
ExecutionContext<R> executionContext)
Returns an instance of
BreakHandler which should be used to handle the break. |
default R |
onBreak(ContextAwareCircuitBreaker<R> circuitBreaker,
Task<R> task,
BreakStrategy<R> breakStrategy,
ExecutionContext<R> executionContext)
Handles situation when break occurs.
|
default R onBreak(ContextAwareCircuitBreaker<R> circuitBreaker, Task<R> task, BreakStrategy<R> breakStrategy, ExecutionContext<R> executionContext) throws TaskExecutionException, CircuitBreakerException, BreakHandlerException
BreakHandler
onBreak
in interface BreakHandler<R>
circuitBreaker
- a reference to the ContextAwareCircuitBreaker
which called this break handlertask
- the task which execution was prevented by break strategy and resulted in calling this
break handlerbreakStrategy
- the strategy which prevented the execution of task and resulted in calling this break
handlerexecutionContext
- contains current execution data (specific to current execution)TaskExecutionException
- in case there was exception while executing the task by this break handler (but
only in case this handler decided to execute the task - there is no possibility
to throw TaskExecutionException in case there was no attempt to execute a task)CircuitBreakerException
- in case the break handler tried to execute some task on circuitBreaker but the
circuitBreaker fallen with unexpected exceptionBreakHandlerException
- in case this break handler is not able to provide the the fallback valueBreakHandler<R> makeHandler(Task<R> task, ExecutionContext<R> executionContext) throws BreakHandlerException
BreakHandler
which should be used to handle the break.task
- the task which is executed by this BreakHandler
executionContext
- contains current execution data (specific to current execution)BreakHandler
BreakHandlerException
- when the handler could not have been producedCopyright © 2017. All rights reserved.