use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class JaxrsAsyncServletResource 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 JaxrsAsyncServletResource method setTimeoutHandler.
@POST
@Path("timeouthandler")
public void setTimeoutHandler(@QueryParam("stage") String stage, int handlerValue) {
JaxrsAsyncServletTimeoutHandler handler = new JaxrsAsyncServletTimeoutHandler(handlerValue);
AsyncResponse async = takeAsyncResponse(stage);
async.setTimeoutHandler(handler);
async.setTimeout(200L, TimeUnit.MILLISECONDS);
addResponse(async, stage);
}
use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class JaxrsAsyncServletResource 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 JaxrsAsyncServletResource method resume.
@POST
@Path("resume")
public String resume(@QueryParam("stage") String stage, String response) {
AsyncResponse async = takeAsyncResponse(stage);
boolean b = resume(async, response);
addResponse(async, stage);
return b ? TRUE : FALSE;
}
use of jakarta.ws.rs.container.AsyncResponse in project resteasy by resteasy.
the class LegacySuspendResource method timeout.
@GET
@Path("timeout")
@Produces("text/plain")
public void timeout(@Suspended final AsyncResponse response) {
response.setTimeout(100, TimeUnit.MILLISECONDS);
Thread t = new Thread() {
@Override
public void run() {
try {
Thread.sleep(1000);
Response jaxrs = Response.ok("hello").type(MediaType.TEXT_PLAIN).build();
response.resume(jaxrs);
} catch (Exception e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
logger.error(errors.toString());
}
}
};
t.start();
}
Aggregations