Annotation Type InjectModule


public @interface InjectModule
Used to explicitly specify if it depends on externally provided beans or provides.

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 Elements
    Modifier and Type Optional Element Description
    String customScopeType
    Internal use only - identifies the custom scope annotation associated to this module.
    String name
    Explicitly specify the name of the module.
    Class<?>[] provides
    Explicitly define features that are provided by this module and required by other modules.
    Class<?>[] requires
    The dependencies that are provided externally or by other modules and that are required when wiring this module.
  • Element Details

    • name

      Explicitly specify the name of the module.
      Default:
      ""
    • 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:
      {}
    • 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:
      ""