R
- the return type of real-method for which a break handler is createdpublic class SimpleHandlerFactory<R> extends Object implements BreakHandlerFactory<R>
BreakHandlerFactory
which creates new instance of given BreakHandler
class for
each invocation of makeHandler(Task, ExecutionContext)
. The class given as a constructor param needs
to have default constructor which is used to create instance. The constructor must be accessible to
SimpleHandlerFactory
.
NOTE: if given handlerClass makes subsequent calls to makeHandler(Task, ExecutionContext)
during one
execution flow of circuit breaker (like for example ReusableRetryHandler
does), new instance of given
handler would be created for each call to makeHandler(Task, ExecutionContext)
, so there will be
different instances of BreakHandler
created per execution flow of circuit breaker. If you want only
one break handler to be created for single execution of Task, consider implementing
OnePerExecutionHandlerFactory
which creates and returns only one
instance per execution. See source code of ReusableRetryHandler
for example of implementing this interface.
Constructor and Description |
---|
SimpleHandlerFactory(Class<? extends BreakHandler<R>> handlerClass) |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onBreak
public SimpleHandlerFactory(Class<? extends BreakHandler<R>> handlerClass)
public BreakHandler<R> makeHandler(Task<R> task, ExecutionContext<R> executionContext)
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
Copyright © 2017. All rights reserved.