ServerProvider.smali

.class public abstract Lio/grpc/ServerProvider;
.super Ljava/lang/Object;
.source "ServerProvider.java"


# static fields
.field private static final provider:Lio/grpc/ServerProvider;


# direct methods
.method static constructor <clinit>()V
    .registers 1

    .line 1
    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/Thread;->getContextClassLoader()Ljava/lang/ClassLoader;

    move-result-object v0

    invoke-static {v0}, Lio/grpc/ServerProvider;->load(Ljava/lang/ClassLoader;)Lio/grpc/ServerProvider;

    move-result-object v0

    sput-object v0, Lio/grpc/ServerProvider;->provider:Lio/grpc/ServerProvider;

    return-void
.end method

.method public constructor <init>()V
    .registers 1

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method static final load(Ljava/lang/ClassLoader;)Lio/grpc/ServerProvider;
    .registers 5

    .line 1
    const-class v0, Lio/grpc/ServerProvider;

    invoke-static {v0, p0}, Ljava/util/ServiceLoader;->load(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/ServiceLoader;

    move-result-object p0

    .line 2
    invoke-virtual {p0}, Ljava/util/ServiceLoader;->iterator()Ljava/util/Iterator;

    move-result-object p0

    const/4 v0, 0x0

    :cond_b
    :goto_b
    invoke-interface {p0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_2d

    invoke-interface {p0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lio/grpc/ServerProvider;

    .line 3
    invoke-virtual {v1}, Lio/grpc/ServerProvider;->isAvailable()Z

    move-result v2

    if-nez v2, :cond_1e

    goto :goto_b

    :cond_1e
    if-nez v0, :cond_21

    goto :goto_2b

    .line 4
    :cond_21
    invoke-virtual {v1}, Lio/grpc/ServerProvider;->priority()I

    move-result v2

    invoke-virtual {v0}, Lio/grpc/ServerProvider;->priority()I

    move-result v3

    if-le v2, v3, :cond_b

    :goto_2b
    move-object v0, v1

    goto :goto_b

    :cond_2d
    return-object v0
.end method

.method public static provider()Lio/grpc/ServerProvider;
    .registers 2

    .line 1
    sget-object v0, Lio/grpc/ServerProvider;->provider:Lio/grpc/ServerProvider;

    if-eqz v0, :cond_5

    return-object v0

    .line 2
    :cond_5
    new-instance v0, Lio/grpc/ManagedChannelProvider$ProviderNotFoundException;

    const-string v1, "No functional server found. Try adding a dependency on the grpc-netty artifact"

    invoke-direct {v0, v1}, Lio/grpc/ManagedChannelProvider$ProviderNotFoundException;-><init>(Ljava/lang/String;)V

    throw v0
.end method


# virtual methods
.method protected abstract builderForPort(I)Lio/grpc/ServerBuilder;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(I)",
            "Lio/grpc/ServerBuilder<",
            "*>;"
        }
    .end annotation
.end method

.method protected abstract isAvailable()Z
.end method

.method protected abstract priority()I
.end method