本文整理匯總了Java中org.apache.thrift.protocol.TProtocol.writeStructBegin方法的典型用法代碼示例。如果您正苦於以下問題:Java TProtocol.writeStructBegin方法的具體用法?Java TProtocol.writeStructBegin怎麽用?Java TProtocol.writeStructBegin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.thrift.protocol.TProtocol
的用法示例。
在下文中一共展示了TProtocol.writeStructBegin方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: encodeRequest
import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
protected void encodeRequest(Channel channel, ChannelBuffer buffer, Request request)
throws IOException {
Invocation invocation = (Invocation) request.getData();
TProtocol protocol = newProtocol(channel.getUrl(), buffer);
try {
protocol.writeMessageBegin(new TMessage(
invocation.getMethodName(), TMessageType.CALL,
thriftSeq.getAndIncrement()));
protocol.writeStructBegin(new TStruct(invocation.getMethodName() + "_args"));
for(int i = 0; i < invocation.getParameterTypes().length; i++) {
Class<?> type = invocation.getParameterTypes()[i];
}
} catch (TException e) {
throw new IOException(e.getMessage(), e);
}
}
示例2: writeResult
import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void writeResult(final TProtocol out, final TMessage msg, final WriterHandler onComplete, TBase args,
final TBase result) {
try {
onComplete.beforeWrite(msg, args, result);
// if (!isOneway()) {
out.writeMessageBegin(new TMessage(msg.name, TMessageType.REPLY, msg.seqid));
if (result != null) {
result.write(out);
} else {
out.writeStructBegin(null);
out.writeFieldStop();
out.writeStructEnd();
}
out.writeMessageEnd();
out.getTransport().flush();
// }
onComplete.afterWrite(msg, null, TMessageType.REPLY, args, result);
} catch (Throwable e) {
onComplete.afterWrite(msg, e, TMessageType.EXCEPTION, args, result);
}
}
示例3: write
import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
/**
* 寫入操作
*/
@Override
public void write(TProtocol oprot) throws TException {
if (!"org.apache.thrift.scheme.StandardScheme".equals(oprot.getScheme().getName()))
throw new TApplicationException("Service scheme must be 'org.apache.thrift.scheme.StandardScheme' !");
oprot.writeStructBegin(getTStruct());
if (str != null) {
oprot.writeFieldBegin(new TField("value", TType.STRING, (short) 0));
oprot.writeString(str);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}