MCPcopy Index your code
hub / github.com/bootique/bootique / BQCoreModule

Class BQCoreModule

bootique/src/main/java/io/bootique/BQCoreModule.java:82–386  ·  view source on GitHub ↗

The main BQModule of Bootique DI runtime. Declares a minimal set of services needed for a Bootique app to start: parsing command line, reading configuration, findings and running a Command.

Source from the content-addressed store, hash-verified

80 * start: parsing command line, reading configuration, findings and running a Command.
81 */
82public class BQCoreModule implements BQModule {
83
84 private static final int TTY_MIN_COLUMNS = 40;
85 private static final int TTY_DEFAULT_COLUMNS = 80;
86
87 // Internal properties used to exclude system env vars and properties by BQTestRuntimeBuilder (JUnit 4) and
88 // TestRuntumeBuilder (JUnit 5)
89 private static final String EXCLUDE_SYSTEM_VARIABLES = "bq.core.excludeSystemVariables";
90 private static final String EXCLUDE_SYSTEM_PROPERTIES = "bq.core.excludeSystemProperties";
91
92 private final String[] args;
93 private final BootLogger bootLogger;
94 private final ShutdownManager shutdownManager;
95 private final Supplier<Collection<ModuleCrate>> modulesSource;
96
97 protected BQCoreModule(
98 String[] args,
99 BootLogger bootLogger,
100 ShutdownManager shutdownManager,
101 Supplier<Collection<ModuleCrate>> modulesSource) {
102
103 this.args = Objects.requireNonNull(args);
104 this.bootLogger = Objects.requireNonNull(bootLogger);
105 this.shutdownManager = Objects.requireNonNull(shutdownManager);
106 this.modulesSource = Objects.requireNonNull(modulesSource);
107 }
108
109 /**
110 * Returns an instance of {@link BQCoreModuleExtender} used by downstream modules to load custom extensions to the
111 * Bootique core module. Should be invoked from a downstream Module's "configure" method.
112 *
113 * @param binder DI binder passed to the Module that invokes this method.
114 * @return an instance of {@link BQCoreModuleExtender} that can be used to load custom extensions to the Bootique
115 * core.
116 */
117 public static BQCoreModuleExtender extend(Binder binder) {
118 return new BQCoreModuleExtender(binder);
119 }
120
121 private static Optional<Command> defaultCommand(Injector injector) {
122 // default is optional, so check via injector whether it is bound...
123 Key<Command> key = Key.get(Command.class, DefaultCommand.class);
124 if (injector.hasProvider(key)) {
125 Provider<Command> commandProvider = injector.getJakartaProvider(key);
126 return Optional.of(commandProvider.get());
127 }
128 return Optional.empty();
129 }
130
131 /**
132 * @since 3.0
133 */
134 @Override
135 public ModuleCrate crate() {
136 return ModuleCrate.of(this)
137 .description("The core of Bootique runtime.")
138 .build();
139 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected