类com.google.protobuf.RpcChannel源码实例Demo

下面列出了怎么用com.google.protobuf.RpcChannel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: protobuf-socket-rpc   文件: IntegrationTest.java
private void doTest(RpcServer rpcServer) throws InterruptedException,
    ServiceException, IOException {
  BlockingRpcChannel blockingChannel = RpcChannels
      .newBlockingRpcChannel(clientConnectionFactory);
  RpcChannel channel = RpcChannels.newRpcChannel(clientConnectionFactory,
      threadPool);
  BlockingInterface blockingStub = TestService
      .newBlockingStub(blockingChannel);
  TestService stub = TestService.newStub(channel);

  try {
    rpcServer.startServer();
    Thread.sleep(500);

    doRpc(stub);
    doBlockingRpc(blockingStub);
    doBlockingRpc(blockingStub);
    doRpc(stub);
  } finally {
    Thread.sleep(500);
    System.out.println("Closing Client");
    if (clientConnectionFactory instanceof Closeable) {
      ((PersistentRpcConnectionFactory) clientConnectionFactory).close();
    }
    Thread.sleep(100);
    System.out.println("Closing Server");
    rpcServer.shutDown();
  }
}
 
源代码2 项目: fuchsia   文件: ProtobufferExporterTest.java
private AddressBookProtos.AddressBookService connectExportedProtobufAddress(ExportDeclaration declaration) throws EndpointException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, BinderException {
    ProtobufferExportDeclarationWrapper pojo = ProtobufferExportDeclarationWrapper.create(declaration);
    Bus cxfbus = BusFactory.getThreadDefaultBus();
    BindingFactoryManager mgr = cxfbus.getExtension(BindingFactoryManager.class);
    mgr.registerBindingFactory(ProtobufBindingFactory.PROTOBUF_BINDING_ID, new ProtobufBindingFactory(cxfbus));
    Class<?> bufferService = AddressBookProtos.AddressBookService.class;
    Class<?> bufferMessage = AddressBookProtos.AddressBookServiceMessage.class;
    Class<? extends Message> generic = bufferMessage.asSubclass(Message.class);
    RpcChannel channel = new SimpleRpcChannel(pojo.getAddress(), generic);
    Method method = bufferService.getMethod("newStub", RpcChannel.class);
    Object service = method.invoke(bufferService, channel);
    AddressBookProtos.AddressBookService addressBook = (AddressBookProtos.AddressBookService) service;
    return addressBook;
}
 
源代码3 项目: protobuf-socket-rpc   文件: RpcChannels.java
/**
 * Create a {@link RpcChannel} that uses the given
 * {@link RpcConnectionFactory} to connect to the RPC server and the given
 * {@link Executor} to listen for the RPC response after sending the request.
 * RPCs made using this {@link RpcChannel} will not block the thread calling
 * the RPC method. Use {@link #newBlockingRpcChannel(RpcConnectionFactory)} if
 * you want the RPC method to block.
 * <p>
 * This channel doesn't call the callback if the server-side implementation
 * did not call the callback. If any error occurs, it will call the callback
 * with null and update the controller with the error.
 */
public static RpcChannel newRpcChannel(
    RpcConnectionFactory connectionFactory, Executor executor) {
  return new RpcChannelImpl(connectionFactory, executor);
}
 
 类所在包
 同包方法