public abstract class ProducerMonitor extends Object
ProductionComponentMonitor
for how to install these monitors.
The lifecycle of the monitor, under normal conditions, is:
requested()
methodStarting()
methodFinished()
succeeded(Object)
if the method returned normally; or
failed(Throwable)
if the method threw an exception.
succeeded(Object)
if the method returned normally, and the future succeeded; or
failed(Throwable)
if the method threw an exception, or returned normally and the
future failed.
If any input to the monitored producer fails, failed(Throwable)
will be called
immediately with the failed input's exception. If more than one input fails, an arbitrary failed
input's exception is used.
For example, given an entry point A that depends on B, which depends on C, when the entry point A is called, this will trigger the following sequence of events, assuming all methods and futures complete successfully:
If any of the monitor's methods throw, then the exception will be logged and processing will continue unaffected.
Constructor and Description |
---|
ProducerMonitor() |
Modifier and Type | Method and Description |
---|---|
<T> void |
addCallbackTo(ListenableFuture<T> future)
Adds this monitor's completion methods as a callback to the future.
|
void |
failed(Throwable t)
Called when the producer's future has failed with an exception.
|
void |
methodFinished()
Called when the producer method has finished executing.
|
void |
methodStarting()
Called when the producer method is about to start executing.
|
static ProducerMonitor |
noOp()
Returns a monitor that does no monitoring.
|
void |
ready()
Called when all of the producer's inputs are available.
|
void |
requested()
Called when the producer's output is requested; that is, when the first method is called that
requires the production of this producer's output.
|
void |
succeeded(Object value)
Called when the producer’s future has completed successfully with a value.
|
public void requested()
Note that if a method depends on Producer<T>
, then this does not count as requesting
T
; that is only triggered by calling Producer.get()
.
Depending on how this producer is requested, the following threading constraints are guaranteed:
requested
will be called on the same thread as the component method call.
T
or Produced<T>
), then requested
will be called from the same thread as
the other producer's requested
.
Producer.get()
, then requested
will be called from the same thread as that get()
call.
When multiple monitors are installed, the order that each monitor will call this method is unspecified, but will remain consistent throughout the course of the execution of a component.
This implementation is a no-op.
public void ready()
failed(Throwable)
is called.
When multiple monitors are installed, the order that each monitor will call this method is unspecified, but will remain consistent throughout the course of the execution of a component.
This implementation is a no-op.
public void methodStarting()
When multiple monitors are installed, calls to this method will be in the reverse order from
calls to requested()
.
This implementation is a no-op.
public void methodFinished()
methodStarting()
and the producer method itself.
When multiple monitors are installed, calls to this method will be in the reverse order from
calls to requested()
.
This implementation is a no-op.
public void succeeded(Object value)
When multiple monitors are installed, calls to this method will be in the reverse order from
calls to requested()
.
This implementation is a no-op.
public void failed(Throwable t)
When multiple monitors are installed, calls to this method will be in the reverse order from
calls to requested()
.
This implementation is a no-op.
public <T> void addCallbackTo(ListenableFuture<T> future)
public static ProducerMonitor noOp()
Copyright © 2012���2017 The Dagger Authors. All rights reserved.