diff options
author | Eric Anderson <ejona@google.com> | 2020-06-16 10:17:10 -0700 |
---|---|---|
committer | Eric Anderson <ejona86@gmail.com> | 2020-06-30 14:34:35 -0500 |
commit | debc3cdc7971c66b4f23a79dd7c37886520d5f37 (patch) | |
tree | da453af3ffd12a6dc001d46474e6b0e3b8dc9579 | |
parent | e42f96d02aea675872355bdb0fc10a0796f9edfe (diff) | |
download | grpc-grpc-java-debc3cdc7971c66b4f23a79dd7c37886520d5f37.tar.gz |
api: Add documentation for Provider SPI discovery
4 files changed, 26 insertions, 0 deletions
diff --git a/api/src/main/java/io/grpc/LoadBalancerProvider.java b/api/src/main/java/io/grpc/LoadBalancerProvider.java index 2b2db7a6d..bb4c57421 100644 --- a/api/src/main/java/io/grpc/LoadBalancerProvider.java +++ b/api/src/main/java/io/grpc/LoadBalancerProvider.java @@ -23,6 +23,16 @@ import java.util.Map; /** * Provider of {@link LoadBalancer}s. Each provider is bounded to a load-balancing policy name. * + * <p>Implementations can be automatically discovered by gRPC via Java's SPI mechanism. For + * automatic discovery, the implementation must have a zero-argument constructor and include + * a resource named {@code META-INF/services/io.grpc.LoadBalancerProvider} in their JAR. The + * file's contents should be the implementation's class name. Implementations that need arguments in + * their constructor can be manually registered by {@link LoadBalancerRegistry#register}. + * + * <p>Implementations <em>should not</em> throw. If they do, it may interrupt class loading. If + * exceptions may reasonably occur for implementation-specific reasons, implementations should + * generally handle the exception gracefully and return {@code false} from {@link #isAvailable()}. + * * @since 1.17.0 */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771") diff --git a/api/src/main/java/io/grpc/ManagedChannelProvider.java b/api/src/main/java/io/grpc/ManagedChannelProvider.java index 26e29727b..76a8d6707 100644 --- a/api/src/main/java/io/grpc/ManagedChannelProvider.java +++ b/api/src/main/java/io/grpc/ManagedChannelProvider.java @@ -25,6 +25,11 @@ import java.util.List; /** * Provider of managed channels for transport agnostic consumption. * + * <p>Implementations can be automatically discovered by gRPC via Java's SPI mechanism. For + * automatic discovery, the implementation must have a zero-argument constructor and include + * a resource named {@code META-INF/services/io.grpc.ManagedChannelProvider} in their JAR. The + * file's contents should be the implementation's class name. + * * <p>Implementations <em>should not</em> throw. If they do, it may interrupt class loading. If * exceptions may reasonably occur for implementation-specific reasons, implementations should * generally handle the exception gracefully and return {@code false} from {@link #isAvailable()}. diff --git a/api/src/main/java/io/grpc/NameResolverProvider.java b/api/src/main/java/io/grpc/NameResolverProvider.java index 8875092b0..6cf6e3716 100644 --- a/api/src/main/java/io/grpc/NameResolverProvider.java +++ b/api/src/main/java/io/grpc/NameResolverProvider.java @@ -21,6 +21,12 @@ import java.util.List; /** * Provider of name resolvers for name agnostic consumption. * + * <p>Implementations can be automatically discovered by gRPC via Java's SPI mechanism. For + * automatic discovery, the implementation must have a zero-argument constructor and include + * a resource named {@code META-INF/services/io.grpc.NameResolverProvider} in their JAR. The + * file's contents should be the implementation's class name. Implementations that need arguments in + * their constructor can be manually registered by {@link NameResolverRegistry#register}. + * * <p>Implementations <em>should not</em> throw. If they do, it may interrupt class loading. If * exceptions may reasonably occur for implementation-specific reasons, implementations should * generally handle the exception gracefully and return {@code false} from {@link #isAvailable()}. diff --git a/api/src/main/java/io/grpc/ServerProvider.java b/api/src/main/java/io/grpc/ServerProvider.java index 301d05b77..a6a28dd86 100644 --- a/api/src/main/java/io/grpc/ServerProvider.java +++ b/api/src/main/java/io/grpc/ServerProvider.java @@ -23,6 +23,11 @@ import java.util.Collections; /** * Provider of servers for transport agnostic consumption. * + * <p>Implementations can be automatically discovered by gRPC via Java's SPI mechanism. For + * automatic discovery, the implementation must have a zero-argument constructor and include + * a resource named {@code META-INF/services/io.grpc.ServerProvider} in their JAR. The + * file's contents should be the implementation's class name. + * * <p>Implementations <em>should not</em> throw. If they do, it may interrupt class loading. If * exceptions may reasonably occur for implementation-specific reasons, implementations should * generally handle the exception gracefully and return {@code false} from {@link #isAvailable()}. |