Package io.grpc

Class NameResolver.Factory

    • Constructor Detail

      • Factory

        public Factory()
    • Method Detail

      • newNameResolver

        public abstract NameResolver newNameResolver​(URI targetUri,
                                                     NameResolver.Args args)
        Creates a NameResolver for the given target URI, or null if 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.URI to io.grpc.Uri. Implementations will override newNameResolver(Uri, Args) instead.

        Parameters:
        targetUri - the target URI to be resolved, whose scheme must not be null
        args - other information that may be useful
        Since:
        1.21.0
      • newNameResolver

        public NameResolver newNameResolver​(io.grpc.Uri targetUri,
                                            NameResolver.Args args)
        Creates a NameResolver for the given target URI.

        Implementations return null if 'targetUri' cannot be resolved by this factory. The decision should be solely based on the target's scheme.

        All NameResolver.Factory implementations should override this method, as it will eventually replace newNameResolver(URI, Args). For backwards compatibility, this default implementation delegates to newNameResolver(URI, Args) if 'targetUri' can be converted to a java.net.URI.

        NB: Conversion is not always possible, for example scheme:#frag is a valid Uri but not a valid URI because its path is empty. The default implementation throws IllegalArgumentException in these cases.

        Parameters:
        targetUri - the target URI to be resolved
        args - 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 when ManagedChannelBuilder.forTarget(String) is given an authority string instead of a compliant URI.
        Since:
        1.0.0