use of io.helidon.microprofile.grpc.server.spi.GrpcMpContext in project helidon by oracle.
the class GrpcServerCdiExtension method loadExtensions.
/**
* Load any instances of {@link GrpcMpExtension} discovered by the
* {@link ServiceLoader} and allow them to further configure the
* gRPC server.
*
* @param beanManager the {@link BeanManager}
* @param config the Helidon configuration
* @param routingBuilder the {@link GrpcRouting.Builder}
* @param serverConfiguration the {@link GrpcServerConfiguration}
*/
private void loadExtensions(BeanManager beanManager, Config config, GrpcRouting.Builder routingBuilder, GrpcServerConfiguration.Builder serverConfiguration, CompletionStage<GrpcServer> whenStarted, CompletionStage<GrpcServer> whenShutdown) {
GrpcMpContext context = new GrpcMpContext() {
@Override
public Config config() {
return config;
}
@Override
public GrpcServerConfiguration.Builder grpcServerConfiguration() {
return serverConfiguration;
}
@Override
public GrpcRouting.Builder routing() {
return routingBuilder;
}
@Override
public BeanManager beanManager() {
return beanManager;
}
@Override
public CompletionStage<GrpcServer> whenStarted() {
return whenStarted;
}
@Override
public CompletionStage<GrpcServer> whenShutdown() {
return whenShutdown;
}
};
HelidonServiceLoader.create(ServiceLoader.load(GrpcMpExtension.class)).forEach(ext -> ext.configure(context));
beanManager.createInstance().select(GrpcMpExtension.class).stream().forEach(ext -> ext.configure(context));
}
Aggregations