当前位置: 首页>>代码示例>>Java>>正文


Java ServiceDescriptor.findMethodByName方法代码示例

本文整理汇总了Java中com.google.protobuf.Descriptors.ServiceDescriptor.findMethodByName方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDescriptor.findMethodByName方法的具体用法?Java ServiceDescriptor.findMethodByName怎么用?Java ServiceDescriptor.findMethodByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.Descriptors.ServiceDescriptor的用法示例。


在下文中一共展示了ServiceDescriptor.findMethodByName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMethod

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
/**
 * Get matching method.
 */
public MethodDescriptor getMethod(String methodName, ServiceDescriptor descriptor) throws MethodNotFoundException {
    MethodDescriptor method = descriptor.findMethodByName(methodName);
    if (method == null) {
        throw new MethodNotFoundException(
                String.format("Could not find method %s in service %s", methodName, descriptor.getFullName())
        );
    }
    return method;
}
 
开发者ID:kevin-xu-158,项目名称:JavaNRPC,代码行数:13,代码来源:NrpcServiceRegistry.java

示例2: resolveServiceMethod

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
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;
}
 
开发者ID:grpc-ecosystem,项目名称:polyglot,代码行数:11,代码来源:ServiceResolver.java

示例3: getMethod

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
/**
 * Get matching method.
 */
private MethodDescriptor getMethod(SocketRpcProtos.Request rpcRequest,
    ServiceDescriptor descriptor) throws RpcException {
  MethodDescriptor method = descriptor.findMethodByName(
      rpcRequest.getMethodName());
  if (method == null) {
    throw new RpcException(
        ErrorReason.METHOD_NOT_FOUND,
        String.format("Could not find method %s in service %s",
            rpcRequest.getMethodName(), descriptor.getFullName()),
        null);
  }
  return method;
}
 
开发者ID:sdeo,项目名称:protobuf-socket-rpc,代码行数:17,代码来源:RpcForwarder.java

示例4: getMethodDescriptor

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
public static MethodDescriptor getMethodDescriptor(final String methodName,
    final ServiceDescriptor serviceDesc)
throws UnknownProtocolException {
  Descriptors.MethodDescriptor methodDesc = serviceDesc.findMethodByName(methodName);
  if (methodDesc == null) {
    throw new UnknownProtocolException("Unknown method " + methodName + " called on service " +
        serviceDesc.getFullName());
  }
  return methodDesc;
}
 
开发者ID:apache,项目名称:hbase,代码行数:11,代码来源:CoprocessorRpcUtils.java

示例5: makeCanonicalService

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的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

示例6: create

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
public static <RequestT extends Message, ResponseT extends Message> RpcMethod<RequestT, ResponseT> create(
        ServiceDescriptor descriptor, String methodName, RequestT requestDefaultInstance,
        ResponseT responseDefaultInstance) {
    MethodDescriptor method = descriptor.findMethodByName(methodName);
    Preconditions.checkArgument(method != null);

    Preconditions.checkArgument(requestDefaultInstance.getDescriptorForType() == method.getInputType());
    Preconditions.checkArgument(responseDefaultInstance.getDescriptorForType() == method.getOutputType());

    return new RpcMethod<RequestT, ResponseT>(method, responseDefaultInstance);
}
 
开发者ID:justinsb,项目名称:cloudata,代码行数:12,代码来源:ProtobufRpcClient.java

