Class NameResolver.Factory
- java.lang.Object
-
- io.grpc.NameResolver.Factory
-
- Direct Known Subclasses:
NameResolverProvider
- Enclosing class:
- NameResolver
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770") public abstract static class NameResolver.Factory extends Object
Factory that createsNameResolverinstances.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description Factory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract StringgetDefaultScheme()Returns the default scheme, which will be used to construct a URI whenManagedChannelBuilder.forTarget(String)is given an authority string instead of a compliant URI.NameResolvernewNameResolver(io.grpc.Uri targetUri, NameResolver.Args args)Creates aNameResolverfor the given target URI.abstract NameResolvernewNameResolver(URI targetUri, NameResolver.Args args)Creates aNameResolverfor the given target URI, ornullif the given URI cannot be resolved by this factory.
-
-
-
Method Detail
-
newNameResolver
public abstract NameResolver newNameResolver(URI targetUri, NameResolver.Args args)
Creates aNameResolverfor the given target URI, ornullif the given URI cannot be resolved by this factory. The decision should be solely based on the scheme of the URI.This method will eventually be deprecated and removed as part of a migration from
java.net.URItoio.grpc.Uri. Implementations will overridenewNameResolver(Uri, Args)instead.- Parameters:
targetUri- the target URI to be resolved, whose scheme must not benullargs- other information that may be useful- Since:
- 1.21.0
-
newNameResolver
public NameResolver newNameResolver(io.grpc.Uri targetUri, NameResolver.Args args)
Creates aNameResolverfor the given target URI.Implementations return
nullif 'targetUri' cannot be resolved by this factory. The decision should be solely based on the target's scheme.All
NameResolver.Factoryimplementations should override this method, as it will eventually replacenewNameResolver(URI, Args). For backwards compatibility, this default implementation delegates tonewNameResolver(URI, Args)if 'targetUri' can be converted to a java.net.URI.NB: Conversion is not always possible, for example
scheme:#fragis a validUribut not a validURIbecause its path is empty. The default implementation throws IllegalArgumentException in these cases.- Parameters:
targetUri- the target URI to be resolvedargs- other information that may be useful- Throws:
IllegalArgumentException- if targetUri does not have the expected form- Since:
- 1.79
-
getDefaultScheme
public abstract String getDefaultScheme()
Returns the default scheme, which will be used to construct a URI whenManagedChannelBuilder.forTarget(String)is given an authority string instead of a compliant URI.- Since:
- 1.0.0
-
-