我有其他api'/ users/{id}/checkin',我想在其中執行一些處理並在不同的資源上調用另一個rest API,但是使用相同的服務。例如。如何使用restEasy在同一進程中調用另一restapi使用restEasy
ServiceResource.java
@GET
@path(/services/checkin/)
public Response checkinUser(User user)
{
// --- processing.
}
UserResource.Java
@POST
@path(/users/{id}/checkin/)
public Response verifyUser(@PathParam("id) String id)
{
// --- Get the users from the iD.
User user = getUsers(id);
// --- need to call service from the serviceResource.
}
任何想法如何做到這一點?因爲我想避免HTTP客戶端調用。
這是一個公共方法,只是將它稱爲正常函數。製作一個對象並且調用它。 – Rjiuk
你好Rjiuk,謝謝你的回覆,但我不想做同樣的事情,因爲我希望它鬆散地加上它。調用方法會添加直接的依賴關係。 – user4828248