• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceDescriptorProto类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.protobuf.DescriptorProtos.ServiceDescriptorProto的典型用法代码示例。如果您正苦于以下问题:Java ServiceDescriptorProto类的具体用法?Java ServiceDescriptorProto怎么用?Java ServiceDescriptorProto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServiceDescriptorProto类属于com.google.protobuf.DescriptorProtos包,在下文中一共展示了ServiceDescriptorProto类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildServiceContext

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private ServiceContext buildServiceContext(ServiceDescriptorProto serviceProto, ProtoTypeMap typeMap, List<Location> locations, int serviceNumber) {
    ServiceContext serviceContext = new ServiceContext();
    serviceContext.fileName = getClassPrefix() + serviceProto.getName() + "Grpc.java";
    serviceContext.className = getClassPrefix() + serviceProto.getName() + "Grpc";
    serviceContext.serviceName = serviceProto.getName();
    serviceContext.deprecated = serviceProto.getOptions() != null && serviceProto.getOptions().getDeprecated();

    locations.stream()
            .filter(location -> location.getPathCount() == METHOD_NUMBER_OF_PATHS &&
                    location.getPath(0) == FileDescriptorProto.SERVICE_FIELD_NUMBER &&
                    location.getPath(1) == serviceNumber &&
                    location.getPath(2) == ServiceDescriptorProto.METHOD_FIELD_NUMBER)
            .forEach(location -> {
                int methodNumber = location.getPath(METHOD_NUMBER_OF_PATHS - 1);
                MethodContext methodContext = buildMethodContext(serviceProto.getMethod(methodNumber), typeMap);
                methodContext.methodNumber = methodNumber;
                methodContext.javaDoc = getJavaDoc(getComments(location), getMethodJavaDocPrefix());
                serviceContext.methods.add(methodContext);
            });
    return serviceContext;
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:22,代码来源:ReactiveGrpcGenerator.java


示例2: ServiceDescriptor

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private ServiceDescriptor(final ServiceDescriptorProto proto,
                          final FileDescriptor file,
                          final int index)
                   throws DescriptorValidationException {
  this.index = index;
  this.proto = proto;
  fullName = computeFullName(file, null, proto.getName());
  this.file = file;

  methods = new MethodDescriptor[proto.getMethodCount()];
  for (int i = 0; i < proto.getMethodCount(); i++) {
    methods[i] = new MethodDescriptor(
      proto.getMethod(i), file, this, i);
  }

  file.pool.addSymbol(this);
}
 
开发者ID:yeriomin,项目名称:play-store-api,代码行数:18,代码来源:Descriptors.java


示例3: decompile

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
public void decompile(FileDescriptorProto fileDescriptor) throws IOException {
    if (fileDescriptor.hasPackage()) {
        indentedFormat("package %s;", fileDescriptor.getPackage());
        absolutePackage = "." + fileDescriptor.getPackage() + ".";
    }
    for (String dependency : fileDescriptor.getDependencyList()) {
        indentedFormat("import \"%s\";", dependency);
    }
    if (fileDescriptor.hasOptions()) {
        decompileOptions(fileDescriptor.getOptions());
    }
    decompileMembers(fileDescriptor.getEnumTypeList(),
                     fileDescriptor.getMessageTypeList(),
                     Collections.<FieldDescriptorProto>emptyList(),
                     Collections.<DescriptorProto.ExtensionRange>emptyList(),
                     fileDescriptor.getExtensionList());
    for (ServiceDescriptorProto serviceDescriptor : fileDescriptor.getServiceList()) {
        decompile(serviceDescriptor);
    }
    newline();
    flush();
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:23,代码来源:ProtobufDecompiler.java


示例4: getFullName

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private static Optional<String> getFullName(FileDescriptorProto descriptor, List<Integer> path) {
    String fullNameSoFar = descriptor.getPackage();
    switch (path.get(0)) {
        case FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER:
            DescriptorProto message = descriptor.getMessageType(path.get(1));
            return appendMessageToFullName(message, path, fullNameSoFar);
        case FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER:
            EnumDescriptorProto enumDescriptor = descriptor.getEnumType(path.get(1));
            return Optional.of(appendEnumToFullName(enumDescriptor, path, fullNameSoFar));
        case FileDescriptorProto.SERVICE_FIELD_NUMBER:
            ServiceDescriptorProto serviceDescriptor = descriptor.getService(path.get(1));
            fullNameSoFar = appendNameComponent(fullNameSoFar, serviceDescriptor.getName());
            if (path.size() > 2) {
                fullNameSoFar = appendFieldComponent(
                        fullNameSoFar, serviceDescriptor.getMethod(path.get(3)).getName());
            }
            return Optional.of(fullNameSoFar);
        default:
            return Optional.empty();
    }
}
 
开发者ID:line,项目名称:armeria,代码行数:22,代码来源:GrpcDocStringExtractor.java


示例5: ServiceDescriptor

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private ServiceDescriptor (final ServiceDescriptorProto proto,
        final FileDescriptor file,
        final int index)
        throws DescriptorValidationException {
    this.index = index;
    this.proto = proto;
    fullName = computeFullName (file, null, proto.getName ());
    this.file = file;

    methods = new MethodDescriptor[proto.getMethodCount ()];
    for (int i = 0; i < proto.getMethodCount (); i++) {
        methods[i] = new MethodDescriptor (
                proto.getMethod (i), file, this, i);
    }

    file.pool.addSymbol (this);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:18,代码来源:Descriptors.java


示例6: makeCanonicalProto

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private FileDescriptorProto makeCanonicalProto(final FileDescriptor fileDescriptor) {
  final FileDescriptorProto.Builder protoBuilder =
      FileDescriptorProto.newBuilder(fileDescriptor.toProto());

  for (final FieldDescriptorProto.Builder field : protoBuilder.getExtensionBuilderList()) {
    makeCanonicalField(field, fileDescriptor.findExtensionByName(field.getName()));
  }

  for (final DescriptorProto.Builder message : protoBuilder.getMessageTypeBuilderList()) {
    makeCanonicalMessage(message, fileDescriptor.findMessageTypeByName(message.getName()));
  }

  // for (EnumDescriptorProto.Builder enumProto :
  // protoBuilder.getEnumTypeBuilderList()) {
  // makeCanonicalEnum(enumProto,
  // fileDescriptor.findEnumTypeByName(enumProto.getName()));
  // }

  for (final ServiceDescriptorProto.Builder serviceProto : protoBuilder.getServiceBuilderList()) {
    makeCanonicalService(serviceProto, fileDescriptor.findServiceByName(serviceProto.getName()));
  }

  // TODO: incorporate options' tree walking into canonicalization to eliminate double walking
  return OptionResolver.newBuilder().setCustomOptionsAsExtensions(false)
      .resolveAllOptionsFor(fileDescriptor, protoBuilder).build();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:27,代码来源:FileDescriptors.java


示例7: buildAllOptions

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private void buildAllOptions(final FileDescriptorProto.Builder proto) {
  if (!buildOptions(proto.getOptionsBuilder())) {
    proto.clearOptions();
  }

  for (final FieldDescriptorProto.Builder extensionProto : proto.getExtensionBuilderList()) {
    if (!buildOptions(extensionProto.getOptionsBuilder())) {
      extensionProto.clearOptions();
    }
  }

  for (final EnumDescriptorProto.Builder enumProto : proto.getEnumTypeBuilderList()) {
    buildAllOptions(enumProto);
  }

  for (final ServiceDescriptorProto.Builder serviceProto : proto.getServiceBuilderList()) {
    buildAllOptions(serviceProto);
  }

  for (final DescriptorProto.Builder messageProto : proto.getMessageTypeBuilderList()) {
    buildAllOptions(messageProto);
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:24,代码来源:OptionResolver.java


示例8: makeCanonicalProto

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private FileDescriptorProto makeCanonicalProto(final FileDescriptor file) {
  final FileDescriptorProto.Builder protoBuilder = FileDescriptorProto.newBuilder(file.toProto());

  for (final FieldDescriptorProto.Builder field : protoBuilder.getExtensionBuilderList()) {
    makeCanonicalField(field, file.findExtensionByName(field.getName()));
  }

  for (final DescriptorProto.Builder message : protoBuilder.getMessageTypeBuilderList()) {
    makeCanonicalMessage(message, file.findMessageTypeByName(message.getName()));
  }

  // for (EnumDescriptorProto.Builder enumProto :
  // protoBuilder.getEnumTypeBuilderList()) {
  // makeCanonicalEnum(enumProto,
  // file.findEnumTypeByName(enumProto.getName()));
  // }

  for (final ServiceDescriptorProto.Builder serviceProto : protoBuilder.getServiceBuilderList()) {
    makeCanonicalService(serviceProto, file.findServiceByName(serviceProto.getName()));
  }

  return OptionResolver.newBuilder().setCustomOptionsAsExtensions(reparseCustomOptions)
      .resolveAllOptionsFor(file, protoBuilder).build();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:25,代码来源:FileDescriptorEx.java


示例9: hasConflictingClassName

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
/** Checks whether any generated classes conflict with the given name. */
private static boolean hasConflictingClassName(FileDescriptorProto file, String name) {
  for (EnumDescriptorProto enumDesc : file.getEnumTypeList()) {
    if (name.equals(enumDesc.getName())) {
      return true;
    }
  }
  for (ServiceDescriptorProto serviceDesc : file.getServiceList()) {
    if (name.equals(serviceDesc.getName())) {
      return true;
    }
  }
  for (DescriptorProto messageDesc : file.getMessageTypeList()) {
    if (hasConflictingClassName(messageDesc, name)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:google,项目名称:closure-templates,代码行数:20,代码来源:JavaQualifiedNames.java


示例10: handle

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
public void handle(FileDescriptorProto protoFile) throws IOException {
  String javaPackage = inferJavaPackage(protoFile);
  boolean multipleFiles = protoFile.getOptions().getJavaMultipleFiles();
  String outerClassName = null;
  if (!multipleFiles) {
    if (protoFile.getOptions().hasJavaOuterClassname()) {
      outerClassName = protoFile.getOptions().getJavaOuterClassname();
    } else {
      outerClassName = inferOuterClassName(protoFile);
    }
  }
  ProtoServiceHandler serviceHandler = new ProtoServiceHandler(javaPackage, types,
      multipleFiles, outerClassName, protoFile.getPackage(), output);
  for (ServiceDescriptorProto service : protoFile.getServiceList()) {
    serviceHandler.handle(service);
  }
}
 
开发者ID:jsilland,项目名称:piezo,代码行数:18,代码来源:ProtoFileHandler.java


示例11: doPrint

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private void doPrint(FileDescriptorProto fdp, String javaPackage, String outerClassName) {
  List<DescriptorProto> messageDescList = Lists.newArrayList(fdp.getMessageTypeList());
  List<ServiceDescriptorProto> serviceDescList = Lists.newArrayList(fdp.getServiceList());
  List<EnumDescriptorProto> enumDescList = Lists.newArrayList(fdp.getEnumTypeList());
  messageDescList.stream().filter(temp -> temp.getEnumTypeList() != null)
      .forEach(temp -> enumDescList.addAll(temp.getEnumTypeList()));
  printEnum(enumDescList, javaPackage, outerClassName);
  printMessage(messageDescList, javaPackage, outerClassName);
  printService(serviceDescList, javaPackage);
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:11,代码来源:CommonProto2Java.java


示例12: printService

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private void printService(List<ServiceDescriptorProto> serviceDescList, String javaPackage) {
  for (ServiceDescriptorProto serviceDesc : serviceDescList) {
    PrintServiceFile serviceFile =
        new PrintServiceFile(generatePath, javaPackage, serviceDesc.getName());
    try {
      serviceFile.setServiceMethods(serviceDesc.getMethodList());
      serviceFile.setPojoTypeCache(pojoTypes);
    } finally {
      serviceFile.print();
    }
  }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:13,代码来源:CommonProto2Java.java


示例13: generateApi

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private ServiceDescriptorProto generateApi(Api api) {
  ServiceDescriptorProto.Builder builder = ServiceDescriptorProto.newBuilder();
  builder.setName(getSimpleName(api.getName()));
  for (Method method : api.getMethodsList()) {
    builder.addMethod(generateMethod(method));
  }
  if (!api.getOptionsList().isEmpty()) {
    builder.setOptions(generateServiceOptions(api));
  }
  return builder.build();
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:12,代码来源:DescriptorGenerator.java


示例14: Interface

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private Interface(ProtoFile parent, ServiceDescriptorProto proto, String path) {
  super(parent, proto.getName(), path);
  this.proto = proto;

  // Build methods.
  ImmutableList.Builder<Method> methodsBuilder = ImmutableList.builder();
  List<MethodDescriptorProto> methodProtos = proto.getMethodList();
  for (int i = 0; i < methodProtos.size(); i++) {
    String childPath = buildPath(path, ServiceDescriptorProto.METHOD_FIELD_NUMBER, i);
    methodsBuilder.add(Method.create(this, methodProtos.get(i), childPath));
  }

  methods = methodsBuilder.build();
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:15,代码来源:Interface.java


示例15: accept

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
@Accepts
protected void accept(ServiceDescriptorProto.Builder service) {
  pushParent(BuilderVisitorNodeInfo.create(service, currentFile));
  visitRepeated(ServiceDescriptorProto.METHOD_FIELD_NUMBER);
  visit(service.getOptionsBuilder());
  popExpectedParent(service);
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:8,代码来源:BuilderVisitor.java


示例16: setProto

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
/** See {@link FileDescriptor#setProto}. */
private void setProto(final ServiceDescriptorProto proto) {
  this.proto = proto;

  for (int i = 0; i < methods.length; i++) {
    methods[i].setProto(proto.getMethod(i));
  }
}
 
开发者ID:yeriomin,项目名称:play-store-api,代码行数:9,代码来源:Descriptors.java


示例17: setProto

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
/**
 * See {@link FileDescriptor#setProto}.
 */
private void setProto (final ServiceDescriptorProto proto) {
    this.proto = proto;

    for (int i = 0; i < methods.length; i++) {
        methods[i].setProto (proto.getMethod (i));
    }
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:11,代码来源:Descriptors.java


示例18: makeCanonicalService

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private void makeCanonicalService(final ServiceDescriptorProto.Builder service,
    final ServiceDescriptor serviceDescriptor) {
  for (final MethodDescriptorProto.Builder method : service.getMethodBuilderList()) {
    final MethodDescriptor methodDescriptor =
        serviceDescriptor.findMethodByName(method.getName());
    method.setInputType(ensureLeadingDot(methodDescriptor.getInputType().getFullName()));
    method.setOutputType(ensureLeadingDot(methodDescriptor.getOutputType().getFullName()));
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:10,代码来源:FileDescriptors.java


示例19: exitService

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
@Override
public void exitService(final ServiceContext ctx) {
  final ServiceDescriptorProto.Builder serviceBuilder =
      ServiceDescriptorProto.Builder.class.cast(scopes.getProtoBuilder());
  serviceBuilder.setName(ctx.identifier().getText());
  scopes.popScope();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:8,代码来源:ProtoFileParser.java


示例20: isCanonical

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入依赖的package包/类
private boolean isCanonical(final FileDescriptor file) {
  final FileDescriptorProto proto = file.toProto();

  if (proto.hasOptions() && proto.getOptions().getUninterpretedOptionCount() > 0) {
    return false;
  }

  for (final FieldDescriptorProto field : proto.getExtensionList()) {
    if (!isFieldCanonical(field)) {
      return false;
    }
  }

  for (final ServiceDescriptorProto serviceProto : proto.getServiceList()) {
    if (!isCanonical(serviceProto)) {
      return false;
    }
  }

  for (final EnumDescriptorProto enumProto : proto.getEnumTypeList()) {
    if (!isCanonical(enumProto)) {
      return false;
    }
  }

  for (final DescriptorProto message : proto.getMessageTypeList()) {
    if (!isMessageRefsCanonical(message)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:34,代码来源:FileDescriptorEx.java



注:本文中的com.google.protobuf.DescriptorProtos.ServiceDescriptorProto类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NotificationContext类代码示例发布时间:2022-05-22
下一篇:
Java CombineSequenceFileInputFormat类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap