Package io.grpc

Class ServiceProviders

java.lang.Object
io.grpc.ServiceProviders

final class ServiceProviders extends Object
  • Constructor Details

    • ServiceProviders

      private ServiceProviders()
  • Method Details

    • load

      public static <T> T load(Class<T> klass, Iterable<Class<?>> hardcoded, ClassLoader cl, ServiceProviders.PriorityAccessor<T> priorityAccessor)
      If this is not Android, returns the highest priority implementation of the class via ServiceLoader. If this is Android, returns an instance of the highest priority class in hardcoded.
    • loadAll

      public static <T> List<T> loadAll(Class<T> klass, Iterable<Class<?>> hardcoded, ClassLoader cl, ServiceProviders.PriorityAccessor<T> priorityAccessor)
      If this is not Android, returns all available implementations discovered via ServiceLoader. If this is Android, returns all available implementations in hardcoded. The list is sorted in descending priority order.
    • isAndroid

      static boolean isAndroid(ClassLoader cl)
      Returns true if the ClassLoader is for android.
    • getCandidatesViaServiceLoader

      public static <T> Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl)
      Loads service providers for the klass service using ServiceLoader.
    • getCandidatesViaHardCoded

      static <T> Iterable<T> getCandidatesViaHardCoded(Class<T> klass, Iterable<Class<?>> hardcoded)
      Load providers from a hard-coded list. This avoids using getResource(), which has performance problems on Android (see https://github.com/grpc/grpc-java/issues/2037).
    • createForHardCoded

      private static <T> T createForHardCoded(Class<T> klass, Class<?> rawClass)