Annotation Interface ProductionComponent
@ProductionComponent prepended with
Dagger. For example, @ProductionComponent interface MyComponent {...} will
produce an implementation named DaggerMyComponent.
Each Produces method 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 @ProductionComponent must contain at least one abstract
component method. Component methods must represent production.
Production methods have no arguments and return either a ListenableFuture or Producer of a type that is injected, provided, or produced. Each may have a Qualifier annotation 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 a Produced<T>, then the downstream producer will
be run with the exception stored in the Produced<T>.
If a non-execution exception is thrown (e.g., an InterruptedException or
CancellationException), then exception is handled as in Futures.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 any Production
ExecutorProductionSubcomponent it may have.
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceA builder for a production component.static @interfaceA factory for a production component. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?>[]A list of types that are to be used as component dependencies.Class<?>[]A list of classes annotated withModuleorProducerModulewhose bindings are used to generate the component implementation.
-
Element Details
-
modules
Class<?>[] modulesA list of classes annotated withModuleorProducerModulewhose bindings are used to generate the component implementation.- Default:
- {}
-
dependencies
Class<?>[] dependenciesA list of types that are to be used as component dependencies.- Default:
- {}
-