本文整理汇总了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();
}