Top Description Inners Fields Constructors Methods
io.grpc

public final Class ServerRegistry

extends Object
Class Inheritance
Annotations
@Internal
@ThreadSafe
Imports
com.google.common.annotations.VisibleForTesting, com.google.common.base.Preconditions, java.util.ArrayList, .Collections, .Comparator, .LinkedHashSet, .List, java.util.logging.Level, .Logger, javax.annotation.concurrent.GuardedBy, .ThreadSafe

Registry of ServerProviders. The default instance loads providers at runtime through the Java service provider mechanism.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ServerRegistry.ProviderNotFoundException

Thrown when no suitable ServerProvider objects can be found.

private static class

Field Summary

Modifier and TypeField and Description
private final LinkedHashSet<ServerProvider>
private List<ServerProvider>
effectiveProviders

Immutable, sorted version of allProviders.

private static ServerRegistry
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private synchronized void
public synchronized void
deregister(ServerProvider
the provider that was added to the register via register.
provider
)

Deregisters a provider.

public static synchronized ServerRegistry
getDefaultRegistry()

Returns the default registry that loads providers via the Java service loader mechanism.

pack-priv static List<Class<?>>
pack-priv ServerBuilder<?>
pack-priv ServerProvider
pack-priv synchronized List<ServerProvider>
providers()

Returns effective providers, in priority order.

private synchronized void
public synchronized void
register(ServerProvider provider)

Register a provider.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allProvidersback to summary
private final LinkedHashSet<ServerProvider> allProviders
Annotations
@GuardedBy:this
effectiveProvidersback to summary
private List<ServerProvider> effectiveProviders

Immutable, sorted version of allProviders. Is replaced instead of mutating.

Annotations
@GuardedBy:this
instanceback to summary
private static ServerRegistry instance
loggerback to summary
private static final Logger logger

Constructor Detail

ServerRegistryback to summary
public ServerRegistry()

Method Detail

addProviderback to summary
private synchronized void addProvider(ServerProvider provider)
deregisterback to summary
public synchronized void deregister(ServerProvider provider)

Deregisters a provider. No-op if the provider is not in the registry.

Parameters
provider:ServerProvider

the provider that was added to the register via register.

getDefaultRegistryback to summary
public static synchronized ServerRegistry getDefaultRegistry()

Returns the default registry that loads providers via the Java service loader mechanism.

getHardCodedClassesback to summary
pack-priv static List<Class<?>> getHardCodedClasses()
Annotations
@VisibleForTesting
newServerBuilderForPortback to summary
pack-priv ServerBuilder<?> newServerBuilderForPort(int port, ServerCredentials creds)
providerback to summary
pack-priv ServerProvider provider()
providersback to summary
pack-priv synchronized List<ServerProvider> providers()

Returns effective providers, in priority order.

Annotations
@VisibleForTesting
refreshProvidersback to summary
private synchronized void refreshProviders()
registerback to summary
public synchronized void register(ServerProvider provider)

Register a provider.

If the provider's isAvailable() returns false, this method will throw IllegalArgumentException.

Providers will be used in priority order. In case of ties, providers are used in registration order.

io.grpc back to summary

public final Class ServerRegistry.ProviderNotFoundException

extends RuntimeException
Class Inheritance

Thrown when no suitable ServerProvider objects can be found.

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

ProviderNotFoundExceptionback to summary
public ProviderNotFoundException(String msg)
io.grpc back to summary

private final Class ServerRegistry.ServerPriorityAccessor

extends Object
implements ServiceProviders.PriorityAccessor<ServerProvider>
Class Inheritance
All Implemented Interfaces
io.grpc.ServiceProviders.PriorityAccessor

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
getPriority(ServerProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.getPriority.

A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration.
public boolean
isAvailable(ServerProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.isAvailable.

Checks this provider is available for use, taking the current environment into consideration.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ServerPriorityAccessorback to summary
private ServerPriorityAccessor()

Method Detail

getPriorityback to summary
public int getPriority(ServerProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.getPriority.

Doc from io.grpc.ServiceProviders.PriorityAccessor.getPriority.

A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration. 5 should be considered the default, and then tweaked based on environment detection. A priority of 0 does not imply that the provider wouldn't work; just that it should be last in line.

Annotations
@Override
isAvailableback to summary
public boolean isAvailable(ServerProvider provider)

Implements io.grpc.ServiceProviders.PriorityAccessor.isAvailable.

Doc from io.grpc.ServiceProviders.PriorityAccessor.isAvailable.

Checks this provider is available for use, taking the current environment into consideration. If false, no other methods are safe to be called.

Annotations
@Override