Package io.grpc.util

Class MutableHandlerRegistry


  • @ThreadSafe
    public final class MutableHandlerRegistry
    extends HandlerRegistry
    Default implementation of HandlerRegistry.

    Uses ConcurrentHashMap to avoid service registration excessively blocking method lookup.

    • Constructor Detail

      • MutableHandlerRegistry

        public MutableHandlerRegistry()
    • 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.
      • lookupMethod

        @Nullable
        public ServerMethodDefinition<?,​?> lookupMethod​(java.lang.String methodName,
                                                              @Nullable
                                                              java.lang.String authority)
        Note: This does not actually honor the authority provided. It will, eventually in the future.
        Specified by:
        lookupMethod in class HandlerRegistry
        Parameters:
        methodName - to lookup ServerMethodDefinition for.
        authority - the authority for the desired method (to do virtual hosting). If null the first matching method will be returned.
        Returns:
        the resolved method or null if no method for that name exists.