ServerProvider { @VisibleForTesting static final ServerProvider load(ClassLoader cl) { ServiceLoader<ServerProvider> providers = ServiceLoader.load(ServerProvider.class, cl); ServerProvider best = null; for (ServerProvider current : providers) { if (!current.isAvailable()) { continue; } else if (best == null) { best = current; } else if (current.priority() > best.priority()) { best = current; } } return best; }  static ServerProvider provider();  }
@Test public void multipleProvider() { ClassLoader cl = new ServicesClassLoader( getClass().getClassLoader(), "io/grpc/ServerProviderTest-multipleProvider.txt"); assertSame(Available7Provider.class, ServerProvider.load(cl).getClass()); }
@Test public void unavailableProvider() { ClassLoader cl = new ServicesClassLoader( getClass().getClassLoader(), "io/grpc/ServerProviderTest-unavailableProvider.txt"); assertNull(ServerProvider.load(cl)); }