Details
Description
My Resource class:
@Path("resource")
public class Resource
{
public static final String RESUMED = "Response resumed";
public static final String FALSE = "A method returned false";
public static final String TRUE = "A method return true";
//
private static final AsyncResponseBlockingQueue[] stage =
;
@GET
@Path("suspend")
public void suspend(@Suspended AsyncResponse asyncResponse)
@GET
@Path("cancelvoid")
public String cancel(@QueryParam("stage") String stage)
@POST
@Path("resume")
public String resume(@QueryParam("stage") String stage, String response)
protected static AsyncResponse takeAsyncResponse(String stageId)
{ return takeAsyncResponse(Integer.parseInt(stageId)); } protected static AsyncResponse takeAsyncResponse(int stageId)
{
final ResponseBuilder error = createErrorResponseBuilder();
AsyncResponse asyncResponse = null;
try
catch (InterruptedException e)
{ throw new WebApplicationException(error.entity( "ArrayBlockingQueue#take").build()); } return asyncResponse;
}
protected static final void addResponse(AsyncResponse response, String stageId)
{ int id = Integer.parseInt(stageId) + 1; if (id != stage.length) stage[id].add(response); }protected static boolean resume(AsyncResponse takenResponse, Object response)
{ return takenResponse.resume(response); }protected static ResponseBuilder createErrorResponseBuilder()
{ return Response.status(Status.EXPECTATION_FAILED); }}