4444import io .quarkus .arc .Arc ;
4545import io .quarkus .arc .InstanceHandle ;
4646import io .quarkus .arc .Subclass ;
47+ import io .quarkus .arc .runtime .BeanContainer ;
4748import io .quarkus .grpc .api .ServerBuilderCustomizer ;
4849import io .quarkus .grpc .auth .GrpcSecurityInterceptor ;
4950import io .quarkus .grpc .reflection .service .ReflectionServiceV1 ;
@@ -121,18 +122,15 @@ public void handle(RoutingContext event) {
121122 }
122123 }
123124
124- public void initializeGrpcServer (RuntimeValue <Vertx > vertxSupplier ,
125+ public void initializeGrpcServer (boolean hasNoBindableServiceBeans , BeanContainer beanContainer ,
126+ RuntimeValue <Vertx > vertxSupplier ,
125127 RuntimeValue <Router > routerSupplier ,
126128 GrpcConfiguration cfg ,
127129 ShutdownContext shutdown ,
128130 Map <String , List <String >> blockingMethodsPerService ,
129131 Map <String , List <String >> virtualMethodsPerService ,
130132 LaunchMode launchMode , boolean securityPresent , Map <Integer , Handler <RoutingContext >> securityHandlers ) {
131- GrpcContainer grpcContainer = Arc .container ().instance (GrpcContainer .class ).get ();
132- if (grpcContainer == null ) {
133- throw new IllegalStateException ("gRPC not initialized, GrpcContainer not found" );
134- }
135- if (hasNoServices (grpcContainer .getServices ()) && LaunchMode .current () != LaunchMode .DEVELOPMENT ) {
133+ if (hasNoBindableServiceBeans && LaunchMode .current () != LaunchMode .DEVELOPMENT ) {
136134 LOGGER .error ("Unable to find beans exposing the `BindableService` interface - not starting the gRPC server" );
137135 return ; // OK?
138136 }
@@ -152,20 +150,23 @@ public void initializeGrpcServer(RuntimeValue<Vertx> vertxSupplier,
152150 // start single server, not in a verticle, regardless of the configuration.instances
153151 // for reason unknown to me, verticles occasionally get undeployed on dev mode reload
154152 if (GrpcServerReloader .getServer () != null || (provider != null && provider .serverAlreadyExists ())) {
155- devModeReload (grpcContainer , vertx , configuration , provider , blockingMethodsPerService ,
153+ devModeReload (beanContainer .beanInstance (GrpcContainer .class ), vertx , configuration , provider ,
154+ blockingMethodsPerService ,
156155 virtualMethodsPerService , shutdown );
157156 } else {
158- devModeStart (grpcContainer , vertx , configuration , provider , blockingMethodsPerService ,
157+ devModeStart (beanContainer .beanInstance (GrpcContainer .class ), vertx , configuration , provider ,
158+ blockingMethodsPerService ,
159159 virtualMethodsPerService , shutdown ,
160160 launchMode );
161161 }
162162 } else {
163- prodStart (grpcContainer , vertx , configuration , provider , blockingMethodsPerService , virtualMethodsPerService ,
163+ prodStart (beanContainer .beanInstance (GrpcContainer .class ), vertx , configuration , provider ,
164+ blockingMethodsPerService , virtualMethodsPerService ,
164165 launchMode );
165166 }
166167 } else {
167168 buildGrpcServer (vertx , configuration , routerSupplier , shutdown , blockingMethodsPerService , virtualMethodsPerService ,
168- grpcContainer , launchMode , securityPresent , securityHandlers );
169+ beanContainer . beanInstance ( GrpcContainer . class ) , launchMode , securityPresent , securityHandlers );
169170 }
170171 }
171172
0 commit comments