根据RestClientClass的create()方法
public static <T, R> T create(final Class<T> remoteService, final RemoteCallback<R> callback, Integer... successCodes) {
return create(remoteService, null, callback, null, successCodes);
}
在您提供的示例中;当使用create()方法时Errai得到CustomerService Class为remoteService,经过多次操作;
Errai 使用他们的 errai-codegen 库解析并实现此 CustomerService 接口,该库使用 Java Reflection API。
简单解析时;
让我使用您提供的示例来解释这些规则。
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
如果您检查here,还有一个附加说明,setEntityParameter 方法中存在异常;
每个方法只允许一个非注释实体参数:
这意味着您不能在您在 Errai 中发送的 Class 中定义具有超过 1 个非注释参数的方法。