Skip to content

Commit

Permalink
gRPC - register additional bean archives
Browse files Browse the repository at this point in the history
- an application archive that contains a MutinyBean implementor is an
additional bean archive
- resolves quarkusio#19864

(cherry picked from commit 13bc4d2)
  • Loading branch information
mkouba authored and gsmet committed Sep 6, 2021
1 parent 063afdd commit 67894fc
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import io.grpc.internal.ServerImpl;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
import io.quarkus.arc.deployment.BeanArchivePredicateBuildItem;
import io.quarkus.arc.deployment.CustomScopeAnnotationsBuildItem;
import io.quarkus.arc.deployment.SyntheticBeansRuntimeInitBuildItem;
import io.quarkus.arc.deployment.ValidationPhaseBuildItem;
import io.quarkus.arc.processor.AnnotationsTransformer;
import io.quarkus.arc.processor.BeanInfo;
import io.quarkus.arc.processor.BuiltinScope;
import io.quarkus.deployment.ApplicationArchive;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.annotations.BuildProducer;
Expand Down Expand Up @@ -218,7 +220,7 @@ private Set<MethodInfo> gatherBlockingMethods(ClassInfo service) {
AnnotationsTransformerBuildItem transformUserDefinedServices(CombinedIndexBuildItem combinedIndexBuildItem,
CustomScopeAnnotationsBuildItem customScopes) {
// User-defined services usually only declare the @GrpcService qualifier
// We need to add @GrpcEnableRequestContext and @Singleton if needed
// We need to add @GrpcEnableRequestContext and @Singleton if needed
Set<DotName> userDefinedServices = new HashSet<>();
for (AnnotationInstance annotation : combinedIndexBuildItem.getIndex().getAnnotations(GrpcDotNames.GRPC_SERVICE)) {
if (annotation.target().kind() == Kind.CLASS) {
Expand Down Expand Up @@ -393,4 +395,16 @@ void configureMetrics(GrpcBuildTimeConfig configuration, Optional<MetricsCapabil
}
}

@BuildStep
BeanArchivePredicateBuildItem additionalBeanArchives() {
return new BeanArchivePredicateBuildItem(new Predicate<ApplicationArchive>() {

@Override
public boolean test(ApplicationArchive archive) {
// Every archive that contains a generated implementor of MutinyBean is considered a bean archive
return !archive.getIndex().getKnownDirectImplementors(GrpcDotNames.MUTINY_BEAN).isEmpty();
}
});
}

}

0 comments on commit 67894fc

Please sign in to comment.