@@ -0,0 +1,3006 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements. See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership. The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License. You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage com.facebook.thrift;%0A%0Aimport com.facebook.thrift.protocol.TMessage;%0Aimport com.facebook.thrift.protocol.TMessageType;%0Aimport com.facebook.thrift.protocol.TProtocol;%0A%0A/**%0A * A TServiceClient is used to communicate with a TService implementation across protocols and%0A * transports.%0A */%0Apublic abstract class TServiceClient %7B%0A  public TServiceClient(TProtocol prot) %7B%0A    this(prot, prot);%0A  %7D%0A%0A  public TServiceClient(TProtocol iprot, TProtocol oprot) %7B%0A    iprot_ = iprot;%0A    oprot_ = oprot;%0A  %7D%0A%0A  protected TProtocol iprot_;%0A  protected TProtocol oprot_;%0A%0A  protected int seqid_;%0A%0A  /**%0A   * Get the TProtocol being used as the input (read) protocol.%0A   *%0A   * @return the TProtocol being used as the input (read) protocol.%0A   */%0A  public TProtocol getInputProtocol() %7B%0A    return this.iprot_;%0A  %7D%0A%0A  /**%0A   * Get the TProtocol being used as the output (write) protocol.%0A   *%0A   * @return the TProtocol being used as the output (write) protocol.%0A   */%0A  public TProtocol getOutputProtocol() %7B%0A    return this.oprot_;%0A  %7D%0A%0A  protected void sendBase(String methodName, TBase args) throws TException %7B%0A    sendBase(methodName, args, TMessageType.CALL);%0A  %7D%0A%0A  protected void sendBaseOneway(String methodName, TBase args) throws TException %7B%0A    sendBase(methodName, args, TMessageType.ONEWAY);%0A  %7D%0A%0A  private void sendBase(String methodName, TBase args, byte type) throws TException %7B%0A    oprot_.writeMessageBegin(new TMessage(methodName, type, ++seqid_));%0A    args.write(oprot_);%0A    oprot_.writeMessageEnd();%0A    oprot_.getTransport().flush();%0A  %7D%0A%0A  protected void receiveBase(TBase result, String methodName) throws TException %7B%0A    TMessage msg = iprot_.readMessageBegin();%0A    if (msg.type == TMessageType.EXCEPTION) %7B%0A      TApplicationException x = new TApplicationException();%0A      x.read(iprot_);%0A      iprot_.readMessageEnd();%0A      throw x;%0A    %7D%0A    if (msg.seqid != seqid_) %7B%0A      throw new TApplicationException(%0A          TApplicationException.BAD_SEQUENCE_ID,%0A          String.format(%0A              %22%25s failed: out of sequence response: expected %25d but got %25d%22,%0A              methodName, seqid_, msg.seqid));%0A    %7D%0A    result.read(iprot_);%0A    iprot_.readMessageEnd();%0A  %7D%0A%7D%0A

Introduce TServiceClient