Package io.grpc.util

Class MutableHandlerRegistry


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

    Uses ConcurrentHashMap to avoid service registration excessively blocking method lookup.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.grpc.ServerServiceDefinition addService​(io.grpc.BindableService bindableService)
      Registers a service.
      io.grpc.ServerServiceDefinition addService​(io.grpc.ServerServiceDefinition service)
      Registers a service.
      java.util.List<io.grpc.ServerServiceDefinition> getServices()
      Note: This does not necessarily return a consistent view of the map.
      io.grpc.ServerMethodDefinition<?,​?> lookupMethod​(java.lang.String methodName, java.lang.String authority)
      Note: This does not actually honor the authority provided.
      boolean removeService​(io.grpc.ServerServiceDefinition service)
      Removes a registered service.
      • Methods inherited from class io.grpc.HandlerRegistry

        lookupMethod
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MutableHandlerRegistry

        public MutableHandlerRegistry()
    • Method Detail

      • addService

        @Nullable
        public io.grpc.ServerServiceDefinition addService​(io.grpc.ServerServiceDefinition service)
        Registers a service.
        Returns:
        the previously registered service with the same service descriptor name if exists, otherwise null.
      • addService

        @Nullable
        public io.grpc.ServerServiceDefinition addService​(io.grpc.BindableService bindableService)
        Registers a service.
        Returns:
        the previously registered service with the same service descriptor name if exists, otherwise null.
      • removeService

        public boolean removeService​(io.grpc.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 java.util.List<io.grpc.ServerServiceDefinition> getServices()
        Note: This does not necessarily return a consistent view of the map.
        Overrides:
        getServices in class io.grpc.HandlerRegistry
      • lookupMethod

        @Nullable
        public io.grpc.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 io.grpc.HandlerRegistry