use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class CallbackResourceBase method isSuspended.
@GET
@Path("issuspended")
public String isSuspended(@QueryParam("stage") String stage) {
AsyncResponse response = takeAsyncResponse(stage);
boolean is = response.isSuspended();
addResponse(response, stage);
return is ? TRUE : FALSE;
}
use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class CallbackResourceBase method takeAsyncResponse.
protected static AsyncResponse takeAsyncResponse(int stageId) {
final ResponseBuilder error = createErrorResponseBuilder();
AsyncResponse asyncResponse = null;
try {
asyncResponse = stage[stageId].take();
} catch (InterruptedException e) {
throw new WebApplicationException(error.entity("ArrayBlockingQueue#take").build());
}
return asyncResponse;
}
use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class CallbackResourceBase method resumeWithCheckedException.
@GET
@Path("resumechecked")
public String resumeWithCheckedException(@QueryParam("stage") String stage) {
AsyncResponse async = takeAsyncResponse(stage);
boolean b = async.resume(new IOException(RESUMED));
addResponse(async, stage);
return b ? TRUE : FALSE;
}
use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class CallbackResourceBase method isCanceled.
@GET
@Path("iscanceled")
public String isCanceled(@QueryParam("stage") String stage) {
AsyncResponse response = takeAsyncResponse(stage);
boolean is = response.isCancelled();
addResponse(response, stage);
return is ? TRUE : FALSE;
}
use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class AsyncServletResource method timeout.
@GET
@Path("timeout")
@Produces("text/plain")
public void timeout(@Suspended final AsyncResponse response) {
response.setTimeout(10, TimeUnit.MILLISECONDS);
Thread t = new Thread() {
private Logger log = Logger.getLogger(AsyncServletResource.class);
@Override
public void run() {
try {
Thread.sleep(100000);
Response jaxrs = Response.ok("goodbye").type(MediaType.TEXT_PLAIN).build();
response.resume(jaxrs);
} catch (Exception e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
log.error(errors.toString());
}
}
};
t.start();
}
Aggregations