diff --git a/service/inject/README.md b/service/inject/README.md index f28d1f55c12..304f35e63a2 100644 --- a/service/inject/README.md +++ b/service/inject/README.md @@ -379,7 +379,7 @@ The generated main class will contain full, reflection less configuration of the The Main class can also be customized; to do this: 1. Create a custom class (let's call it `CustomMain` as an example) -2. The class must extends the injection main class (`public abstract class CustomMain extends InjectionMain`) +2. The class must extend the injection main class (`public abstract class CustomMain extends InjectionMain`) 3. The class must be annotated with `@Injection.Main`, so it is discovered by annotation processor 4. Implement any desired methods; the generated class will only implement `serviceDescriptors(InjectConfig.Builder configBuilder)` (always), and `discoverServices()` (if created from the Maven plugin) diff --git a/service/inject/inject/src/main/java/io/helidon/service/inject/InjectStartupProvider.java b/service/inject/inject/src/main/java/io/helidon/service/inject/InjectStartupProvider.java index 09c383a5db2..58b13960320 100644 --- a/service/inject/inject/src/main/java/io/helidon/service/inject/InjectStartupProvider.java +++ b/service/inject/inject/src/main/java/io/helidon/service/inject/InjectStartupProvider.java @@ -60,6 +60,7 @@ public void start(String[] arguments) { @Override protected void serviceDescriptors(InjectConfig.Builder configBuilder) { + // service descriptors are discovered when startup provider is used - see below discoverServices() method } @Override diff --git a/service/inject/maven-plugin/src/main/java/io/helidon/service/inject/maven/plugin/BindingGenerator.java b/service/inject/maven-plugin/src/main/java/io/helidon/service/inject/maven/plugin/BindingGenerator.java index fea87bd0624..93f3ea286a6 100644 --- a/service/inject/maven-plugin/src/main/java/io/helidon/service/inject/maven/plugin/BindingGenerator.java +++ b/service/inject/maven-plugin/src/main/java/io/helidon/service/inject/maven/plugin/BindingGenerator.java @@ -291,9 +291,14 @@ private InjectionPlan injectionPlan(WrappedServices services, Lookup dependencyTo = Lookup.create(dependency); Set qualifiers = dependencyTo.qualifiers(); if (self.contracts().containsAll(dependencyTo.contracts()) && self.qualifiers().equals(qualifiers)) { - // criteria must have a single contract for each injection point - // if this service implements the contracts actually required, we must look for services with lower weight - // but only if we also have the same qualifiers + /* + lookup must have a single contract for each injection point + if this service implements the contracts actually required, we must look for services with lower weight + but only if we also have the same qualifiers; + this is to ensure that if an injection point in a service injects a contract the service implements itself, + we do not end up in an infinite loop, but look for a service with a lower weight to satisfy that injection point + this allows us to "chain" a single contract through multiple services + */ dependencyTo = Lookup.builder(dependencyTo) .weight(self.weight()) .build();