public interface OnePerExecutionHandlerFactory<R> extends BreakHandlerFactory<R>
BreakHandlerFactory
which creates new instance of given BreakHandler
if it
does not exist in current execution context, otherwise returns BreakHandler
bound to current execution
context (reuses the same instance for handling subsequent calls to
BreakHandler.onBreak(ContextAwareCircuitBreaker, Task, BreakStrategy, ExecutionContext)
).
NOTE: Each call to CircuitBreaker.execute(Task, BreakStrategy, BreakHandler)
method creates new
context.
If implementation of OnePerExecutionHandlerFactory
is used as a BreakHandler
, "one and only one"
instance of given BreakHandler
is created for per execution context (this is guaranteed by default
implementation of makeHandler(Task, ExecutionContext)
provided by this interface)
Modifier and Type | Method and Description |
---|---|
BreakHandler<R> |
createNewHandler(Task<R> task,
ExecutionContext<R> executionContext)
Constructs and returns new
BreakHandler . |
default String |
getOnePerExecutionContextParamName(Task<R> task,
ExecutionContext<R> executionContext)
Returns execution context parameter name under which produced break handler will be stored.
|
default BreakHandler<R> |
makeHandler(Task<R> task,
ExecutionContext<R> executionContext)
Returns an instance of
BreakHandler which should be used to handle the break. |
onBreak
default BreakHandler<R> makeHandler(Task<R> task, ExecutionContext<R> executionContext) throws BreakHandlerException
BreakHandlerFactory
BreakHandler
which should be used to handle the break.makeHandler
in interface BreakHandlerFactory<R>
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 producedBreakHandler<R> createNewHandler(Task<R> task, ExecutionContext<R> executionContext)
BreakHandler
. This method is invoked break handler has not yet been created in
current execution context.task
- the originally executed taskexecutionContext
- current execution contextBreakHandler
default String getOnePerExecutionContextParamName(Task<R> task, ExecutionContext<R> executionContext)
task
- the originally executed taskexecutionContext
- current execution contextExecutionContext.getContextAttribute(String)
Copyright © 2017. All rights reserved.