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 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 new instance of this break handler in case it has NOT been created in current context yet.
|
onBreak
default BreakHandler<R> makeHandler(Task<R> task, ExecutionContext<R> executionContext) throws BreakHandlerException
makeHandler
in interface BreakHandlerFactory<R>
task
- the task which is executed by this BreakHandler
executionContext
- contains current execution data (specific to current execution)BreakHandlerException
- in case it was not possible to return implementation of this break handlerBreakHandler<R> createNewHandler(Task<R> task, ExecutionContext<R> executionContext)
BreakHandler
. This method is invoked when break handler instance has
NOT been created in current execution context yet.task
- currently executed taskexecutionContext
- current execution contextBreakHandler
default String getOnePerExecutionContextParamName(Task<R> task, ExecutionContext<R> executionContext)
task
- currently executed taskexecutionContext
- current execution contextExecutionContext.getContextAttribute(String)
Copyright © 2017. All rights reserved.