Package io.grpc.util
Class MutableHandlerRegistry
- java.lang.Object
-
- io.grpc.HandlerRegistry
-
- io.grpc.util.MutableHandlerRegistry
-
@ThreadSafe public final class MutableHandlerRegistry extends HandlerRegistry
Default implementation ofHandlerRegistry
.Uses
ConcurrentHashMap
to avoid service registration excessively blocking method lookup.
-
-
Constructor Summary
Constructors Constructor Description MutableHandlerRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServerServiceDefinition
addService(BindableService bindableService)
Registers a service.ServerServiceDefinition
addService(ServerServiceDefinition service)
Registers a service.List<ServerServiceDefinition>
getServices()
Note: This does not necessarily return a consistent view of the map.ServerMethodDefinition<?,?>
lookupMethod(String methodName, String authority)
Note: This does not actually honor the authority provided.boolean
removeService(ServerServiceDefinition service)
Removes a registered service.-
Methods inherited from class io.grpc.HandlerRegistry
lookupMethod
-
-
-
-
Method Detail
-
addService
@Nullable public ServerServiceDefinition addService(ServerServiceDefinition service)
Registers a service.- Returns:
- the previously registered service with the same service descriptor name if exists,
otherwise
null
.
-
addService
@Nullable public ServerServiceDefinition addService(BindableService bindableService)
Registers a service.- Returns:
- the previously registered service with the same service descriptor name if exists,
otherwise
null
.
-
removeService
public boolean removeService(ServerServiceDefinition service)
Removes a registered service.- Returns:
- true if the service was found to be removed.
-
getServices
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222") public List<ServerServiceDefinition> getServices()
Note: This does not necessarily return a consistent view of the map.- Overrides:
getServices
in classHandlerRegistry
-
lookupMethod
@Nullable public ServerMethodDefinition<?,?> lookupMethod(String methodName, @Nullable String authority)
Note: This does not actually honor the authority provided. It will, eventually in the future.- Specified by:
lookupMethod
in classHandlerRegistry
- Parameters:
methodName
- to lookupServerMethodDefinition
for.authority
- the authority for the desired method (to do virtual hosting). Ifnull
the first matching method will be returned.- Returns:
- the resolved method or
null
if no method for that name exists.
-
-