私は Thrift の初心者で、Thrift ジェネレーター ファイルを作成する際に助けていただければ幸いです。さまざまな言語の多数のクライアントで Java サーバーを使用したいと考えています。これらのファイルを自動生成するために Thrift を使用しています。
これが私のThriftファイルです:
namespace php example
namespace py example
namespace csharp example
namespace cpp example
namespace perl example
namespace d example
namespace java javaobjectmethods
struct ExternalLibraryItem {
1: required string name
}
service ExampleService {
list<ExternalLibraryItem> javaObjectMethod(1:i32 count)
}
パッケージ javaObject に別の Java ファイルのセットがあり、javaObjectMethod はパッケージ内のメソッドの 1 つです。ただし、このメソッドは、外部ライブラリによってインスタンス化されたオブジェクトを返します。これをThriftファイルに次のものなしで書き込むにはどうすればよいですか:
struct ExternalLibraryItem {
1: required string name
}
現在、この行がないとサーバー ファイルを生成できません。
これが私のJavaファイルです:
package javaobjectmethods;
import externalLibrary.ExternalLibaryItem;
import externalLibrary.ExternalLibraryClass;
public class javaObject {
private String file;
public javaObject(String file) {
this.file = file;
}
public List<ExternalLibraryItem> javaObjectMethod(int count) {
// this method returns List<ExternalLibraryItem>
return ExternalLibraryClass.doThis(count, this.file);
}
}