mirror of https://github.com/grpc/grpc-java.git
api: add ServerBuilder.addServices() API (#7926)
This commit is contained in:
parent
cfe7d7c00d
commit
a598b973a3
|
|
@ -30,6 +30,7 @@ import io.grpc.ServerTransportFilter;
|
||||||
import io.grpc.netty.NettyServerBuilder;
|
import io.grpc.netty.NettyServerBuilder;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
@ -117,6 +118,13 @@ public final class AltsServerBuilder extends ServerBuilder<AltsServerBuilder> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
public AltsServerBuilder addServices(List<ServerServiceDefinition> services) {
|
||||||
|
delegate.addServices(services);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public AltsServerBuilder fallbackHandlerRegistry(HandlerRegistry fallbackRegistry) {
|
public AltsServerBuilder fallbackHandlerRegistry(HandlerRegistry fallbackRegistry) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package io.grpc;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
@ -71,6 +72,12 @@ public abstract class ForwardingServerBuilder<T extends ServerBuilder<T>> extend
|
||||||
return thisT();
|
return thisT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T addServices(List<ServerServiceDefinition> services) {
|
||||||
|
delegate().addServices(services);
|
||||||
|
return thisT();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T intercept(ServerInterceptor interceptor) {
|
public T intercept(ServerInterceptor interceptor) {
|
||||||
delegate().intercept(interceptor);
|
delegate().intercept(interceptor);
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,12 @@
|
||||||
|
|
||||||
package io.grpc;
|
package io.grpc;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
@ -89,6 +92,22 @@ public abstract class ServerBuilder<T extends ServerBuilder<T>> {
|
||||||
*/
|
*/
|
||||||
public abstract T addService(BindableService bindableService);
|
public abstract T addService(BindableService bindableService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a list of service implementations to the handler registry together.
|
||||||
|
*
|
||||||
|
* @param services the list of ServerServiceDefinition objects
|
||||||
|
* @return this
|
||||||
|
* @since 1.37.0
|
||||||
|
*/
|
||||||
|
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7925")
|
||||||
|
public T addServices(List<ServerServiceDefinition> services) {
|
||||||
|
checkNotNull(services, "services");
|
||||||
|
for (ServerServiceDefinition service : services) {
|
||||||
|
addService(service);
|
||||||
|
}
|
||||||
|
return thisT();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a {@link ServerInterceptor} that is run for all services on the server. Interceptors
|
* Adds a {@link ServerInterceptor} that is run for all services on the server. Interceptors
|
||||||
* added through this method always run before per-service interceptors added through {@link
|
* added through this method always run before per-service interceptors added through {@link
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import io.grpc.ServerStreamTracer;
|
||||||
import io.grpc.ServerTransportFilter;
|
import io.grpc.ServerTransportFilter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
@ -85,6 +86,12 @@ public abstract class AbstractServerImplBuilder
|
||||||
return thisT();
|
return thisT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T addServices(List<ServerServiceDefinition> services) {
|
||||||
|
delegate().addServices(services);
|
||||||
|
return thisT();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T intercept(ServerInterceptor interceptor) {
|
public T intercept(ServerInterceptor interceptor) {
|
||||||
delegate().intercept(interceptor);
|
delegate().intercept(interceptor);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue