Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pico cfg driven with additional ctor injection points fix #6612

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.helidon.examples.nima.pico;

import org.junit.jupiter.api.Test;

class GreetEndpointTest {

@Test
void testIt() {
PicoMain.main(new String[] {});
tomas-langer marked this conversation as resolved.
Show resolved Hide resolved
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public Optional<Object> resolve(InjectionPointInfo ipInfo,
.addContractImplemented(configBeanType().getName())
.build();
if (!dep.matchesContracts(criteria)) {
return Optional.empty();
return Optional.empty(); // we are being injected with neither a config bean nor a service that matches ourselves
}

// if we are here then we are asking for a config bean for ourselves, or a slave/managed instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ private static void accumulate(DependencyInfo dep,
.orElse(null);
Object target = (resolved instanceof Optional)
? ((Optional<?>) resolved).orElse(null) : resolved;
DefaultPicoInjectionPlan.Builder planBuilder = DefaultPicoInjectionPlan.builder()
.serviceProvider(self)
.injectionPointInfo(ipInfo)
.injectionPointQualifiedServiceProviders(toIpQualified(target))
.unqualifiedProviders(toIpUnqualified(target))
.wasResolved(resolved != null);
if (target != null) {
DefaultPicoInjectionPlan.Builder planBuilder = DefaultPicoInjectionPlan.builder()
.serviceProvider(self)
.injectionPointInfo(ipInfo)
.injectionPointQualifiedServiceProviders(toIpQualified(target))
.unqualifiedProviders(toIpUnqualified(target))
.wasResolved(resolved != null);

if (ipInfo.optionalWrapped()) {
planBuilder.resolved((target instanceof Optional && ((Optional<?>) target).isEmpty())
? Optional.empty() : Optional.of(target));
Expand All @@ -125,9 +126,11 @@ private static void accumulate(DependencyInfo dep,
}
planBuilder.resolved(target);
}

PicoInjectionPlan plan = planBuilder.build();
Object prev = result.put(id, plan);
assert (prev == null) : ipInfo;
}
Object prev = result.put(id, planBuilder.build());
assert (prev == null) : ipInfo;
}
});
}
Expand All @@ -143,8 +146,8 @@ private static void accumulate(DependencyInfo dep,
List<ServiceProvider<?>> serviceProviders =
(tmpServiceProviders != null && !tmpServiceProviders.isEmpty())
? tmpServiceProviders.stream()
.filter(sp -> !isSelf(self, sp))
.collect(Collectors.toList())
.filter(sp -> !isSelf(self, sp))
.collect(Collectors.toList())
: tmpServiceProviders;

dep.injectionPointDependencies()
Expand All @@ -163,7 +166,7 @@ private static void accumulate(DependencyInfo dep,
throw DefaultServices.resolutionBasedInjectionError(
ipInfo.dependencyToServiceInfo());
}
DefaultPicoInjectionPlan plan = DefaultPicoInjectionPlan.builder()
PicoInjectionPlan plan = DefaultPicoInjectionPlan.builder()
.injectionPointInfo(ipInfo)
.injectionPointQualifiedServiceProviders(serviceProviders)
.serviceProvider(self)
Expand Down