001package io.avaje.inject.spi; 002 003import io.avaje.inject.InjectModule; 004 005/** 006 * A Module that can be included in BeanScope. 007 */ 008public interface Module { 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 Class<?>[] 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 Class<?>[] requires() { 026 return EMPTY_CLASSES; 027 } 028 029 /** 030 * Return the packages this module needs to be provided via other modules. 031 */ 032 default Class<?>[] 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 * <p> 039 * This is a convenience when using multiple modules that is otherwise controlled manually by 040 * explicitly using {@link InjectModule#provides()}. 041 */ 042 default Class<?>[] autoProvides() { 043 return EMPTY_CLASSES; 044 } 045 046 /** 047 * Return the aspects that this module provides. 048 * <p> 049 * This is a convenience when using multiple modules that we otherwise manually specify via 050 * {@link InjectModule#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 058 * external modules (that are in the classpath at compile time). 059 * <p> 060 * This is a convenience when using multiple modules that is otherwise controlled manually by 061 * explicitly using {@link InjectModule#requires()} or {@link InjectModule#requiresPackages()}. 062 */ 063 default Class<?>[] autoRequires() { 064 return EMPTY_CLASSES; 065 } 066 067 /** 068 * These are the apects that this module requires whose implementations are provided by other external 069 * 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 * <p> 078 * This method allows code to use reflection to inspect the modules classes 079 * before the module 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 Module { 092 093 } 094}