示例7: testCustomOptions

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
public void testCustomOptions() throws Exception {
  Descriptor descriptor =
    UnittestCustomOptions.TestMessageWithCustomOptions.getDescriptor();

  assertTrue(
    descriptor.getOptions().hasExtension(UnittestCustomOptions.messageOpt1));
  assertEquals(Integer.valueOf(-56),
    descriptor.getOptions().getExtension(UnittestCustomOptions.messageOpt1));

  FieldDescriptor field = descriptor.findFieldByName("field1");
  assertNotNull(field);

  assertTrue(
    field.getOptions().hasExtension(UnittestCustomOptions.fieldOpt1));
  assertEquals(Long.valueOf(8765432109L),
    field.getOptions().getExtension(UnittestCustomOptions.fieldOpt1));

  EnumDescriptor enumType =
    UnittestCustomOptions.TestMessageWithCustomOptions.AnEnum.getDescriptor();

  assertTrue(
    enumType.getOptions().hasExtension(UnittestCustomOptions.enumOpt1));
  assertEquals(Integer.valueOf(-789),
    enumType.getOptions().getExtension(UnittestCustomOptions.enumOpt1));

  ServiceDescriptor service =
    UnittestCustomOptions.TestServiceWithCustomOptions.getDescriptor();

  assertTrue(
    service.getOptions().hasExtension(UnittestCustomOptions.serviceOpt1));
  assertEquals(Long.valueOf(-9876543210L),
    service.getOptions().getExtension(UnittestCustomOptions.serviceOpt1));

  MethodDescriptor method = service.findMethodByName("Foo");
  assertNotNull(method);

  assertTrue(
    method.getOptions().hasExtension(UnittestCustomOptions.methodOpt1));
  assertEquals(UnittestCustomOptions.MethodOpt1.METHODOPT1_VAL2,
    method.getOptions().getExtension(UnittestCustomOptions.methodOpt1));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:42,代码来源:DescriptorsTest.java

示例8: testCustomOptions

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
public void testCustomOptions() throws Exception {
  // Get the descriptor indirectly from a dependent proto class. This is to
  // ensure that when a proto class is loaded, custom options defined in its
  // dependencies are also properly initialized.
  Descriptor descriptor =
      TestCustomOptions.TestMessageWithCustomOptionsContainer.getDescriptor()
      .findFieldByName("field").getMessageType();

  assertTrue(
    descriptor.getOptions().hasExtension(UnittestCustomOptions.messageOpt1));
  assertEquals(Integer.valueOf(-56),
    descriptor.getOptions().getExtension(UnittestCustomOptions.messageOpt1));

  FieldDescriptor field = descriptor.findFieldByName("field1");
  assertNotNull(field);

  assertTrue(
    field.getOptions().hasExtension(UnittestCustomOptions.fieldOpt1));
  assertEquals(Long.valueOf(8765432109L),
    field.getOptions().getExtension(UnittestCustomOptions.fieldOpt1));

  EnumDescriptor enumType =
    UnittestCustomOptions.TestMessageWithCustomOptions.AnEnum.getDescriptor();

  assertTrue(
    enumType.getOptions().hasExtension(UnittestCustomOptions.enumOpt1));
  assertEquals(Integer.valueOf(-789),
    enumType.getOptions().getExtension(UnittestCustomOptions.enumOpt1));

  ServiceDescriptor service =
    UnittestCustomOptions.TestServiceWithCustomOptions.getDescriptor();

  assertTrue(
    service.getOptions().hasExtension(UnittestCustomOptions.serviceOpt1));
  assertEquals(Long.valueOf(-9876543210L),
    service.getOptions().getExtension(UnittestCustomOptions.serviceOpt1));

  MethodDescriptor method = service.findMethodByName("Foo");
  assertNotNull(method);

  assertTrue(
    method.getOptions().hasExtension(UnittestCustomOptions.methodOpt1));
  assertEquals(UnittestCustomOptions.MethodOpt1.METHODOPT1_VAL2,
    method.getOptions().getExtension(UnittestCustomOptions.methodOpt1));
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:46,代码来源:DescriptorsTest.java

示例9: messageReceived

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
/**
	 * Find the service and process the remote RPC.
	 */
	@SuppressWarnings("unchecked")
	public void messageReceived(final IoSession session, Object message)
			throws Exception {
		RpcMessage request = (RpcMessage) message;
		final int id = request.getId();
		final String className = request.getClassName();
		final String methodName = request.getMethod();
		final String serviceName = request.getService();
		Class reqClass = null;
		try {
			reqClass = Class.forName(className);
		} catch (Exception e) {
			logger.warn("Cannot find " + className);
			sendResponse(session, id, Result.ERR, className, serviceName,
					methodName, null);
			return;
		}
		
		Method parseFromMethod = reqClass.getDeclaredMethod(PARSE_FROM_METHOD, PRASE_FROM_ARG); 
		Message reqMessage = null;
		ByteString payload = request.getPayload();
		if ( payload != null ) {
			reqMessage = (Message)parseFromMethod.invoke(reqClass, payload.toByteArray());
		}
		
		if ( logger.isDebugEnabled() ) {
			logger.debug("messageReceived id:{}, serviceName:{}, methodName:{}", new Object[]{id, serviceName, methodName});
		}
		
		SecureRpcCallback cb = new SecureRpcCallback(session, id, serviceName, methodName);
		
		Service service = GameContext.getInstance().findRpcService(
				serviceName, methodName);
		if ( service != null ) {
			ServiceDescriptor serviceDesc = service.getDescriptorForType();
			MethodDescriptor methodDesc = serviceDesc.findMethodByName(methodName);
			if ( methodDesc != null ) {
				service.callMethod(methodDesc, rpcController, reqMessage, cb);
//				if ( !cb.isCalled() ) {
//					logger.warn("You may forgot to call RpcCallback.run method in {}", serviceName);
//					sendResponse(session, id, Result.ERR, className, serviceName,
//							methodName, null);
//				}
			} else {
				logger.debug("Do not find the remote method: {}", methodName);
				sendResponse(session, id, Result.ERR, className, serviceName,
						methodName, null);
			}
		} else {
			logger.debug("Do not find the remote service: {}", serviceName);
			sendResponse(session, id, Result.ERR, className, serviceName,
					methodName, null);
		}
	}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:58,代码来源:RpcHandler.java

示例10: testCustomOptions

import com.google.protobuf.Descriptors.ServiceDescriptor; //导入方法依赖的package包/类
public void testCustomOptions() throws Exception {
  // Get the descriptor indirectly from a dependent proto class. This is to
  // ensure that when a proto class is loaded, custom options defined in its
  // dependencies are also properly initialized.
  Descriptor descriptor =
      TestCustomOptions.TestMessageWithCustomOptionsContainer.getDescriptor()
      .findFieldByName("field").getMessageType();

  assertTrue(
    descriptor.getOptions().hasExtension(UnittestCustomOptions.messageOpt1));
  assertEquals(Integer.valueOf(-56),
    descriptor.getOptions().getExtension(UnittestCustomOptions.messageOpt1));

  FieldDescriptor field = descriptor.findFieldByName("field1");
  assertNotNull(field);

  assertTrue(
    field.getOptions().hasExtension(UnittestCustomOptions.fieldOpt1));
  assertEquals(Long.valueOf(8765432109L),
    field.getOptions().getExtension(UnittestCustomOptions.fieldOpt1));

  OneofDescriptor oneof = descriptor.getOneofs().get(0);
  assertNotNull(oneof);

  assertTrue(
    oneof.getOptions().hasExtension(UnittestCustomOptions.oneofOpt1));
  assertEquals(Integer.valueOf(-99),
    oneof.getOptions().getExtension(UnittestCustomOptions.oneofOpt1));

  EnumDescriptor enumType =
    UnittestCustomOptions.TestMessageWithCustomOptions.AnEnum.getDescriptor();

  assertTrue(
    enumType.getOptions().hasExtension(UnittestCustomOptions.enumOpt1));
  assertEquals(Integer.valueOf(-789),
    enumType.getOptions().getExtension(UnittestCustomOptions.enumOpt1));

  ServiceDescriptor service =
    UnittestCustomOptions.TestServiceWithCustomOptions.getDescriptor();

  assertTrue(
    service.getOptions().hasExtension(UnittestCustomOptions.serviceOpt1));
  assertEquals(Long.valueOf(-9876543210L),
    service.getOptions().getExtension(UnittestCustomOptions.serviceOpt1));

  MethodDescriptor method = service.findMethodByName("Foo");
  assertNotNull(method);

  assertTrue(
    method.getOptions().hasExtension(UnittestCustomOptions.methodOpt1));
  assertEquals(UnittestCustomOptions.MethodOpt1.METHODOPT1_VAL2,
    method.getOptions().getExtension(UnittestCustomOptions.methodOpt1));
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:54,代码来源:DescriptorsTest.java


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