Java Code Examples for com.google.protobuf.Descriptors.FileDescriptor#findServiceByName()

The following examples show how to use com.google.protobuf.Descriptors.FileDescriptor#findServiceByName() . 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: ServiceResolver.java    From grpc-swagger with MIT License 5 votes vote down vote up
private ServiceDescriptor findService(String packageName, String serviceName) {
    // TODO(dino): Consider creating an index.
    for (FileDescriptor fileDescriptor : fileDescriptors) {
        if (!fileDescriptor.getPackage().equals(packageName)) {
            // Package does not match this file, ignore.
            continue;
        }

        ServiceDescriptor serviceDescriptor = fileDescriptor.findServiceByName(serviceName);
        if (serviceDescriptor != null) {
            return serviceDescriptor;
        }
    }
    throw new IllegalArgumentException("Unable to find service with name: " + serviceName);
}
 
Example 2
Source File: ServiceResolver.java    From milkman with MIT License 5 votes vote down vote up
private ServiceDescriptor findService(String serviceName, String packageName) {
  // TODO(dino): Consider creating an index.
  for (FileDescriptor fileDescriptor : fileDescriptors) {
    if (!fileDescriptor.getPackage().equals(packageName)) {
      // Package does not match this file, ignore.
      continue;
    }

    ServiceDescriptor serviceDescriptor = fileDescriptor.findServiceByName(serviceName);
    if (serviceDescriptor != null) {
      return serviceDescriptor;
    }
  }
  throw new IllegalArgumentException("Unable to find service with name: " + serviceName);
}
 
Example 3
Source File: ServiceResolver.java    From grpc-swagger with MIT License 5 votes vote down vote up
private ServiceDescriptor findService(String packageName, String serviceName) {
    // TODO(dino): Consider creating an index.
    for (FileDescriptor fileDescriptor : fileDescriptors) {
        if (!fileDescriptor.getPackage().equals(packageName)) {
            // Package does not match this file, ignore.
            continue;
        }

        ServiceDescriptor serviceDescriptor = fileDescriptor.findServiceByName(serviceName);
        if (serviceDescriptor != null) {
            return serviceDescriptor;
        }
    }
    throw new IllegalArgumentException("Unable to find service with name: " + serviceName);
}