001package io.avaje.inject; 002 003/** 004 * Used to explicitly specify if it depends on externally provided beans or provides. 005 * 006 * <h3>External dependencies</h3> 007 * <p> 008 * Use {@code requires} to specify dependencies that will be provided externally. 009 * 010 * <pre>{@code 011 * 012 * // tell the annotation processor Pump and Grinder are provided externally 013 * // otherwise it will think we have missing dependencies at compile time 014 * 015 * @InjectModule(requires = {Pump.class, Grinder.class}) 016 * 017 * }</pre> 018 * 019 * <h3>Custom scope depending on another scope</h3> 020 * <p> 021 * When using custom scopes we can have the case where we desire one scope to depend 022 * on another. In this case we put the custom scope annotation in requires. 023 * <p> 024 * For example lets say we have a custom scope called {@code StoreComponent} and that 025 * depends on {@code QueueComponent} custom scope. 026 * 027 * <pre>{@code 028 * 029 * @Scope 030 * @InjectModule(requires = {QueueComponent.class}) 031 * public @interface StoreComponent { 032 * } 033 * 034 * 035 * }</pre> 036 */ 037public @interface InjectModule { 038 039 /** 040 * Explicitly specify the name of the module. 041 */ 042 String name() default ""; 043 044 /** 045 * Explicitly define features that are provided by this module and required by other modules. 046 * <p> 047 * This is used to order wiring across multiple modules. Modules that provide dependencies 048 * should be wired before modules that require dependencies. 049 */ 050 Class<?>[] provides() default {}; 051 052 /** 053 * The dependencies that are provided externally or by other modules and that are required 054 * when wiring this module. 055 * <p> 056 * This effectively tells the annotation processor that these types are expected to be 057 * provided and to not treat them as missing dependencies. If we don't do this the annotation 058 * processor thinks the dependency is missing and will error the compilation saying there is 059 * a missing dependency. 060 */ 061 Class<?>[] requires() default {}; 062 063 /** 064 * Internal use only - identifies the custom scope annotation associated to this module. 065 * <p> 066 * When a module is generated for a custom scope this is set to link the module back to the 067 * custom scope annotation and support partial compilation. 068 */ 069 String customScopeType() default ""; 070 071}