本文整理了Java中javax.ws.rs.container.Suspended
类的一些代码示例,展示了Suspended
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Suspended
类的具体详情如下:
包路径:javax.ws.rs.container.Suspended
类名称:Suspended
暂无
代码示例来源:origin: prestodb/presto
@GET
@Path("{queryId}/{token}")
@Produces(MediaType.APPLICATION_JSON)
public void getQueryResults(
@PathParam("queryId") QueryId queryId,
@PathParam("token") long token,
@QueryParam("maxWait") Duration maxWait,
@QueryParam("targetResultSize") DataSize targetResultSize,
@HeaderParam(X_FORWARDED_PROTO) String proto,
@Context UriInfo uriInfo,
@Suspended AsyncResponse asyncResponse)
{
Query query = queries.get(queryId);
if (query == null) {
asyncResponse.resume(Response.status(Status.NOT_FOUND).build());
return;
}
if (isNullOrEmpty(proto)) {
proto = uriInfo.getRequestUri().getScheme();
}
asyncQueryResults(query, OptionalLong.of(token), maxWait, targetResultSize, uriInfo, proto, asyncResponse);
}
代码示例来源:origin: jersey/jersey
@GET
@Path("async")
public void suspendViaContextExample(@Suspended final AsyncResponse ar, @QueryParam("query") final String query) {
TASK_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(SLEEP_TIME_IN_MILLIS);
} catch (InterruptedException ex) {
LOGGER.log(Level.SEVERE, "Response processing interrupted", ex);
}
ar.resume("Complex result for " + query);
}
});
}
}
代码示例来源:origin: apache/incubator-pinot
@POST
@ManagedAsync
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/segments")
@ApiOperation(value = "Upload a segment", notes = "Upload a segment as binary")
// For the multipart endpoint, we will always move segment to final location regardless of the segment endpoint.
public void uploadSegmentAsMultiPart(FormDataMultiPart multiPart,
@ApiParam(value = "Whether to enable parallel push protection") @DefaultValue("false") @QueryParam(FileUploadDownloadClient.QueryParameters.ENABLE_PARALLEL_PUSH_PROTECTION) boolean enableParallelPushProtection,
@Context HttpHeaders headers, @Context Request request, @Suspended final AsyncResponse asyncResponse) {
try {
asyncResponse.resume(uploadSegment(multiPart, enableParallelPushProtection, headers, request, true));
} catch (Throwable t) {
asyncResponse.resume(t);
}
}
代码示例来源:origin: prestodb/presto
@DELETE
@Path("/v1/proxy")
@Produces(APPLICATION_JSON)
public void cancelQuery(
@QueryParam("uri") String uri,
@QueryParam("hmac") String hash,
@Context HttpServletRequest servletRequest,
@Suspended AsyncResponse asyncResponse)
{
if (!hmac.hashString(uri, UTF_8).equals(HashCode.fromString(hash))) {
throw badRequest(FORBIDDEN, "Failed to validate HMAC of URI");
}
Request.Builder request = prepareDelete().setUri(URI.create(uri));
performRequest(servletRequest, asyncResponse, request, response -> responseWithHeaders(noContent(), response));
}
代码示例来源:origin: jersey/jersey
@GET
@ManagedAsync
public void longGet(@Suspended final AsyncResponse ar, @QueryParam("id") int requestId) {
try {
Thread.sleep(SLEEP_TIME_IN_MILLIS);
} catch (InterruptedException ex) {
LOGGER.log(Level.SEVERE, "Response processing interrupted", ex);
}
ar.resume(requestId + " - " + NOTIFICATION_RESPONSE);
}
}
代码示例来源:origin: jersey/jersey
@GET
public void longGet(@Suspended final AsyncResponse ar) {
TASK_EXECUTOR.submit(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(SLEEP_TIME_IN_MILLIS);
} catch (InterruptedException ex) {
LOGGER.log(Level.SEVERE, "Response processing interrupted", ex);
}
ar.resume(NOTIFICATION_RESPONSE);
}
});
}
}
代码示例来源:origin: pravega/pravega
@GET
@Produces({ "application/json" })
@ApiOperation(
value = "", notes = "List all scopes in the system", response = ScopesList.class, tags = { })
@ApiResponses(value = {
@ApiResponse(
code = 200, message = "List of scope objects", response = ScopesList.class),
@ApiResponse(
code = 500, message = "Server error", response = ScopesList.class) })
void listScopes(@Context SecurityContext securityContext, @Suspended final AsyncResponse asyncResponse);
代码示例来源:origin: pravega/pravega
@POST
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(
value = "", notes = "Creates a new scope", response = ScopeProperty.class, tags = { })
@ApiResponses(value = {
@ApiResponse(
code = 201, message = "Successfully created the scope", response = ScopeProperty.class),
@ApiResponse(
code = 409, message = "Scope already exists", response = ScopeProperty.class),
@ApiResponse(
code = 500, message = "Server error", response = ScopeProperty.class) })
void createScope(
@ApiParam(value = "The scope configuration", required = true) CreateScopeRequest createScopeRequest,
@Context SecurityContext securityContext, @Suspended final AsyncResponse asyncResponse);
代码示例来源:origin: graphhopper/graphhopper
@POST
@Timed
@ManagedAsync
public void changeGraph(JsonFeatureCollection collection, @Suspended AsyncResponse response) {
response.resume(graphHopper.changeGraph(collection.getFeatures()));
}
代码示例来源:origin: prestodb/presto
@GET
@Path("/v1/proxy")
@Produces(APPLICATION_JSON)
public void getNext(
@QueryParam("uri") String uri,
@QueryParam("hmac") String hash,
@Context HttpServletRequest servletRequest,
@Context UriInfo uriInfo,
@Suspended AsyncResponse asyncResponse)
{
if (!hmac.hashString(uri, UTF_8).equals(HashCode.fromString(hash))) {
throw badRequest(FORBIDDEN, "Failed to validate HMAC of URI");
}
Request.Builder request = prepareGet().setUri(URI.create(uri));
performRequest(servletRequest, asyncResponse, request, response -> buildResponse(uriInfo, response));
}
代码示例来源:origin: apache/incubator-pinot
@POST
@ManagedAsync
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/v2/segments")
@ApiOperation(value = "Upload a segment", notes = "Upload a segment as binary")
// This behavior does not differ from v1 of the same endpoint.
public void uploadSegmentAsMultiPartV2(FormDataMultiPart multiPart,
@ApiParam(value = "Whether to enable parallel push protection") @DefaultValue("false") @QueryParam(FileUploadDownloadClient.QueryParameters.ENABLE_PARALLEL_PUSH_PROTECTION) boolean enableParallelPushProtection,
@Context HttpHeaders headers, @Context Request request, @Suspended final AsyncResponse asyncResponse) {
try {
asyncResponse.resume(uploadSegment(multiPart, enableParallelPushProtection, headers, request, true));
} catch (Throwable t) {
asyncResponse.resume(t);
}
}
代码示例来源:origin: prestodb/presto
@POST
@Path("/v1/statement")
@Produces(APPLICATION_JSON)
public void postStatement(
String statement,
@Context HttpServletRequest servletRequest,
@Context UriInfo uriInfo,
@Suspended AsyncResponse asyncResponse)
{
Request.Builder request = preparePost()
.setUri(uriBuilderFrom(remoteUri).replacePath("/v1/statement").build())
.setBodyGenerator(createStaticBodyGenerator(statement, UTF_8));
performRequest(servletRequest, asyncResponse, request, response -> buildResponse(uriInfo, response));
}
代码示例来源:origin: aol/micro-server
@GET
@Produces("application/json")
public void mainfest(@Suspended AsyncResponse asyncResponse, @Context ServletContext context) {
ReactiveSeq.of("/META-INF/MANIFEST.MF")
.map(url->context.getResourceAsStream(url))
.map(this::getManifest)
.foldFuture(WorkerThreads.ioExecutor.get(),
s->s.forEach(Long.MAX_VALUE,result->asyncResponse.resume(result)));
}
代码示例来源:origin: jersey/jersey
@GET
@ManagedAsync
public void getMessage(@Suspended final AsyncResponse ar) throws InterruptedException {
suspended.put(ar);
}
代码示例来源:origin: devicehive/devicehive-java-server
@DELETE
@PreAuthorize("isAuthenticated() and hasPermission(null, 'MANAGE_PLUGIN')")
@ApiOperation(value = "Delete Plugin", notes = "Deletes plugin in DH Server")
@ApiResponses(value = {
@ApiResponse(code = 403, message = "If principal does not have access to the plugin"),
@ApiResponse(code = 404, message = "If plugin not found")
})
void delete(
@QueryParam("topicName")
String topicName,
@ApiParam(name = "Authorization", value = "Authorization token", required = true)
@HeaderParam("Authorization")
String authorization,
@Suspended final AsyncResponse asyncResponse);
}
代码示例来源:origin: atomix/atomix
@GET
@Path("/{name}/value")
@Produces(MediaType.APPLICATION_JSON)
public void get(@PathParam("name") String name, @Suspended AsyncResponse response) {
getPrimitive(name).thenCompose(value -> value.get()).whenComplete((result, error) -> {
if (error == null) {
response.resume(Response.ok(result).build());
} else {
LOGGER.warn("{}", error);
response.resume(Response.serverError().build());
}
});
}
代码示例来源:origin: prestodb/presto
@GET
@Path("/v1/info")
@Produces(APPLICATION_JSON)
public void getInfo(
@Context HttpServletRequest servletRequest,
@Suspended AsyncResponse asyncResponse)
{
Request.Builder request = prepareGet()
.setUri(uriBuilderFrom(remoteUri).replacePath("/v1/info").build());
performRequest(servletRequest, asyncResponse, request, response ->
responseWithHeaders(Response.ok(response.getBody()), response));
}
代码示例来源:origin: apache/incubator-pinot
@POST
@ManagedAsync
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/segments")
@ApiOperation(value = "Upload a segment", notes = "Upload a segment as json")
// We use this endpoint with URI upload because a request sent with the multipart content type will reject the POST
// request if a multipart object is not sent. This endpoint does not move the segment to its final location;
// it keeps it at the downloadURI header that is set. We will not support this endpoint going forward.
public void uploadSegmentAsJson(String segmentJsonStr,
@ApiParam(value = "Whether to enable parallel push protection") @DefaultValue("false") @QueryParam(FileUploadDownloadClient.QueryParameters.ENABLE_PARALLEL_PUSH_PROTECTION) boolean enableParallelPushProtection,
@Context HttpHeaders headers, @Context Request request, @Suspended final AsyncResponse asyncResponse) {
try {
asyncResponse.resume(uploadSegment(null, enableParallelPushProtection, headers, request, false));
} catch (Throwable t) {
asyncResponse.resume(t);
}
}
代码示例来源:origin: devicehive/devicehive-java-server
@POST
@PreAuthorize("isAuthenticated() and hasPermission(null, 'MANAGE_PLUGIN')")
@ApiOperation(value = "Register Plugin", notes = "Registers plugin in DH Server")
@ApiResponses(value = {
@ApiResponse(code = 200,
message = "Returns plugin uuid, topic name and health check period",
response = PluginVO.class),
})
void register(
@BeanParam
PluginReqisterQuery pluginReqisterQuery,
@ApiParam(value = "Filter body", defaultValue = "{}", required = true)
PluginUpdate filterToCreate,
@ApiParam(name = "Authorization", value = "Authorization token", required = true)
@HeaderParam("Authorization")
String authorization,
@Suspended final AsyncResponse asyncResponse);
代码示例来源:origin: atomix/atomix
@DELETE
@Path("/{name}/lock")
public void unlock(@PathParam("name") String name, @Suspended AsyncResponse response) {
getPrimitive(name).thenCompose(lock -> lock.unlock()).whenComplete((result, error) -> {
if (error == null) {
response.resume(Response.ok().build());
} else {
LOGGER.warn("{}", error);
response.resume(Response.serverError().build());
}
});
}
}
内容来源于网络,如有侵权,请联系作者删除!