use of com.google.protobuf.Descriptors.ServiceDescriptor in project tesla by linking12.
the class ServiceResolver method resolveServiceMethod.
private MethodDescriptor resolveServiceMethod(String serviceName, String methodName, String packageName) {
ServiceDescriptor service = findService(serviceName, packageName);
MethodDescriptor method = service.findMethodByName(methodName);
if (method == null) {
throw new IllegalArgumentException("Unable to find method " + methodName + " in service " + serviceName);
}
return method;
}
use of com.google.protobuf.Descriptors.ServiceDescriptor in project BIMserver by opensourceBIM.
the class ProtocolBuffersMetaData method load.
public String load(InputStream inputStream) {
try {
FileDescriptorSet descriptorSet = FileDescriptorSet.parseFrom(inputStream);
List<FileDescriptorProto> fileList = descriptorSet.getFileList();
FileDescriptorProto fileDescriptorProto = fileList.get(0);
FileDescriptor[] ar = new FileDescriptor[fileDescriptorProto.getDependencyCount()];
int i = 0;
for (String dep : fileDescriptorProto.getDependencyList()) {
FileDescriptor fileDescriptor = loaded.get(dep);
if (fileDescriptor == null) {
LOGGER.error("Dependency " + dep + " of " + fileDescriptorProto.getName() + " not found");
}
ar[i++] = fileDescriptor;
}
FileDescriptor fileDescriptor = FileDescriptor.buildFrom(fileDescriptorProto, ar);
loaded.put(fileDescriptor.getName(), fileDescriptor);
for (Descriptor descriptor : fileDescriptor.getMessageTypes()) {
this.messageDescriptors.put(descriptor.getName(), new MessageDescriptorContainer(descriptor));
}
for (ServiceDescriptor serviceDescriptor : fileDescriptor.getServices()) {
this.serviceDescriptors.put(serviceDescriptor.getName(), new ServiceDescriptorContainer(serviceDescriptor));
return serviceDescriptor.getName();
}
} catch (IOException e) {
LOGGER.error("", e);
} catch (DescriptorValidationException e) {
LOGGER.error("", e);
} finally {
try {
inputStream.close();
} catch (IOException e) {
LOGGER.error("", e);
}
}
return null;
}
Aggregations