我正在使用portal
javascript 库与我的 Java 套接字进行交互。我似乎无法确定如何将请求映射到以下资源上的方法。正在正确建立套接字@Path("workstation/approval/{uuid}")
,然后通过连接传递 JSON 数据。但是在 Java 方面,我如何将数据推送映射到方法以便我可以处理它?
@Path("workstation/approval/{uuid}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public class WorkstationResource {
ObjectMapper mapper = new ObjectMapper();
@Context
private BroadcasterFactory broadcasterFactory;
@GET
@Suspend
public Broadcastable get(@PathParam("uuid") String uuid) {
return new Broadcastable(getBroadcaster(uuid));
}
private Broadcaster getBroadcaster(String uuid) {
return broadcasterFactory.lookup(JerseyBroadcaster.class, "workstation/approval/"+uuid, true);
}
public String onMessage(String message) throws IOException {
return mapper.writeValueAsString("This is a test");
}
}