Rename BaseGrpcServerFactory to DefaultGrpcServerFactory
This commit is contained in:
@@ -30,7 +30,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Base implementation for {@link GrpcServerFactory gRPC service factories}.
|
||||
* Default implementation for {@link GrpcServerFactory gRPC service factories}.
|
||||
* <p>
|
||||
* The server builder implementation is discovered via Java's SPI mechanism.
|
||||
*
|
||||
@@ -39,7 +39,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* @param <T> the type of server builder
|
||||
* @see ServerProvider#provider()
|
||||
*/
|
||||
public class BaseGrpcServerFactory<T extends ServerBuilder<T>> implements GrpcServerFactory {
|
||||
public class DefaultGrpcServerFactory<T extends ServerBuilder<T>> implements GrpcServerFactory {
|
||||
|
||||
// VisibleForSubclass
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
@@ -52,7 +52,8 @@ public class BaseGrpcServerFactory<T extends ServerBuilder<T>> implements GrpcSe
|
||||
|
||||
private final List<ServerBuilderCustomizer<T>> serverBuilderCustomizers;
|
||||
|
||||
public BaseGrpcServerFactory(String address, int port, List<ServerBuilderCustomizer<T>> serverBuilderCustomizers) {
|
||||
public DefaultGrpcServerFactory(String address, int port,
|
||||
List<ServerBuilderCustomizer<T>> serverBuilderCustomizers) {
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.serverBuilderCustomizers = Objects.requireNonNull(serverBuilderCustomizers, "serverBuilderCustomizers");
|
||||
@@ -31,7 +31,7 @@ import io.netty.channel.unix.DomainSocketAddress;
|
||||
* @author David Syer
|
||||
* @author Chris Bono
|
||||
*/
|
||||
public class NettyGrpcServerFactory extends BaseGrpcServerFactory<NettyServerBuilder> {
|
||||
public class NettyGrpcServerFactory extends DefaultGrpcServerFactory<NettyServerBuilder> {
|
||||
|
||||
private static final String ANY_IP_ADDRESS = "*";
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress;
|
||||
* @author David Syer
|
||||
* @author Chris Bono
|
||||
*/
|
||||
public class ShadedNettyGrpcServerFactory extends BaseGrpcServerFactory<NettyServerBuilder> {
|
||||
public class ShadedNettyGrpcServerFactory extends DefaultGrpcServerFactory<NettyServerBuilder> {
|
||||
|
||||
private static final String ANY_IP_ADDRESS = "*";
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ package org.springframework.grpc.server;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link DefaultGrpcServerFactory}/
|
||||
* Tests for {@link GrpcServerFactory gRPC server factories}.
|
||||
*/
|
||||
class DefaultGrpcServerFactoryTests {
|
||||
class GrpcServerFactoryTests {
|
||||
|
||||
@Test
|
||||
void placeholderTest() {
|
||||
@@ -28,7 +28,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.grpc.server.BaseGrpcServerFactory;
|
||||
import org.springframework.grpc.server.DefaultGrpcServerFactory;
|
||||
import org.springframework.grpc.server.GrpcServerFactory;
|
||||
import org.springframework.grpc.server.NettyGrpcServerFactory;
|
||||
import org.springframework.grpc.server.ServerBuilderCustomizer;
|
||||
@@ -90,13 +90,13 @@ class GrpcServerFactoryConfigurations {
|
||||
static class ServiceProviderServerFactoryConfiguration {
|
||||
|
||||
@Bean
|
||||
<T extends ServerBuilder<T>> BaseGrpcServerFactory<T> serviceProviderGrpcServerFactory(
|
||||
<T extends ServerBuilder<T>> DefaultGrpcServerFactory<T> serviceProviderGrpcServerFactory(
|
||||
GrpcServerProperties properties, ObjectProvider<BindableService> grpcServicesProvider,
|
||||
ServerBuilderCustomizers serverBuilderCustomizers) {
|
||||
BaseServerFactoryPropertyMapper<T> mapper = new BaseServerFactoryPropertyMapper<>(properties);
|
||||
DefaultServerFactoryPropertyMapper<T> mapper = new DefaultServerFactoryPropertyMapper<>(properties);
|
||||
List<ServerBuilderCustomizer<T>> builderCustomizers = List.of(mapper::customizeServerBuilder,
|
||||
serverBuilderCustomizers::customize);
|
||||
BaseGrpcServerFactory<T> factory = new BaseGrpcServerFactory<>(properties.getAddress(),
|
||||
DefaultGrpcServerFactory<T> factory = new DefaultGrpcServerFactory<>(properties.getAddress(),
|
||||
properties.getPort(), builderCustomizers);
|
||||
grpcServicesProvider.orderedStream().map(BindableService::bindService).forEach(factory::addService);
|
||||
return factory;
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.grpc.server.BaseGrpcServerFactory;
|
||||
import org.springframework.grpc.server.DefaultGrpcServerFactory;
|
||||
import org.springframework.grpc.server.GrpcServerFactory;
|
||||
import org.springframework.grpc.server.NettyGrpcServerFactory;
|
||||
import org.springframework.grpc.server.ServerBuilderCustomizer;
|
||||
@@ -154,7 +154,7 @@ class GrpcServerAutoConfigurationTests {
|
||||
.withClassLoader(new FilteredClassLoader(NettyServerBuilder.class,
|
||||
io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder.class))
|
||||
.run((context) -> assertThat(context).getBean(GrpcServerFactory.class)
|
||||
.isInstanceOf(BaseGrpcServerFactory.class));
|
||||
.isInstanceOf(DefaultGrpcServerFactory.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,10 +171,11 @@ class GrpcServerAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void baseServerFactoryAutoConfiguredAsExpected() {
|
||||
serverFactoryAutoConfiguredAsExpected(this.contextRunner()
|
||||
.withClassLoader(new FilteredClassLoader(NettyServerBuilder.class,
|
||||
io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder.class)),
|
||||
BaseGrpcServerFactory.class);
|
||||
serverFactoryAutoConfiguredAsExpected(
|
||||
this.contextRunner()
|
||||
.withClassLoader(new FilteredClassLoader(NettyServerBuilder.class,
|
||||
io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder.class)),
|
||||
DefaultGrpcServerFactory.class);
|
||||
}
|
||||
|
||||
private void serverFactoryAutoConfiguredAsExpected(ApplicationContextRunner contextRunner,
|
||||
@@ -227,7 +228,7 @@ class GrpcServerAutoConfigurationTests {
|
||||
this.contextRunnerWithLifecyle()
|
||||
.withClassLoader(new FilteredClassLoader(NettyServerBuilder.class,
|
||||
io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder.class)),
|
||||
builder, BaseGrpcServerFactory.class);
|
||||
builder, DefaultGrpcServerFactory.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user