RestClient
クラスの create() メソッドによると
public static <T, R> T create(final Class<T> remoteService, final RemoteCallback<R> callback, Integer... successCodes) {
return create(remoteService, null, callback, null, successCodes);
}
あなたが提供した例では; remoteService
create() メソッドを使用すると、多くの操作の後、Errai は CustomerService クラスを として取得します。
Errai は、Java Reflection APIを使用するerrai-codegenライブラリを使用して、この CustomerService インターフェイスを解析および実装します。
単純に解析する場合;
あなたが提供した例を使用して、これらのルールを説明しましょう。
Customer customer = new Customer("new name", "new last name", "new postal code");
RestClient.create(CustomerService.class, callback).updateCustomer(240193, customer);
Errai は次のような URL を作成します。
example.com/cusomers/240193
@PathParam("id") アノテーション ルールは URL にパラメーターを追加しているため、Errai の entityParameter ルールに従ってcustomer
、PUT でデータを送信するときにマーシャリングされます。
@PUT
@Path("/{id}")
@Consumes("application/json")
@Produces("application/json")
public Customer updateCustomer(@PathParam("id") long id, Customer customer); //- See more at: http://errai-blog.blogspot.com.tr/2011/10/jax-rs-in-gwt-with-errai.html#sthash.2GTQtIg8.dpuf
ここをチェックすると、setEntityParameter メソッドに例外があることにもう 1 つ注意が必要です。
メソッドごとに許可される注釈なしのエンティティ パラメータは 1 つだけです。
これは、Errai で送信したクラスで、アノテーションのないパラメーターを 1 つ以上持つメソッドを定義できないことを意味します。