Annotation Type ProductionComponent
-
@Retention(RUNTIME) @Documented @Target(TYPE) @Beta public @interface ProductionComponentAnnotates an interface or abstract class for which a fully-formed, dependency-injected implementation is to be generated from a set of modules. The generated class will have the name of the type annotated with@ProductionComponentprepended withDagger. For example,@ProductionComponent interface MyComponent {...}will produce an implementation namedDaggerMyComponent.Each
Producesmethod that contributes to the component will be called at most once per component instance, no matter how many times that binding is used as a dependency. TODO(beder): Decide on how scope works for producers.Component methods
Every type annotated with
@ProductionComponentmust contain at least one abstract component method. Component methods must represent production.Production methods have no arguments and return either a
ListenableFutureorProducerof a type that isinjected,provided, orproduced. Each may have aQualifierannotation as well. The following are all valid production method declarations:ListenableFuture<SomeType> getSomeType(); Producer<Set<SomeType>> getSomeTypes(); @Response ListenableFuture<Html> getResponse();Exceptions
When a producer throws an exception, the exception will be propagated to its downstream producers in the following way: if the downstream producer injects a type
T, then that downstream producer will be skipped, and the exception propagated to its downstream producers; and if the downstream producer injects aProduced<T>, then the downstream producer will be run with the exception stored in theProduced<T>.If a non-execution exception is thrown (e.g., an
InterruptedExceptionorCancellationException), then exception is handled as inFutures.transform(com.google.common.util.concurrent.ListenableFuture<I>, com.google.common.base.Function<? super I, ? extends O>, java.util.concurrent.Executor).Executor
The component must include a binding for
@; this binding will be called exactly once, and the provided executor will be used by the framework to schedule all producer methods (for this component, and anyProductionExecutorProductionSubcomponentit may have.- Since:
- 2.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>[]dependenciesA list of types that are to be used as component dependencies.java.lang.Class<?>[]modulesA list of classes annotated withModuleorProducerModulewhose bindings are used to generate the component implementation.
-
-
-
Element Detail
-
modules
java.lang.Class<?>[] modules
A list of classes annotated withModuleorProducerModulewhose bindings are used to generate the component implementation.- Default:
- {}
-
-