Maven에서 *.thrift 컴파일 하기
프로그래밍 2015. 4. 9. 17:20
thrift
서로 다른 플랫폼 사이에 통신할 때 사용하면 편리하다.
물론 thrift를 사용하지 않고 간단하게 json으로 통신해도 좋지만,
thrift는 바이너리 형태로 통신할 수 있어,네트워크 트래픽을 줄일 수 있고,
컨테이너 자료형(List, Map, Set)이 있어 더 편리하다.
Maven
Maven으로 프로젝트 빌드시, maven antrun과 bat파일을 이용해 *thrift 파일을 컴파일 해보자.
테스트 방법
1) pom.xml에 다음과 같이 추가
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<pluginManagement> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>build-thrift</id> | |
<phase>install</phase> | |
<goals><goal>run</goal></goals> | |
<configuration> | |
<target> | |
<echo>thrift gen java</echo> | |
<!-- always use properties if available --> | |
<mkdir dir="${project.build.directory}/generated-sources/thrift" /> | |
<mkdir dir="${project.build.directory}/generated-sources/thrift/gen-java" /> | |
<delete dir="${project.build.directory}/generated-sources/thrift/gen-java" includeemptydirs="true"/> | |
<mkdir dir="${project.build.directory}/generated-sources/thrift/gen-java" /> | |
<exec executable="G:\project\Vert.x\thrift\thrift.cmd" failonerror="true"> | |
<arg value="-gen" /> | |
<arg value="java" /> | |
<arg value="-o" /> | |
<arg value="${project.build.directory}/generated-sources/thrift" /> | |
<!-- set the dir there are thrift files. --> | |
<arg value="${basedir}/src/main/thrift/" /> | |
</exec> | |
<!-- You never ever copy generated stuff back into src/* --> | |
<!-- use Build Helper Maven Plugin to add the generated source --> | |
<copy todir="src/main/java" overwrite="true"> | |
<fileset dir="target/generated-sources/thrift/gen-java" /> | |
</copy> | |
</target> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
... | |
</pluginManagement> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.8</version> | |
</plugin> | |
</plugins> | |
<build> |
2) thrift.cmd에 다음과 같이 추가
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for /R %5 %%i in (*.thrift) do G:\project\Vert.x\thrift\thrift-0.9.2 %1 %2 %3 %4 %%i |
3) thrift 파일을 src/main/thrift/에 만들기
4) 이클립스 프로젝트 -> R Click -> Run As -> Maven install
5) src/main/java폴더에 자동으로 파일들이 생성되었는지 확인
6) src/main/java폴더에 자동으로 생성된 파일에 컴파일 오류가 발생했다면, Java Complier를 1.7 이상으로 설정해 준다.
sample thrift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, | |
* software distributed under the License is distributed on an | |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
* KIND, either express or implied. See the License for the | |
* specific language governing permissions and limitations | |
* under the License. | |
*/ | |
/** | |
* This Thrift file can be included by other Thrift files that want to share | |
* these definitions. | |
*/ | |
namespace cpp shared | |
namespace d share // "shared" would collide with the eponymous D keyword. | |
namespace java com.sample.idl.shared | |
namespace perl shared | |
namespace php shared | |
//namespace haxe shared | |
struct SharedStruct { | |
1: i32 key | |
2: string valuefff | |
} | |
service SharedService { | |
SharedStruct getStruct(1: i32 key) | |
} |
자동으로 생성된 java 파일들
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Autogenerated by Thrift Compiler (0.9.2) | |
* | |
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
* @generated | |
*/ | |
package com.sample.idl.shared; | |
import org.apache.thrift.scheme.IScheme; | |
import org.apache.thrift.scheme.SchemeFactory; | |
import org.apache.thrift.scheme.StandardScheme; | |
import org.apache.thrift.scheme.TupleScheme; | |
import org.apache.thrift.protocol.TTupleProtocol; | |
import org.apache.thrift.protocol.TProtocolException; | |
import org.apache.thrift.EncodingUtils; | |
import org.apache.thrift.TException; | |
import org.apache.thrift.async.AsyncMethodCallback; | |
import org.apache.thrift.server.AbstractNonblockingServer.*; | |
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.Map; | |
import java.util.HashMap; | |
import java.util.EnumMap; | |
import java.util.Set; | |
import java.util.HashSet; | |
import java.util.EnumSet; | |
import java.util.Collections; | |
import java.util.BitSet; | |
import java.nio.ByteBuffer; | |
import java.util.Arrays; | |
import javax.annotation.Generated; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) | |
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-4-13") | |
public class SharedStruct implements org.apache.thrift.TBase<SharedStruct, SharedStruct._Fields>, java.io.Serializable, Cloneable, Comparable<SharedStruct> { | |
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SharedStruct"); | |
private static final org.apache.thrift.protocol.TField KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("key", org.apache.thrift.protocol.TType.I32, (short)1); | |
private static final org.apache.thrift.protocol.TField VALUEFFF_FIELD_DESC = new org.apache.thrift.protocol.TField("valuefff", org.apache.thrift.protocol.TType.STRING, (short)2); | |
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); | |
static { | |
schemes.put(StandardScheme.class, new SharedStructStandardSchemeFactory()); | |
schemes.put(TupleScheme.class, new SharedStructTupleSchemeFactory()); | |
} | |
public int key; // required | |
public String valuefff; // required | |
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ | |
public enum _Fields implements org.apache.thrift.TFieldIdEnum { | |
KEY((short)1, "key"), | |
VALUEFFF((short)2, "valuefff"); | |
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); | |
static { | |
for (_Fields field : EnumSet.allOf(_Fields.class)) { | |
byName.put(field.getFieldName(), field); | |
} | |
} | |
/** | |
* Find the _Fields constant that matches fieldId, or null if its not found. | |
*/ | |
public static _Fields findByThriftId(int fieldId) { | |
switch(fieldId) { | |
case 1: // KEY | |
return KEY; | |
case 2: // VALUEFFF | |
return VALUEFFF; | |
default: | |
return null; | |
} | |
} | |
/** | |
* Find the _Fields constant that matches fieldId, throwing an exception | |
* if it is not found. | |
*/ | |
public static _Fields findByThriftIdOrThrow(int fieldId) { | |
_Fields fields = findByThriftId(fieldId); | |
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); | |
return fields; | |
} | |
/** | |
* Find the _Fields constant that matches name, or null if its not found. | |
*/ | |
public static _Fields findByName(String name) { | |
return byName.get(name); | |
} | |
private final short _thriftId; | |
private final String _fieldName; | |
_Fields(short thriftId, String fieldName) { | |
_thriftId = thriftId; | |
_fieldName = fieldName; | |
} | |
public short getThriftFieldId() { | |
return _thriftId; | |
} | |
public String getFieldName() { | |
return _fieldName; | |
} | |
} | |
// isset id assignments | |
private static final int __KEY_ISSET_ID = 0; | |
private byte __isset_bitfield = 0; | |
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; | |
static { | |
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); | |
tmpMap.put(_Fields.KEY, new org.apache.thrift.meta_data.FieldMetaData("key", org.apache.thrift.TFieldRequirementType.DEFAULT, | |
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); | |
tmpMap.put(_Fields.VALUEFFF, new org.apache.thrift.meta_data.FieldMetaData("valuefff", org.apache.thrift.TFieldRequirementType.DEFAULT, | |
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); | |
metaDataMap = Collections.unmodifiableMap(tmpMap); | |
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SharedStruct.class, metaDataMap); | |
} | |
public SharedStruct() { | |
} | |
public SharedStruct( | |
int key, | |
String valuefff) | |
{ | |
this(); | |
this.key = key; | |
setKeyIsSet(true); | |
this.valuefff = valuefff; | |
} | |
/** | |
* Performs a deep copy on <i>other</i>. | |
*/ | |
public SharedStruct(SharedStruct other) { | |
__isset_bitfield = other.__isset_bitfield; | |
this.key = other.key; | |
if (other.isSetValuefff()) { | |
this.valuefff = other.valuefff; | |
} | |
} | |
public SharedStruct deepCopy() { | |
return new SharedStruct(this); | |
} | |
@Override | |
public void clear() { | |
setKeyIsSet(false); | |
this.key = 0; | |
this.valuefff = null; | |
} | |
public int getKey() { | |
return this.key; | |
} | |
public SharedStruct setKey(int key) { | |
this.key = key; | |
setKeyIsSet(true); | |
return this; | |
} | |
public void unsetKey() { | |
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __KEY_ISSET_ID); | |
} | |
/** Returns true if field key is set (has been assigned a value) and false otherwise */ | |
public boolean isSetKey() { | |
return EncodingUtils.testBit(__isset_bitfield, __KEY_ISSET_ID); | |
} | |
public void setKeyIsSet(boolean value) { | |
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __KEY_ISSET_ID, value); | |
} | |
public String getValuefff() { | |
return this.valuefff; | |
} | |
public SharedStruct setValuefff(String valuefff) { | |
this.valuefff = valuefff; | |
return this; | |
} | |
public void unsetValuefff() { | |
this.valuefff = null; | |
} | |
/** Returns true if field valuefff is set (has been assigned a value) and false otherwise */ | |
public boolean isSetValuefff() { | |
return this.valuefff != null; | |
} | |
public void setValuefffIsSet(boolean value) { | |
if (!value) { | |
this.valuefff = null; | |
} | |
} | |
public void setFieldValue(_Fields field, Object value) { | |
switch (field) { | |
case KEY: | |
if (value == null) { | |
unsetKey(); | |
} else { | |
setKey((Integer)value); | |
} | |
break; | |
case VALUEFFF: | |
if (value == null) { | |
unsetValuefff(); | |
} else { | |
setValuefff((String)value); | |
} | |
break; | |
} | |
} | |
public Object getFieldValue(_Fields field) { | |
switch (field) { | |
case KEY: | |
return Integer.valueOf(getKey()); | |
case VALUEFFF: | |
return getValuefff(); | |
} | |
throw new IllegalStateException(); | |
} | |
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ | |
public boolean isSet(_Fields field) { | |
if (field == null) { | |
throw new IllegalArgumentException(); | |
} | |
switch (field) { | |
case KEY: | |
return isSetKey(); | |
case VALUEFFF: | |
return isSetValuefff(); | |
} | |
throw new IllegalStateException(); | |
} | |
@Override | |
public boolean equals(Object that) { | |
if (that == null) | |
return false; | |
if (that instanceof SharedStruct) | |
return this.equals((SharedStruct)that); | |
return false; | |
} | |
public boolean equals(SharedStruct that) { | |
if (that == null) | |
return false; | |
boolean this_present_key = true; | |
boolean that_present_key = true; | |
if (this_present_key || that_present_key) { | |
if (!(this_present_key && that_present_key)) | |
return false; | |
if (this.key != that.key) | |
return false; | |
} | |
boolean this_present_valuefff = true && this.isSetValuefff(); | |
boolean that_present_valuefff = true && that.isSetValuefff(); | |
if (this_present_valuefff || that_present_valuefff) { | |
if (!(this_present_valuefff && that_present_valuefff)) | |
return false; | |
if (!this.valuefff.equals(that.valuefff)) | |
return false; | |
} | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
List<Object> list = new ArrayList<Object>(); | |
boolean present_key = true; | |
list.add(present_key); | |
if (present_key) | |
list.add(key); | |
boolean present_valuefff = true && (isSetValuefff()); | |
list.add(present_valuefff); | |
if (present_valuefff) | |
list.add(valuefff); | |
return list.hashCode(); | |
} | |
@Override | |
public int compareTo(SharedStruct other) { | |
if (!getClass().equals(other.getClass())) { | |
return getClass().getName().compareTo(other.getClass().getName()); | |
} | |
int lastComparison = 0; | |
lastComparison = Boolean.valueOf(isSetKey()).compareTo(other.isSetKey()); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
if (isSetKey()) { | |
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.key, other.key); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
} | |
lastComparison = Boolean.valueOf(isSetValuefff()).compareTo(other.isSetValuefff()); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
if (isSetValuefff()) { | |
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.valuefff, other.valuefff); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
} | |
return 0; | |
} | |
public _Fields fieldForId(int fieldId) { | |
return _Fields.findByThriftId(fieldId); | |
} | |
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { | |
schemes.get(iprot.getScheme()).getScheme().read(iprot, this); | |
} | |
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { | |
schemes.get(oprot.getScheme()).getScheme().write(oprot, this); | |
} | |
@Override | |
public String toString() { | |
StringBuilder sb = new StringBuilder("SharedStruct("); | |
boolean first = true; | |
sb.append("key:"); | |
sb.append(this.key); | |
first = false; | |
if (!first) sb.append(", "); | |
sb.append("valuefff:"); | |
if (this.valuefff == null) { | |
sb.append("null"); | |
} else { | |
sb.append(this.valuefff); | |
} | |
first = false; | |
sb.append(")"); | |
return sb.toString(); | |
} | |
public void validate() throws org.apache.thrift.TException { | |
// check for required fields | |
// check for sub-struct validity | |
} | |
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { | |
try { | |
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); | |
} catch (org.apache.thrift.TException te) { | |
throw new java.io.IOException(te); | |
} | |
} | |
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { | |
try { | |
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. | |
__isset_bitfield = 0; | |
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); | |
} catch (org.apache.thrift.TException te) { | |
throw new java.io.IOException(te); | |
} | |
} | |
private static class SharedStructStandardSchemeFactory implements SchemeFactory { | |
public SharedStructStandardScheme getScheme() { | |
return new SharedStructStandardScheme(); | |
} | |
} | |
private static class SharedStructStandardScheme extends StandardScheme<SharedStruct> { | |
public void read(org.apache.thrift.protocol.TProtocol iprot, SharedStruct struct) throws org.apache.thrift.TException { | |
org.apache.thrift.protocol.TField schemeField; | |
iprot.readStructBegin(); | |
while (true) | |
{ | |
schemeField = iprot.readFieldBegin(); | |
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { | |
break; | |
} | |
switch (schemeField.id) { | |
case 1: // KEY | |
if (schemeField.type == org.apache.thrift.protocol.TType.I32) { | |
struct.key = iprot.readI32(); | |
struct.setKeyIsSet(true); | |
} else { | |
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); | |
} | |
break; | |
case 2: // VALUEFFF | |
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { | |
struct.valuefff = iprot.readString(); | |
struct.setValuefffIsSet(true); | |
} else { | |
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); | |
} | |
break; | |
default: | |
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); | |
} | |
iprot.readFieldEnd(); | |
} | |
iprot.readStructEnd(); | |
// check for required fields of primitive type, which can't be checked in the validate method | |
struct.validate(); | |
} | |
public void write(org.apache.thrift.protocol.TProtocol oprot, SharedStruct struct) throws org.apache.thrift.TException { | |
struct.validate(); | |
oprot.writeStructBegin(STRUCT_DESC); | |
oprot.writeFieldBegin(KEY_FIELD_DESC); | |
oprot.writeI32(struct.key); | |
oprot.writeFieldEnd(); | |
if (struct.valuefff != null) { | |
oprot.writeFieldBegin(VALUEFFF_FIELD_DESC); | |
oprot.writeString(struct.valuefff); | |
oprot.writeFieldEnd(); | |
} | |
oprot.writeFieldStop(); | |
oprot.writeStructEnd(); | |
} | |
} | |
private static class SharedStructTupleSchemeFactory implements SchemeFactory { | |
public SharedStructTupleScheme getScheme() { | |
return new SharedStructTupleScheme(); | |
} | |
} | |
private static class SharedStructTupleScheme extends TupleScheme<SharedStruct> { | |
@Override | |
public void write(org.apache.thrift.protocol.TProtocol prot, SharedStruct struct) throws org.apache.thrift.TException { | |
TTupleProtocol oprot = (TTupleProtocol) prot; | |
BitSet optionals = new BitSet(); | |
if (struct.isSetKey()) { | |
optionals.set(0); | |
} | |
if (struct.isSetValuefff()) { | |
optionals.set(1); | |
} | |
oprot.writeBitSet(optionals, 2); | |
if (struct.isSetKey()) { | |
oprot.writeI32(struct.key); | |
} | |
if (struct.isSetValuefff()) { | |
oprot.writeString(struct.valuefff); | |
} | |
} | |
@Override | |
public void read(org.apache.thrift.protocol.TProtocol prot, SharedStruct struct) throws org.apache.thrift.TException { | |
TTupleProtocol iprot = (TTupleProtocol) prot; | |
BitSet incoming = iprot.readBitSet(2); | |
if (incoming.get(0)) { | |
struct.key = iprot.readI32(); | |
struct.setKeyIsSet(true); | |
} | |
if (incoming.get(1)) { | |
struct.valuefff = iprot.readString(); | |
struct.setValuefffIsSet(true); | |
} | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Autogenerated by Thrift Compiler (0.9.2) | |
* | |
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
* @generated | |
*/ | |
package com.sample.idl.shared; | |
import org.apache.thrift.scheme.IScheme; | |
import org.apache.thrift.scheme.SchemeFactory; | |
import org.apache.thrift.scheme.StandardScheme; | |
import org.apache.thrift.scheme.TupleScheme; | |
import org.apache.thrift.protocol.TTupleProtocol; | |
import org.apache.thrift.protocol.TProtocolException; | |
import org.apache.thrift.EncodingUtils; | |
import org.apache.thrift.TException; | |
import org.apache.thrift.async.AsyncMethodCallback; | |
import org.apache.thrift.server.AbstractNonblockingServer.*; | |
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.Map; | |
import java.util.HashMap; | |
import java.util.EnumMap; | |
import java.util.Set; | |
import java.util.HashSet; | |
import java.util.EnumSet; | |
import java.util.Collections; | |
import java.util.BitSet; | |
import java.nio.ByteBuffer; | |
import java.util.Arrays; | |
import javax.annotation.Generated; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) | |
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-4-13") | |
public class SharedService { | |
public interface Iface { | |
public SharedStruct getStruct(int key) throws org.apache.thrift.TException; | |
} | |
public interface AsyncIface { | |
public void getStruct(int key, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; | |
} | |
public static class Client extends org.apache.thrift.TServiceClient implements Iface { | |
public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> { | |
public Factory() {} | |
public Client getClient(org.apache.thrift.protocol.TProtocol prot) { | |
return new Client(prot); | |
} | |
public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { | |
return new Client(iprot, oprot); | |
} | |
} | |
public Client(org.apache.thrift.protocol.TProtocol prot) | |
{ | |
super(prot, prot); | |
} | |
public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { | |
super(iprot, oprot); | |
} | |
public SharedStruct getStruct(int key) throws org.apache.thrift.TException | |
{ | |
send_getStruct(key); | |
return recv_getStruct(); | |
} | |
public void send_getStruct(int key) throws org.apache.thrift.TException | |
{ | |
getStruct_args args = new getStruct_args(); | |
args.setKey(key); | |
sendBase("getStruct", args); | |
} | |
public SharedStruct recv_getStruct() throws org.apache.thrift.TException | |
{ | |
getStruct_result result = new getStruct_result(); | |
receiveBase(result, "getStruct"); | |
if (result.isSetSuccess()) { | |
return result.success; | |
} | |
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getStruct failed: unknown result"); | |
} | |
} | |
public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { | |
public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> { | |
private org.apache.thrift.async.TAsyncClientManager clientManager; | |
private org.apache.thrift.protocol.TProtocolFactory protocolFactory; | |
public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { | |
this.clientManager = clientManager; | |
this.protocolFactory = protocolFactory; | |
} | |
public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { | |
return new AsyncClient(protocolFactory, clientManager, transport); | |
} | |
} | |
public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { | |
super(protocolFactory, clientManager, transport); | |
} | |
public void getStruct(int key, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { | |
checkReady(); | |
getStruct_call method_call = new getStruct_call(key, resultHandler, this, ___protocolFactory, ___transport); | |
this.___currentMethod = method_call; | |
___manager.call(method_call); | |
} | |
public static class getStruct_call extends org.apache.thrift.async.TAsyncMethodCall { | |
private int key; | |
public getStruct_call(int key, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { | |
super(client, protocolFactory, transport, resultHandler, false); | |
this.key = key; | |
} | |
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { | |
prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getStruct", org.apache.thrift.protocol.TMessageType.CALL, 0)); | |
getStruct_args args = new getStruct_args(); | |
args.setKey(key); | |
args.write(prot); | |
prot.writeMessageEnd(); | |
} | |
public SharedStruct getResult() throws org.apache.thrift.TException { | |
if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { | |
throw new IllegalStateException("Method call not finished!"); | |
} | |
org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); | |
org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); | |
return (new Client(prot)).recv_getStruct(); | |
} | |
} | |
} | |
public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor { | |
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName()); | |
public Processor(I iface) { | |
super(iface, getProcessMap(new HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>())); | |
} | |
protected Processor(I iface, Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) { | |
super(iface, getProcessMap(processMap)); | |
} | |
private static <I extends Iface> Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) { | |
processMap.put("getStruct", new getStruct()); | |
return processMap; | |
} | |
public static class getStruct<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getStruct_args> { | |
public getStruct() { | |
super("getStruct"); | |
} | |
public getStruct_args getEmptyArgsInstance() { | |
return new getStruct_args(); | |
} | |
protected boolean isOneway() { | |
return false; | |
} | |
public getStruct_result getResult(I iface, getStruct_args args) throws org.apache.thrift.TException { | |
getStruct_result result = new getStruct_result(); | |
result.success = iface.getStruct(args.key); | |
return result; | |
} | |
} | |
} | |
public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> { | |
private static final Logger LOGGER = LoggerFactory.getLogger(AsyncProcessor.class.getName()); | |
public AsyncProcessor(I iface) { | |
super(iface, getProcessMap(new HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>())); | |
} | |
protected AsyncProcessor(I iface, Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) { | |
super(iface, getProcessMap(processMap)); | |
} | |
private static <I extends AsyncIface> Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase,?>> getProcessMap(Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) { | |
processMap.put("getStruct", new getStruct()); | |
return processMap; | |
} | |
public static class getStruct<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getStruct_args, SharedStruct> { | |
public getStruct() { | |
super("getStruct"); | |
} | |
public getStruct_args getEmptyArgsInstance() { | |
return new getStruct_args(); | |
} | |
public AsyncMethodCallback<SharedStruct> getResultHandler(final AsyncFrameBuffer fb, final int seqid) { | |
final org.apache.thrift.AsyncProcessFunction fcall = this; | |
return new AsyncMethodCallback<SharedStruct>() { | |
public void onComplete(SharedStruct o) { | |
getStruct_result result = new getStruct_result(); | |
result.success = o; | |
try { | |
fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); | |
return; | |
} catch (Exception e) { | |
LOGGER.error("Exception writing to internal frame buffer", e); | |
} | |
fb.close(); | |
} | |
public void onError(Exception e) { | |
byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; | |
org.apache.thrift.TBase msg; | |
getStruct_result result = new getStruct_result(); | |
{ | |
msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; | |
msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); | |
} | |
try { | |
fcall.sendResponse(fb,msg,msgType,seqid); | |
return; | |
} catch (Exception ex) { | |
LOGGER.error("Exception writing to internal frame buffer", ex); | |
} | |
fb.close(); | |
} | |
}; | |
} | |
protected boolean isOneway() { | |
return false; | |
} | |
public void start(I iface, getStruct_args args, org.apache.thrift.async.AsyncMethodCallback<SharedStruct> resultHandler) throws TException { | |
iface.getStruct(args.key,resultHandler); | |
} | |
} | |
} | |
public static class getStruct_args implements org.apache.thrift.TBase<getStruct_args, getStruct_args._Fields>, java.io.Serializable, Cloneable, Comparable<getStruct_args> { | |
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStruct_args"); | |
private static final org.apache.thrift.protocol.TField KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("key", org.apache.thrift.protocol.TType.I32, (short)1); | |
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); | |
static { | |
schemes.put(StandardScheme.class, new getStruct_argsStandardSchemeFactory()); | |
schemes.put(TupleScheme.class, new getStruct_argsTupleSchemeFactory()); | |
} | |
public int key; // required | |
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ | |
public enum _Fields implements org.apache.thrift.TFieldIdEnum { | |
KEY((short)1, "key"); | |
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); | |
static { | |
for (_Fields field : EnumSet.allOf(_Fields.class)) { | |
byName.put(field.getFieldName(), field); | |
} | |
} | |
/** | |
* Find the _Fields constant that matches fieldId, or null if its not found. | |
*/ | |
public static _Fields findByThriftId(int fieldId) { | |
switch(fieldId) { | |
case 1: // KEY | |
return KEY; | |
default: | |
return null; | |
} | |
} | |
/** | |
* Find the _Fields constant that matches fieldId, throwing an exception | |
* if it is not found. | |
*/ | |
public static _Fields findByThriftIdOrThrow(int fieldId) { | |
_Fields fields = findByThriftId(fieldId); | |
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); | |
return fields; | |
} | |
/** | |
* Find the _Fields constant that matches name, or null if its not found. | |
*/ | |
public static _Fields findByName(String name) { | |
return byName.get(name); | |
} | |
private final short _thriftId; | |
private final String _fieldName; | |
_Fields(short thriftId, String fieldName) { | |
_thriftId = thriftId; | |
_fieldName = fieldName; | |
} | |
public short getThriftFieldId() { | |
return _thriftId; | |
} | |
public String getFieldName() { | |
return _fieldName; | |
} | |
} | |
// isset id assignments | |
private static final int __KEY_ISSET_ID = 0; | |
private byte __isset_bitfield = 0; | |
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; | |
static { | |
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); | |
tmpMap.put(_Fields.KEY, new org.apache.thrift.meta_data.FieldMetaData("key", org.apache.thrift.TFieldRequirementType.DEFAULT, | |
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); | |
metaDataMap = Collections.unmodifiableMap(tmpMap); | |
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStruct_args.class, metaDataMap); | |
} | |
public getStruct_args() { | |
} | |
public getStruct_args( | |
int key) | |
{ | |
this(); | |
this.key = key; | |
setKeyIsSet(true); | |
} | |
/** | |
* Performs a deep copy on <i>other</i>. | |
*/ | |
public getStruct_args(getStruct_args other) { | |
__isset_bitfield = other.__isset_bitfield; | |
this.key = other.key; | |
} | |
public getStruct_args deepCopy() { | |
return new getStruct_args(this); | |
} | |
@Override | |
public void clear() { | |
setKeyIsSet(false); | |
this.key = 0; | |
} | |
public int getKey() { | |
return this.key; | |
} | |
public getStruct_args setKey(int key) { | |
this.key = key; | |
setKeyIsSet(true); | |
return this; | |
} | |
public void unsetKey() { | |
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __KEY_ISSET_ID); | |
} | |
/** Returns true if field key is set (has been assigned a value) and false otherwise */ | |
public boolean isSetKey() { | |
return EncodingUtils.testBit(__isset_bitfield, __KEY_ISSET_ID); | |
} | |
public void setKeyIsSet(boolean value) { | |
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __KEY_ISSET_ID, value); | |
} | |
public void setFieldValue(_Fields field, Object value) { | |
switch (field) { | |
case KEY: | |
if (value == null) { | |
unsetKey(); | |
} else { | |
setKey((Integer)value); | |
} | |
break; | |
} | |
} | |
public Object getFieldValue(_Fields field) { | |
switch (field) { | |
case KEY: | |
return Integer.valueOf(getKey()); | |
} | |
throw new IllegalStateException(); | |
} | |
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ | |
public boolean isSet(_Fields field) { | |
if (field == null) { | |
throw new IllegalArgumentException(); | |
} | |
switch (field) { | |
case KEY: | |
return isSetKey(); | |
} | |
throw new IllegalStateException(); | |
} | |
@Override | |
public boolean equals(Object that) { | |
if (that == null) | |
return false; | |
if (that instanceof getStruct_args) | |
return this.equals((getStruct_args)that); | |
return false; | |
} | |
public boolean equals(getStruct_args that) { | |
if (that == null) | |
return false; | |
boolean this_present_key = true; | |
boolean that_present_key = true; | |
if (this_present_key || that_present_key) { | |
if (!(this_present_key && that_present_key)) | |
return false; | |
if (this.key != that.key) | |
return false; | |
} | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
List<Object> list = new ArrayList<Object>(); | |
boolean present_key = true; | |
list.add(present_key); | |
if (present_key) | |
list.add(key); | |
return list.hashCode(); | |
} | |
@Override | |
public int compareTo(getStruct_args other) { | |
if (!getClass().equals(other.getClass())) { | |
return getClass().getName().compareTo(other.getClass().getName()); | |
} | |
int lastComparison = 0; | |
lastComparison = Boolean.valueOf(isSetKey()).compareTo(other.isSetKey()); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
if (isSetKey()) { | |
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.key, other.key); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
} | |
return 0; | |
} | |
public _Fields fieldForId(int fieldId) { | |
return _Fields.findByThriftId(fieldId); | |
} | |
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { | |
schemes.get(iprot.getScheme()).getScheme().read(iprot, this); | |
} | |
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { | |
schemes.get(oprot.getScheme()).getScheme().write(oprot, this); | |
} | |
@Override | |
public String toString() { | |
StringBuilder sb = new StringBuilder("getStruct_args("); | |
boolean first = true; | |
sb.append("key:"); | |
sb.append(this.key); | |
first = false; | |
sb.append(")"); | |
return sb.toString(); | |
} | |
public void validate() throws org.apache.thrift.TException { | |
// check for required fields | |
// check for sub-struct validity | |
} | |
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { | |
try { | |
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); | |
} catch (org.apache.thrift.TException te) { | |
throw new java.io.IOException(te); | |
} | |
} | |
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { | |
try { | |
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. | |
__isset_bitfield = 0; | |
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); | |
} catch (org.apache.thrift.TException te) { | |
throw new java.io.IOException(te); | |
} | |
} | |
private static class getStruct_argsStandardSchemeFactory implements SchemeFactory { | |
public getStruct_argsStandardScheme getScheme() { | |
return new getStruct_argsStandardScheme(); | |
} | |
} | |
private static class getStruct_argsStandardScheme extends StandardScheme<getStruct_args> { | |
public void read(org.apache.thrift.protocol.TProtocol iprot, getStruct_args struct) throws org.apache.thrift.TException { | |
org.apache.thrift.protocol.TField schemeField; | |
iprot.readStructBegin(); | |
while (true) | |
{ | |
schemeField = iprot.readFieldBegin(); | |
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { | |
break; | |
} | |
switch (schemeField.id) { | |
case 1: // KEY | |
if (schemeField.type == org.apache.thrift.protocol.TType.I32) { | |
struct.key = iprot.readI32(); | |
struct.setKeyIsSet(true); | |
} else { | |
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); | |
} | |
break; | |
default: | |
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); | |
} | |
iprot.readFieldEnd(); | |
} | |
iprot.readStructEnd(); | |
// check for required fields of primitive type, which can't be checked in the validate method | |
struct.validate(); | |
} | |
public void write(org.apache.thrift.protocol.TProtocol oprot, getStruct_args struct) throws org.apache.thrift.TException { | |
struct.validate(); | |
oprot.writeStructBegin(STRUCT_DESC); | |
oprot.writeFieldBegin(KEY_FIELD_DESC); | |
oprot.writeI32(struct.key); | |
oprot.writeFieldEnd(); | |
oprot.writeFieldStop(); | |
oprot.writeStructEnd(); | |
} | |
} | |
private static class getStruct_argsTupleSchemeFactory implements SchemeFactory { | |
public getStruct_argsTupleScheme getScheme() { | |
return new getStruct_argsTupleScheme(); | |
} | |
} | |
private static class getStruct_argsTupleScheme extends TupleScheme<getStruct_args> { | |
@Override | |
public void write(org.apache.thrift.protocol.TProtocol prot, getStruct_args struct) throws org.apache.thrift.TException { | |
TTupleProtocol oprot = (TTupleProtocol) prot; | |
BitSet optionals = new BitSet(); | |
if (struct.isSetKey()) { | |
optionals.set(0); | |
} | |
oprot.writeBitSet(optionals, 1); | |
if (struct.isSetKey()) { | |
oprot.writeI32(struct.key); | |
} | |
} | |
@Override | |
public void read(org.apache.thrift.protocol.TProtocol prot, getStruct_args struct) throws org.apache.thrift.TException { | |
TTupleProtocol iprot = (TTupleProtocol) prot; | |
BitSet incoming = iprot.readBitSet(1); | |
if (incoming.get(0)) { | |
struct.key = iprot.readI32(); | |
struct.setKeyIsSet(true); | |
} | |
} | |
} | |
} | |
public static class getStruct_result implements org.apache.thrift.TBase<getStruct_result, getStruct_result._Fields>, java.io.Serializable, Cloneable, Comparable<getStruct_result> { | |
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStruct_result"); | |
private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); | |
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); | |
static { | |
schemes.put(StandardScheme.class, new getStruct_resultStandardSchemeFactory()); | |
schemes.put(TupleScheme.class, new getStruct_resultTupleSchemeFactory()); | |
} | |
public SharedStruct success; // required | |
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ | |
public enum _Fields implements org.apache.thrift.TFieldIdEnum { | |
SUCCESS((short)0, "success"); | |
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); | |
static { | |
for (_Fields field : EnumSet.allOf(_Fields.class)) { | |
byName.put(field.getFieldName(), field); | |
} | |
} | |
/** | |
* Find the _Fields constant that matches fieldId, or null if its not found. | |
*/ | |
public static _Fields findByThriftId(int fieldId) { | |
switch(fieldId) { | |
case 0: // SUCCESS | |
return SUCCESS; | |
default: | |
return null; | |
} | |
} | |
/** | |
* Find the _Fields constant that matches fieldId, throwing an exception | |
* if it is not found. | |
*/ | |
public static _Fields findByThriftIdOrThrow(int fieldId) { | |
_Fields fields = findByThriftId(fieldId); | |
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); | |
return fields; | |
} | |
/** | |
* Find the _Fields constant that matches name, or null if its not found. | |
*/ | |
public static _Fields findByName(String name) { | |
return byName.get(name); | |
} | |
private final short _thriftId; | |
private final String _fieldName; | |
_Fields(short thriftId, String fieldName) { | |
_thriftId = thriftId; | |
_fieldName = fieldName; | |
} | |
public short getThriftFieldId() { | |
return _thriftId; | |
} | |
public String getFieldName() { | |
return _fieldName; | |
} | |
} | |
// isset id assignments | |
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; | |
static { | |
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); | |
tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, | |
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, SharedStruct.class))); | |
metaDataMap = Collections.unmodifiableMap(tmpMap); | |
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStruct_result.class, metaDataMap); | |
} | |
public getStruct_result() { | |
} | |
public getStruct_result( | |
SharedStruct success) | |
{ | |
this(); | |
this.success = success; | |
} | |
/** | |
* Performs a deep copy on <i>other</i>. | |
*/ | |
public getStruct_result(getStruct_result other) { | |
if (other.isSetSuccess()) { | |
this.success = new SharedStruct(other.success); | |
} | |
} | |
public getStruct_result deepCopy() { | |
return new getStruct_result(this); | |
} | |
@Override | |
public void clear() { | |
this.success = null; | |
} | |
public SharedStruct getSuccess() { | |
return this.success; | |
} | |
public getStruct_result setSuccess(SharedStruct success) { | |
this.success = success; | |
return this; | |
} | |
public void unsetSuccess() { | |
this.success = null; | |
} | |
/** Returns true if field success is set (has been assigned a value) and false otherwise */ | |
public boolean isSetSuccess() { | |
return this.success != null; | |
} | |
public void setSuccessIsSet(boolean value) { | |
if (!value) { | |
this.success = null; | |
} | |
} | |
public void setFieldValue(_Fields field, Object value) { | |
switch (field) { | |
case SUCCESS: | |
if (value == null) { | |
unsetSuccess(); | |
} else { | |
setSuccess((SharedStruct)value); | |
} | |
break; | |
} | |
} | |
public Object getFieldValue(_Fields field) { | |
switch (field) { | |
case SUCCESS: | |
return getSuccess(); | |
} | |
throw new IllegalStateException(); | |
} | |
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ | |
public boolean isSet(_Fields field) { | |
if (field == null) { | |
throw new IllegalArgumentException(); | |
} | |
switch (field) { | |
case SUCCESS: | |
return isSetSuccess(); | |
} | |
throw new IllegalStateException(); | |
} | |
@Override | |
public boolean equals(Object that) { | |
if (that == null) | |
return false; | |
if (that instanceof getStruct_result) | |
return this.equals((getStruct_result)that); | |
return false; | |
} | |
public boolean equals(getStruct_result that) { | |
if (that == null) | |
return false; | |
boolean this_present_success = true && this.isSetSuccess(); | |
boolean that_present_success = true && that.isSetSuccess(); | |
if (this_present_success || that_present_success) { | |
if (!(this_present_success && that_present_success)) | |
return false; | |
if (!this.success.equals(that.success)) | |
return false; | |
} | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
List<Object> list = new ArrayList<Object>(); | |
boolean present_success = true && (isSetSuccess()); | |
list.add(present_success); | |
if (present_success) | |
list.add(success); | |
return list.hashCode(); | |
} | |
@Override | |
public int compareTo(getStruct_result other) { | |
if (!getClass().equals(other.getClass())) { | |
return getClass().getName().compareTo(other.getClass().getName()); | |
} | |
int lastComparison = 0; | |
lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
if (isSetSuccess()) { | |
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
} | |
return 0; | |
} | |
public _Fields fieldForId(int fieldId) { | |
return _Fields.findByThriftId(fieldId); | |
} | |
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { | |
schemes.get(iprot.getScheme()).getScheme().read(iprot, this); | |
} | |
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { | |
schemes.get(oprot.getScheme()).getScheme().write(oprot, this); | |
} | |
@Override | |
public String toString() { | |
StringBuilder sb = new StringBuilder("getStruct_result("); | |
boolean first = true; | |
sb.append("success:"); | |
if (this.success == null) { | |
sb.append("null"); | |
} else { | |
sb.append(this.success); | |
} | |
first = false; | |
sb.append(")"); | |
return sb.toString(); | |
} | |
public void validate() throws org.apache.thrift.TException { | |
// check for required fields | |
// check for sub-struct validity | |
if (success != null) { | |
success.validate(); | |
} | |
} | |
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { | |
try { | |
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); | |
} catch (org.apache.thrift.TException te) { | |
throw new java.io.IOException(te); | |
} | |
} | |
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { | |
try { | |
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); | |
} catch (org.apache.thrift.TException te) { | |
throw new java.io.IOException(te); | |
} | |
} | |
private static class getStruct_resultStandardSchemeFactory implements SchemeFactory { | |
public getStruct_resultStandardScheme getScheme() { | |
return new getStruct_resultStandardScheme(); | |
} | |
} | |
private static class getStruct_resultStandardScheme extends StandardScheme<getStruct_result> { | |
public void read(org.apache.thrift.protocol.TProtocol iprot, getStruct_result struct) throws org.apache.thrift.TException { | |
org.apache.thrift.protocol.TField schemeField; | |
iprot.readStructBegin(); | |
while (true) | |
{ | |
schemeField = iprot.readFieldBegin(); | |
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { | |
break; | |
} | |
switch (schemeField.id) { | |
case 0: // SUCCESS | |
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { | |
struct.success = new SharedStruct(); | |
struct.success.read(iprot); | |
struct.setSuccessIsSet(true); | |
} else { | |
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); | |
} | |
break; | |
default: | |
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); | |
} | |
iprot.readFieldEnd(); | |
} | |
iprot.readStructEnd(); | |
// check for required fields of primitive type, which can't be checked in the validate method | |
struct.validate(); | |
} | |
public void write(org.apache.thrift.protocol.TProtocol oprot, getStruct_result struct) throws org.apache.thrift.TException { | |
struct.validate(); | |
oprot.writeStructBegin(STRUCT_DESC); | |
if (struct.success != null) { | |
oprot.writeFieldBegin(SUCCESS_FIELD_DESC); | |
struct.success.write(oprot); | |
oprot.writeFieldEnd(); | |
} | |
oprot.writeFieldStop(); | |
oprot.writeStructEnd(); | |
} | |
} | |
private static class getStruct_resultTupleSchemeFactory implements SchemeFactory { | |
public getStruct_resultTupleScheme getScheme() { | |
return new getStruct_resultTupleScheme(); | |
} | |
} | |
private static class getStruct_resultTupleScheme extends TupleScheme<getStruct_result> { | |
@Override | |
public void write(org.apache.thrift.protocol.TProtocol prot, getStruct_result struct) throws org.apache.thrift.TException { | |
TTupleProtocol oprot = (TTupleProtocol) prot; | |
BitSet optionals = new BitSet(); | |
if (struct.isSetSuccess()) { | |
optionals.set(0); | |
} | |
oprot.writeBitSet(optionals, 1); | |
if (struct.isSetSuccess()) { | |
struct.success.write(oprot); | |
} | |
} | |
@Override | |
public void read(org.apache.thrift.protocol.TProtocol prot, getStruct_result struct) throws org.apache.thrift.TException { | |
TTupleProtocol iprot = (TTupleProtocol) prot; | |
BitSet incoming = iprot.readBitSet(1); | |
if (incoming.get(0)) { | |
struct.success = new SharedStruct(); | |
struct.success.read(iprot); | |
struct.setSuccessIsSet(true); | |
} | |
} | |
} | |
} | |
} |
빌드 로그 확인
로그에 아래 내용이 포함되어 있어야 한다.
[INFO] --- maven-antrun-plugin:1.8:run (build-thrift) @ HelloWorld ---
[INFO] Executing tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[INFO] | |
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ HelloWorld --- | |
[INFO] Building jar: G:\project\HelloWorld\target\HelloWorld-0.0.1-SNAPSHOT.jar | |
[INFO] | |
[INFO] --- maven-install-plugin:2.4:install (default-install) @ HelloWorld --- | |
[INFO] Installing G:\project\HelloWorld\target\HelloWorld-0.0.1-SNAPSHOT.jar to G:\project\CommonSetting\Maven\repository\com\sample\HelloWorld\0.0.1-SNAPSHOT\HelloWorld-0.0.1-SNAPSHOT.jar | |
[INFO] Installing G:\project\HelloWorld\pom.xml to G:\project\CommonSetting\Maven\repository\com\sample\HelloWorld\0.0.1-SNAPSHOT\HelloWorld-0.0.1-SNAPSHOT.pom | |
[INFO] | |
[INFO] --- maven-antrun-plugin:1.8:run (build-thrift) @ HelloWorld --- | |
[INFO] Executing tasks | |
main: | |
[copy] Copying 2 files to G:\project\HelloWorld\src\main\java | |
[INFO] Executed tasks | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] BUILD SUCCESS | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Total time: 2.644 s | |
[INFO] Finished at: 2015-04-13T10:13:10+09:00 | |
[INFO] Final Memory: 15M/209M | |
[INFO] ------------------------------------------------------------------------ |
Posted by 약올랑