001package io.avaje.inject.spi;
002
003import java.lang.reflect.Type;
004
005/**
006 * A Module containing dependencies that will be included in BeanScope.
007 */
008public interface AvajeModule extends InjectExtension {
009
010  /**
011   * Empty array of classes.
012   */
013  Class<?>[] EMPTY_CLASSES = {};
014
015  /**
016   * Return the set of types this module explicitly provides to other modules.
017   */
018  default Type[] provides() {
019    return EMPTY_CLASSES;
020  }
021
022  /**
023   * Return the types this module needs to be provided externally or via other modules.
024   */
025  default Type[] requires() {
026    return EMPTY_CLASSES;
027  }
028
029  /**
030   * Return the packages this module needs to be provided via other modules.
031   */
032  default Type[] requiresPackages() {
033    return EMPTY_CLASSES;
034  }
035
036  /**
037   * Return the classes that this module provides that we allow other modules to auto depend on.
038   *
039   * <p>This is a convenience when using multiple modules that is otherwise controlled manually by
040   * explicitly using {@link AvajeModule#provides()}.
041   */
042  default Type[] autoProvides() {
043    return EMPTY_CLASSES;
044  }
045
046  /**
047   * Return the aspects that this module provides.
048   *
049   * <p>This is a convenience when using multiple modules that we otherwise manually specify via
050   * {@link AvajeModule#provides()}.
051   */
052  default Class<?>[] autoProvidesAspects() {
053    return EMPTY_CLASSES;
054  }
055
056  /**
057   * These are the classes that this module requires for wiring that are provided by other external
058   * modules (that are in the classpath at compile time).
059   *
060   * <p>This is a convenience when using multiple modules that is otherwise controlled manually by
061   * explicitly using {@link AvajeModule#requires()} or {@link AvajeModule#requiresPackages()}.
062   */
063  default Type[] autoRequires() {
064    return EMPTY_CLASSES;
065  }
066
067  /**
068   * These are the aspects that this module requires whose implementations are provided by other
069   * external modules (that are in the classpath at compile time).
070   */
071  default Class<?>[] autoRequiresAspects() {
072    return EMPTY_CLASSES;
073  }
074
075  /**
076   * Return public classes of the beans that would be registered by this module.
077   *
078   * <p>This method allows code to use reflection to inspect the modules classes before the module
079   * is wired. This method is not required for DI wiring.
080   */
081  Class<?>[] classes();
082
083  /**
084   * Build all the beans.
085   */
086  void build(Builder builder);
087
088  /**
089   * Marker for custom scoped modules.
090   */
091  interface Custom extends AvajeModule {
092  }
093}