Skip to content

Commit

Permalink
Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-langer committed Nov 26, 2024
1 parent aaf4d5f commit 90f167a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion service/inject/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,14 @@ private InjectionPlan injectionPlan(WrappedServices services,
Lookup dependencyTo = Lookup.create(dependency);
Set<Qualifier> 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();
Expand Down

0 comments on commit 90f167a

Please sign in to comment.