本文整理汇总了Java中com.google.protobuf.DescriptorProtos.FileDescriptorSet.parseFrom方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptorSet.parseFrom方法的具体用法?Java FileDescriptorSet.parseFrom怎么用?Java FileDescriptorSet.parseFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.DescriptorProtos.FileDescriptorSet
的用法示例。
在下文中一共展示了FileDescriptorSet.parseFrom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadService
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
private void loadService() {
LOG.info("Load service definition is starting...");
InputStream in = null;
FileDescriptorSet descriptorSet;
try {
in = ClassHelper.getClassLoader().getResourceAsStream(GrpcConstants.PROTO_DESC_FILENAME);
descriptorSet = FileDescriptorSet.parseFrom(in);
for (FileDescriptorProto fdp : descriptorSet.getFileList()) {
FileDescriptor fd = FileDescriptor.buildFrom(fdp, new FileDescriptor[] {}, true);
for (com.google.protobuf.Descriptors.ServiceDescriptor service : fd.getServices()) {
addServiceDenifition(service.getName(),
fd.getOptions().getJavaPackage() + '.' + service.getFullName());
}
}
LOG.info("Load service denifition is finished, total {} service are found.", services.size());
} catch (Exception ex) {
LOG.error("Load service denifition error happened.", ex);
throw new RuntimeException(ex);
} finally {
IOUtils.closeInputStream(in);
}
}
示例2: parseFileAsDescriptorSet
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
private FileDescriptorSet parseFileAsDescriptorSet(
FileWrapper inputFile, ModelBuildOverrides registry, DiagCollector diagCollector) {
ByteString extensionFile = inputFile.getFileContents();
try {
return FileDescriptorSet.parseFrom(extensionFile, registry.getPlatformExtensions());
} catch (InvalidProtocolBufferException e) {
diagCollector.addDiag(
Diag.error(
SimpleLocation.TOPLEVEL,
"Cannot read file descriptor file '%s': %s",
inputFile.getFilename(),
e.getMessage()));
return null;
}
}
示例3: main
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
ProtobufDecompiler decompiler = new ProtobufDecompiler((Appendable)System.out);
FileDescriptorSet set;
try (FileInputStream istr = new FileInputStream(args[0])) {
set = FileDescriptorSet.parseFrom(istr);
}
decompiler.decompile(set);
}
示例4: getDescriptor
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
/** Returns the file descriptor set generated from the sources of this api. */
public FileDescriptorSet getDescriptor() throws IOException {
return FileDescriptorSet.parseFrom(Files.newInputStream(descriptorFile), EXTENSIONS);
}
示例5: parseFrom
import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
/**
* Parses a serialized schema descriptor (from byte array)
*
* @param schemaDescBuf the descriptor byte array
* @return the schema object
* @throws DescriptorValidationException
* @throws IOException
*/
public static DynamicSchema parseFrom(byte[] schemaDescBuf) throws DescriptorValidationException, IOException {
return new DynamicSchema(FileDescriptorSet.parseFrom(schemaDescBuf));
}