Java Code Examples for io.grpc.ServerServiceDefinition#getMethods()

The following examples show how to use io.grpc.ServerServiceDefinition#getMethods() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternalHandlerRegistry.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
/**
 * 重新设置服务和方法
 *
 * @author sxp
 * @since 2019/7/16
 */
@Override
public void resetServicesAndMethods(List<ServerServiceDefinition> newServices) {
  Map<String, ServerMethodDefinition<?, ?>> map = new HashMap<>();
  for (ServerServiceDefinition service : newServices) {
    for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
      map.put(method.getMethodDescriptor().getFullMethodName(), method);
    }
  }

  this.services = Collections.unmodifiableList(newServices);
  this.methods = Collections.unmodifiableMap(map);
}
 
Example 2
Source File: InternalHandlerRegistry.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
InternalHandlerRegistry build() {
  Map<String, ServerMethodDefinition<?, ?>> map =
      new HashMap<String, ServerMethodDefinition<?, ?>>();
  for (ServerServiceDefinition service : services.values()) {
    for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
      map.put(method.getMethodDescriptor().getFullMethodName(), method);
    }
  }
  return new InternalHandlerRegistry(
      Collections.unmodifiableList(new ArrayList<>(services.values())),
      Collections.unmodifiableMap(map));
}
 
Example 3
Source File: HandlerRegistry.java    From armeria with Apache License 2.0 5 votes vote down vote up
HandlerRegistry build() {
    final ImmutableMap.Builder<String, ServerMethodDefinition<?, ?>> mapBuilder =
            ImmutableMap.builder();
    for (ServerServiceDefinition service : services.values()) {
        for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
            mapBuilder.put(method.getMethodDescriptor().getFullMethodName(), method);
        }
    }
    return new HandlerRegistry(ImmutableList.copyOf(services.values()), mapBuilder.build());
}
 
Example 4
Source File: InternalHandlerRegistry.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
InternalHandlerRegistry build() {
  Map<String, ServerMethodDefinition<?, ?>> map =
      new HashMap<>();
  for (ServerServiceDefinition service : services.values()) {
    for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
      map.put(method.getMethodDescriptor().getFullMethodName(), method);
    }
  }
  return new InternalHandlerRegistry(
      Collections.unmodifiableList(new ArrayList<>(services.values())),
      Collections.unmodifiableMap(map));
}