考虑以下简单的RestEasy(JAX-RS)服务:
@Path("/example-service")
public interface ExampleService {
@Path("/ping")
@GET
public String ping(String message);
}
我想在接口上而不是类上定义JAXRS细节,这样我就可以使用nice客户机框架,即:
ExampleService client = ProxyFactory.create(ExampleService.class, "http://localhost:8080");
除了我想介绍一些resteay的上下文注入(即:@context)之外,所有东西都工作得很好。天真地考虑一下:
@Path("/example-service")
public interface ExampleService {
@Path("/ping")
@GET
public String ping(@Context HttpServletRequest request, String message);
}
这显然没有意义,因为@context注入是正交的,不属于接口(而且,即使我可以从客户机的角度克服这个接口的丑陋并传递空值,目前仍有一个bug阻止它工作:
RESTEASY-311
)
我如何使用接口JAXRS标记(因此可以利用好的RESTEasy客户机框架)并同时访问正交@context注入?