|
16 | 16 | import java.util.function.Consumer; |
17 | 17 | import java.util.function.Supplier; |
18 | 18 |
|
19 | | -import jakarta.inject.Provider; |
20 | 19 | import org.jspecify.annotations.Nullable; |
21 | 20 |
|
22 | 21 | import io.avaje.applog.AppLog; |
| 22 | +import io.avaje.config.Configuration; |
23 | 23 | import io.avaje.inject.spi.AvajeModule; |
24 | 24 | import io.avaje.inject.spi.Builder; |
25 | 25 | import io.avaje.inject.spi.ClosePair; |
26 | 26 | import io.avaje.inject.spi.ConfigPropertyPlugin; |
27 | 27 | import io.avaje.inject.spi.EnrichBean; |
28 | 28 | import io.avaje.inject.spi.ModuleOrdering; |
29 | 29 | import io.avaje.inject.spi.SuppliedBean; |
| 30 | +import jakarta.inject.Provider; |
30 | 31 |
|
31 | 32 | /** Build a bean scope with options for shutdown hook and supplying test doubles. */ |
32 | 33 | final class DBeanScopeBuilder implements BeanScopeBuilder.ForTesting { |
@@ -220,16 +221,19 @@ private ConfigPropertyPlugin defaultPropertyPlugin() { |
220 | 221 | return detectAvajeConfig() ? new DConfigProps() : new DSystemProps(); |
221 | 222 | } |
222 | 223 |
|
223 | | - private boolean detectAvajeConfig() { |
224 | | - if (ModuleLayer.boot().findModule("io.avaje.config").isPresent()) { |
225 | | - return true; |
226 | | - } |
227 | | - try { |
228 | | - Class.forName("io.avaje.config.Configuration", false, classLoader); |
229 | | - return true; |
230 | | - } catch (final ClassNotFoundException e) { |
231 | | - return false; |
232 | | - } |
| 224 | + @SuppressWarnings("ConstantValue") |
| 225 | + private static boolean detectAvajeConfig() { |
| 226 | + var modules = ModuleLayer.boot(); |
| 227 | + return modules |
| 228 | + .findModule("io.avaje.inject") |
| 229 | + .map(m -> modules.findModule("io.avaje.config").isPresent()) |
| 230 | + .orElseGet(() -> { |
| 231 | + try { |
| 232 | + return Configuration.class != null; |
| 233 | + } catch (NoClassDefFoundError e) { |
| 234 | + return false; |
| 235 | + } |
| 236 | + }); |
233 | 237 | } |
234 | 238 |
|
235 | 239 | private void initProfiles() { |
|
0 commit comments