本文整理汇总了Java中com.google.protobuf.DescriptorProtos.MethodDescriptorProto类的典型用法代码示例。如果您正苦于以下问题:Java MethodDescriptorProto类的具体用法?Java MethodDescriptorProto怎么用?Java MethodDescriptorProto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodDescriptorProto类属于com.google.protobuf.DescriptorProtos包,在下文中一共展示了MethodDescriptorProto类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildMethodContext
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private MethodContext buildMethodContext(MethodDescriptorProto methodProto, ProtoTypeMap typeMap) {
MethodContext methodContext = new MethodContext();
methodContext.methodName = lowerCaseFirst(methodProto.getName());
methodContext.inputType = typeMap.toJavaTypeName(methodProto.getInputType());
methodContext.outputType = typeMap.toJavaTypeName(methodProto.getOutputType());
methodContext.deprecated = methodProto.getOptions() != null && methodProto.getOptions().getDeprecated();
methodContext.isManyInput = methodProto.getClientStreaming();
methodContext.isManyOutput = methodProto.getServerStreaming();
if (!methodProto.getClientStreaming() && !methodProto.getServerStreaming()) {
methodContext.reactiveCallsMethodName = "oneToOne";
methodContext.grpcCallsMethodName = "asyncUnaryCall";
}
if (!methodProto.getClientStreaming() && methodProto.getServerStreaming()) {
methodContext.reactiveCallsMethodName = "oneToMany";
methodContext.grpcCallsMethodName = "asyncServerStreamingCall";
}
if (methodProto.getClientStreaming() && !methodProto.getServerStreaming()) {
methodContext.reactiveCallsMethodName = "manyToOne";
methodContext.grpcCallsMethodName = "asyncClientStreamingCall";
}
if (methodProto.getClientStreaming() && methodProto.getServerStreaming()) {
methodContext.reactiveCallsMethodName = "manyToMany";
methodContext.grpcCallsMethodName = "asyncBidiStreamingCall";
}
return methodContext;
}
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:27,代码来源:ReactiveGrpcGenerator.java
示例2: generateMethod
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private String generateMethod(MethodDescriptorProto method, String inPutType, String outPutType,
String methodName, String inputValue) {
String methodStr =
"public " + outPutType + " " + methodName + "(" + inPutType + " " + inputValue + ");";
boolean isClientStream = !method.getServerStreaming() && method.getClientStreaming();
boolean isBidiStream = method.getServerStreaming() && method.getClientStreaming();
boolean isServerStream = method.getServerStreaming() && !method.getClientStreaming();
if (isClientStream || isBidiStream) {
methodStr =
"public " + inPutType + " " + methodName + "(" + outPutType + " responseObserver);";
} else if (isServerStream) {
methodStr = "public void " + methodName + "(" + inPutType + " " + inputValue + ","
+ outPutType + " responseObserver);";
}
return methodStr;
}
开发者ID:venus-boot,项目名称:saluki,代码行数:17,代码来源:PrintServiceFile.java
示例3: generateMethod
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private MethodDescriptorProto generateMethod(Method method) {
MethodDescriptorProto.Builder builder = MethodDescriptorProto.newBuilder();
builder.setName(method.getName());
builder.setInputType(getTypeName(method.getRequestTypeUrl()));
builder.setOutputType(getTypeName(method.getResponseTypeUrl()));
builder.setOptions(generateMethodOptions(method));
builder.setClientStreaming(method.getRequestStreaming());
// protoc set serverStreaming field as false for legacy streaming options,
// but google.protobuf.Method set the responseStreaming field to true for both new and legacy
// streaming setup. So we need to distinguish streaming style while generating
// MethodDescriptorProto.
// But we cannot distinguish if the new and old styles are both set which should be rare case.
if (method.getResponseStreaming() && isLegacyStreaming(method)) {
builder.setServerStreaming(false);
} else {
builder.setServerStreaming(method.getResponseStreaming());
}
return builder.build();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:20,代码来源:DescriptorGenerator.java
示例4: decompile
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
protected void decompile(ServiceDescriptorProto serviceDescriptor) throws IOException {
indentedFormat("service %s {", serviceDescriptor.getName());
indent++;
if (serviceDescriptor.hasOptions()) {
decompileOptions(serviceDescriptor.getOptions());
}
for (MethodDescriptorProto methodDescriptor : serviceDescriptor.getMethodList()) {
indentedFormat("rpc %s (%s) returns (%s)",
methodDescriptor.getName(), methodDescriptor.getInputType(), methodDescriptor.getOutputType());
if (methodDescriptor.hasOptions()) {
write("{ ");
indent++;
decompileOptions(methodDescriptor.getOptions());
indent--;
indentedFormat("}");
}
else {
write(";");
}
}
indent--;
indentedFormat("}");
}
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:24,代码来源:ProtobufDecompiler.java
示例5: collectFileData
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
@Override
protected List<String> collectFileData() {
String className = super.getClassName();
String packageName = super.getSourcePackageName().toLowerCase();
List<String> fileData = Lists.newArrayList();
fileData.add("package " + packageName + ";");
fileData.add("public interface " + className + "{");
for (MethodDescriptorProto method : serviceMethods) {
String outPutType = method.getOutputType();
String inPutType = method.getInputType();
String methodName = method.getName();
inPutType = CommonUtils.findPojoTypeFromCache(inPutType, pojoTypeCache);
outPutType = CommonUtils.findPojoTypeFromCache(outPutType, pojoTypeCache);
String stream = generateGrpcStream(method, inPutType, outPutType);
if (method.getServerStreaming() || method.getClientStreaming()) {
outPutType = "io.grpc.stub.StreamObserver<" + outPutType + ">";
}
String inputValue = CommonUtils.findNotIncludePackageType(inPutType).toLowerCase();
if (method.getClientStreaming()) {
inPutType = "io.grpc.stub.StreamObserver<" + inPutType + ">";
}
if (stream != null)
fileData.add(stream);
String methodStr = generateMethod(method, inPutType, outPutType, methodName, inputValue);
fileData.add(methodStr);
}
fileData.add("}");
return fileData;
}
开发者ID:venus-boot,项目名称:saluki,代码行数:30,代码来源:PrintServiceFile.java
示例6: Interface
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的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
示例7: Method
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private Method(Interface parent, MethodDescriptorProto proto, String path) {
super(parent, proto.getName(), path);
this.isDeprecated = proto.getOptions().getDeprecated();
this.descriptor = new MethodDescriptor(proto);
this.requestStreaming = proto.getClientStreaming();
this.responseStreaming = proto.getServerStreaming();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:8,代码来源:Method.java
示例8: MethodDescriptor
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private MethodDescriptor(final MethodDescriptorProto proto,
final FileDescriptor file,
final ServiceDescriptor parent,
final int index)
throws DescriptorValidationException {
this.index = index;
this.proto = proto;
this.file = file;
service = parent;
fullName = parent.getFullName() + '.' + proto.getName();
file.pool.addSymbol(this);
}
开发者ID:yeriomin,项目名称:play-store-api,代码行数:15,代码来源:Descriptors.java
示例9: MethodDescriptor
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private MethodDescriptor (final MethodDescriptorProto proto,
final FileDescriptor file,
final ServiceDescriptor parent,
final int index)
throws DescriptorValidationException {
this.index = index;
this.proto = proto;
this.file = file;
service = parent;
fullName = parent.getFullName () + '.' + proto.getName ();
file.pool.addSymbol (this);
}
开发者ID:BFergerson,项目名称:Beam,代码行数:15,代码来源:Descriptors.java
示例10: makeCanonicalService
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的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
示例11: exitMethodStatement
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
@Override
public void exitMethodStatement(final MethodStatementContext ctx) {
final MethodDescriptorProto.Builder methodBuilder =
MethodDescriptorProto.Builder.class.cast(scopes.getProtoBuilder());
methodBuilder.setName(ctx.identifier().getText()).setInputType(ctx.extendedId(0).getText())
.setOutputType(ctx.extendedId(1).getText());
scopes.popScope();
}
开发者ID:protobufel,项目名称:protobuf-el,代码行数:9,代码来源:ProtoFileParser.java
示例12: buildAllOptions
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private void buildAllOptions(final ServiceDescriptorProto.Builder proto) {
if (!buildOptions(proto.getOptionsBuilder())) {
proto.clearOptions();
}
for (final MethodDescriptorProto.Builder methodProto : proto.getMethodBuilderList()) {
if (!buildOptions(methodProto.getOptionsBuilder())) {
methodProto.clearOptions();
}
}
}
开发者ID:protobufel,项目名称:protobuf-el,代码行数:12,代码来源:OptionResolver.java
示例13: isCanonical
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private boolean isCanonical(final ServiceDescriptorProto serviceProto) {
if (serviceProto.hasOptions() && serviceProto.getOptions().getUninterpretedOptionCount() > 0) {
return false;
}
for (final MethodDescriptorProto methodProto : serviceProto.getMethodList()) {
if (methodProto.hasOptions() && methodProto.getOptions().getUninterpretedOptionCount() > 0) {
return false;
}
}
return true;
}
开发者ID:protobufel,项目名称:protobuf-el,代码行数:14,代码来源:FileDescriptorEx.java
示例14: handle
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
public void handle(ServiceDescriptorProto service) throws IOException {
ImmutableList.Builder<ServiceHandlerData.Method> methods = ImmutableList.builder();
for (MethodDescriptorProto method : service.getMethodList()) {
ServiceHandlerData.Method methodData = new ServiceHandlerData.Method(
method.getName(),
CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, method.getName()),
types.lookup(method.getInputType()).toString(),
types.lookup(method.getOutputType()).toString());
methods.add(methodData);
}
String fullName = Joiner.on('.').skipNulls().join(protoPackage, service.getName());
ServiceHandlerData.Service serviceData = new ServiceHandlerData.Service(
service.getName(), fullName, methods.build());
ServiceHandlerData data = new ServiceHandlerData(javaPackage, multipleFiles, serviceData);
String template = Resources.toString(Resources.getResource(this.getClass(),
"service_class.mvel"), Charsets.UTF_8);
String serviceFile = (String) TemplateRuntime.eval(template,
ImmutableMap.<String, Object>of("handler", data));
CodeGeneratorResponse.Builder response = CodeGeneratorResponse.newBuilder();
CodeGeneratorResponse.File.Builder file = CodeGeneratorResponse.File.newBuilder();
file.setContent(serviceFile);
file.setName(javaPackage.replace('.', '/') + '/' + service.getName() + ".java");
if (!multipleFiles) {
file.setName(javaPackage.replace('.', '/') + '/' + outerClassName + ".java");
file.setInsertionPoint("outer_class_scope");
}
response.addFile(file);
response.build().writeTo(output);
}
开发者ID:jsilland,项目名称:piezo,代码行数:34,代码来源:ProtoServiceHandler.java
示例15: setServiceMethods
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
public void setServiceMethods(List<MethodDescriptorProto> serviceMethods) {
this.serviceMethods = serviceMethods;
}
开发者ID:venus-boot,项目名称:saluki,代码行数:4,代码来源:PrintServiceFile.java
示例16: getOptions
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
public static List<Option> getOptions(MethodDescriptorProto descriptor) {
return getOptions(descriptor, true);
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:4,代码来源:DescriptorNormalization.java
示例17: create
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
/**
* Creates a method with {@link MethodDescriptorProto}.
*/
public static Method create(Interface parent, MethodDescriptorProto proto, String path) {
return new Method(parent, proto, path);
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:Method.java
示例18: MethodDescriptor
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private MethodDescriptor(MethodDescriptorProto methodProto) {
this.inputTypeName = methodProto.getInputType();
this.outputTypeName = methodProto.getOutputType();
this.optionFields = ImmutableMap.copyOf(methodProto.getOptions().getAllFields());
this.methodProto = methodProto;
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:Method.java
示例19: accept
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
@Accepts
protected void accept(MethodDescriptorProto.Builder method) {
pushParent(BuilderVisitorNodeInfo.create(method, currentFile));
visit(method.getOptionsBuilder());
popExpectedParent(method);
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:BuilderVisitor.java
示例20: restify
import com.google.protobuf.DescriptorProtos.MethodDescriptorProto; //导入依赖的package包/类
private void restify(MethodKind httpKind, String simpleName, String template) {
Model model = Model.create(FileDescriptorSet.getDefaultInstance());
model.setServiceConfig(
ConfigSource.newBuilder(Service.getDefaultInstance())
.setValue(
Service.getDescriptor().findFieldByNumber(Service.CONFIG_VERSION_FIELD_NUMBER),
null,
UInt32Value.newBuilder().setValue(configVersion).build(),
new SimpleLocation("from test"))
.build());
HttpConfigAspect aspect = HttpConfigAspect.create(model);
ProtoFile file =
ProtoFile.create(
model, FileDescriptorProto.getDefaultInstance(), true, ExtensionPool.EMPTY);
Interface iface = Interface.create(file, ServiceDescriptorProto.getDefaultInstance(), "");
Method method =
Method.create(iface, MethodDescriptorProto.newBuilder().setName(simpleName).build(), "");
RestMethod restMethod;
ImmutableList<PathSegment> path = parse(model, template);
if (!model.getDiagReporter().getDiagCollector().getDiags().isEmpty()) {
restMethod = RestMethod.create(method, RestKind.CUSTOM, "*error*", "*error*", null);
} else {
HttpRule httpRule = HttpRule.getDefaultInstance();
HttpAttribute httpConfig =
new HttpAttribute(
httpRule,
httpKind,
MessageType.create(file, Empty.getDescriptor().toProto(), "", ExtensionPool.EMPTY),
path,
"",
false,
ImmutableList.<HttpAttribute>of(),
false);
RestAnalyzer analyzer = new RestAnalyzer(aspect);
restMethod = analyzer.analyzeMethod(method, httpConfig);
}
PrintWriter pw = testOutput();
pw.print(httpKind.toString());
pw.print(" ");
pw.print(simpleName);
pw.print(" ");
pw.print(template.isEmpty() ? "(empty)" : template);
pw.println();
pw.println(Strings.repeat("=", 70));
pw.printf("Rest Kind: %s\n", restMethod.getRestKind());
pw.printf(
"Version: %s\n", restMethod.getVersion().isEmpty() ? "(empty)" : restMethod.getVersion());
pw.printf(
"Version with default: %s\n",
restMethod.getVersionWithDefault().isEmpty()
? "(empty)"
: restMethod.getVersionWithDefault());
pw.printf(
"Simple collection: %s\n",
restMethod.getRestCollectionName().isEmpty()
? "(empty)"
: restMethod.getSimpleRestCollectionName());
pw.printf(
"Versioned collection: %s\n",
restMethod.getRestCollectionName().isEmpty()
? "(empty)" : restMethod.getRestCollectionName());
pw.printf("Base collection: %s\n",
restMethod.getBaseRestCollectionName().isEmpty()
? "(empty)" : restMethod.getBaseRestCollectionName());
pw.printf("Custom Name: %s\n",
restMethod.getRestKind() == RestKind.CUSTOM
? restMethod.getRestMethodName() : "(null)");
List<Diag> diags = model.getDiagReporter().getDiagCollector().getDiags();
if (diags.size() > 0) {
pw.println("Diagnostics:");
for (Diag d : diags) {
pw.printf(" %s\n", DiagUtils.getDiagToPrint(d, true));
}
}
pw.println();
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:81,代码来源:RestAnalyzerTest.java
注:本文中的com.google.protobuf.DescriptorProtos.MethodDescriptorProto类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论