External dependencies
Use requires
to specify dependencies that will be provided externally.
// tell the annotation processor Pump and Grinder are provided externally
// otherwise it will think we have missing dependencies at compile time
@InjectModule(requires = {Pump.class, Grinder.class})
Custom scope depending on another scope
When using custom scopes we can have the case where we desire one scope to depend on another. In this case we put the custom scope annotation in requires.
For example lets say we have a custom scope called StoreComponent
and that
depends on QueueComponent
custom scope.
@Scope
@InjectModule(requires = {QueueComponent.class})
public @interface StoreComponent {
}
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionInternal use only - identifies the custom scope annotation associated to this module.boolean
Set to true to ignore anything annotated with@Singleton
.Explicitly specify the name of the module.Class<?>[]
Explicitly define features that are provided by this module and required by other modules.Class<?>[]
The dependencies that are provided externally or by other modules and that are required when wiring this module.Class<?>[]
Dependencies in these packages are expected to be provided by other modules.
-
Element Details
-
name
Explicitly specify the name of the module.- Default:
""
-
ignoreSingleton
boolean ignoreSingletonSet to true to ignore anything annotated with@Singleton
.Set this to true when some other library is using
@Singleton
and we want avaje-inject to be completely independent of that by ignoring the standard@Singleton
.We instead use
@Component
instead of@Singleton
.- Default:
false
-
provides
Explicitly define features that are provided by this module and required by other modules.This is used to order wiring across multiple modules. Modules that provide dependencies should be wired before modules that require dependencies.
- Default:
{}
-
requires
The dependencies that are provided externally or by other modules and that are required when wiring this module.This effectively tells the annotation processor that these types are expected to be provided and to not treat them as missing dependencies. If we don't do this the annotation processor thinks the dependency is missing and will error the compilation saying there is a missing dependency.
- Default:
{}
-
requiresPackages
Class<?>[] requiresPackagesDependencies in these packages are expected to be provided by other modules.Instead of listing each and every dependency in
requires
we can use this to specify that any required dependency that is in these packages is expected to be provided by another module.Use this rather than
requires
when there are lots of required dependencies, and we don't want to list each one inrequires
andprovides
.- Default:
{}
-
customScopeType
Internal use only - identifies the custom scope annotation associated to this module.When a module is generated for a custom scope this is set to link the module back to the custom scope annotation and support partial compilation.
- Default:
""
-