Search in sources :

Example 1 with GrpcMpContext

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));
}
Also used : GrpcServerConfiguration(io.helidon.grpc.server.GrpcServerConfiguration) GrpcServer(io.helidon.grpc.server.GrpcServer) GrpcMpContext(io.helidon.microprofile.grpc.server.spi.GrpcMpContext) GrpcRouting(io.helidon.grpc.server.GrpcRouting)

Aggregations

GrpcRouting (io.helidon.grpc.server.GrpcRouting)1 GrpcServer (io.helidon.grpc.server.GrpcServer)1 GrpcServerConfiguration (io.helidon.grpc.server.GrpcServerConfiguration)1 GrpcMpContext (io.helidon.microprofile.grpc.server.spi.GrpcMpContext)1