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   * Set to true to ignore anything annotated with <code>@Singleton</code>.
046   * <p>
047   * Set this to true when some other library is using <code>@Singleton</code> and we want
048   * avaje-inject to be completely independent of that by ignoring the standard <code>@Singleton</code>.
049   * <p>
050   * We instead use <code>@Component</code> instead of <code>@Singleton</code>.
051   */
052  boolean ignoreSingleton() default false;
053
054  /**
055   * Explicitly define features that are provided by this module and required by other modules.
056   * <p>
057   * This is used to order wiring across multiple modules. Modules that provide dependencies
058   * should be wired before modules that require dependencies.
059   */
060  Class<?>[] provides() default {};
061
062  /**
063   * The dependencies that are provided externally or by other modules and that are required
064   * when wiring this module.
065   * <p>
066   * This effectively tells the annotation processor that these types are expected to be
067   * provided and to not treat them as missing dependencies. If we don't do this the annotation
068   * processor thinks the dependency is missing and will error the compilation saying there is
069   * a missing dependency.
070   */
071  Class<?>[] requires() default {};
072
073  /**
074   * Dependencies in these packages are expected to be provided by other modules.
075   * <p>
076   * Instead of listing each and every dependency in {@code requires} we can use this to specify
077   * that any required dependency that is in these packages is expected to be provided by another module.
078   * <p>
079   * Use this rather than {@code requires} when there are lots of required dependencies, and we don't
080   * want to list each one in {@code requires} and {@code provides}.
081   */
082  Class<?>[] requiresPackages() default {};
083
084  /**
085   * Internal use only - identifies the custom scope annotation associated to this module.
086   * <p>
087   * When a module is generated for a custom scope this is set to link the module back to the
088   * custom scope annotation and support partial compilation.
089   */
090  String customScopeType() default "";
091
092}