javax.ws.rs.container.AsyncResponse.isDone()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(30)

本文整理了Java中javax.ws.rs.container.AsyncResponse.isDone()方法的一些代码示例,展示了AsyncResponse.isDone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AsyncResponse.isDone()方法的具体详情如下:
包路径:javax.ws.rs.container.AsyncResponse
类名称:AsyncResponse
方法名:isDone

AsyncResponse.isDone介绍

[英]Check if the processing of a request this asynchronous response instance belongs to has finished. Method returns true if the processing of a request this asynchronous response is bound to is finished.

The request processing may be finished due to a normal termination, a suspend timeout, or cancellation -- in all of these cases, this method will return true.
[中]检查此异步响应实例所属的请求的处理是否已完成。如果此异步响应绑定到的请求的处理完成,则方法返回true。
请求处理可能由于正常终止、挂起超时或取消而完成——在所有这些情况下,此方法将返回true。

代码示例

代码示例来源:origin: confluentinc/kafka-streams-examples

/**
 * Use Kafka Streams' Queryable State API to work out if a key/value pair is located on
 * this node, or on another Kafka Streams node. This returned HostStoreInfo can be used
 * to redirect an HTTP request to the node that has the data.
 * <p>
 * If metadata is available, which can happen on startup, or during a rebalance, block until it is.
 */
private HostStoreInfo getKeyLocationOrBlock(String id, AsyncResponse asyncResponse) {
 HostStoreInfo locationOfKey;
 while (locationMetadataIsUnavailable(locationOfKey = getHostForOrderId(id))) {
  //The metastore is not available. This can happen on startup/rebalance.
  if (asyncResponse.isDone()) {
   //The response timed out so return
   return null;
  }
  try {
   //Sleep a bit until metadata becomes available
   Thread.sleep(Math.min(Long.valueOf(CALL_TIMEOUT), 200));
  } catch (InterruptedException e) {
   e.printStackTrace();
  }
 }
 return locationOfKey;
}

代码示例来源:origin: net.oneandone.reactive/reactive-http

@Override
  public void onComplete() {
    if (!asyncResponse.isDone()) {
      asyncResponse.resume(Response.noContent().build());
    }
  }
}

代码示例来源:origin: documents4j/documents4j

private void onCancel(ConverterNetworkProtocol.Status status) {
    if (asyncResponse.isDone()) {
      return;
    }
    synchronized (answerLock) {
      if (asyncResponse.isDone()) {
        return;
      }
      LOGGER.info("Sending cancellation response for {}", asyncResponse);
      asyncResponse.resume(Response
          .status(status.getStatusCode())
          .build());
    }
  }
}

代码示例来源:origin: documents4j/documents4j

@Override
public void onException(Exception e) {
  if (asyncResponse.isDone()) {
    return;
  }
  synchronized (answerLock) {
    if (asyncResponse.isDone()) {
      return;
    }
    LOGGER.info("Sending exceptional response for {}", asyncResponse, e);
    asyncResponse.resume(Response
        .status(ConverterNetworkProtocol.Status.describe(e).getStatusCode())
        .build());
  }
}

代码示例来源:origin: documents4j/documents4j

@Override
public void onComplete(InputStream inputStream) {
  if (asyncResponse.isDone()) {
    return;
  }
  synchronized (answerLock) {
    if (asyncResponse.isDone()) {
      return;
    }
    LOGGER.info("Sending successful response for {}", asyncResponse);
    asyncResponse.resume(Response
        .status(ConverterNetworkProtocol.Status.OK.getStatusCode())
        .entity(inputStream)
        .type(targetType.toString())
        .build());
  }
}

代码示例来源:origin: devicehive/devicehive-java-server

@Override
public void update(String topicName, PluginUpdateQuery updateQuery, String authorization, AsyncResponse asyncResponse) {
  HivePrincipal principal = (HivePrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  UserVO user = principal.getUser();
  PluginVO pluginVO = getPluginVO(topicName, asyncResponse, principal, user);
  if (!asyncResponse.isDone()) {
    pluginRegisterService.update(pluginVO, updateQuery)
        .thenAccept(asyncResponse::resume);
  }
}

代码示例来源:origin: devicehive/devicehive-java-server

@Override
public void delete(String topicName, String authorization, AsyncResponse asyncResponse) {
  HivePrincipal principal = (HivePrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  UserVO user = principal.getUser();
  PluginVO pluginVO = getPluginVO(topicName, asyncResponse, principal, user);
  if (!asyncResponse.isDone()) {
    pluginRegisterService.delete(pluginVO)
        .thenAccept(asyncResponse::resume);
  }
}

代码示例来源:origin: net.oneandone.reactive/reactive-http

@Override
  public void onComplete() {
    if (!asyncResponse.isDone()) {
      T element = elementRef.get();
      if (element == null) {
        asyncResponse.resume(new NotFoundException());
      } else {
        asyncResponse.resume(element);
      }
    }
  }
}

代码示例来源:origin: devicehive/devicehive-java-server

if (!asyncResponse.isDone()) {
  asyncResponse.resume(ResponseFactory.response(
      Response.Status.OK,
    .subscribe(filters, names, ts, callback);
pair.getRight().thenAccept(collection -> {
  if (!collection.isEmpty() && !asyncResponse.isDone()) {
    asyncResponse.resume(ResponseFactory.response(
        Response.Status.OK,
if (!asyncResponse.isDone()) {
  asyncResponse.resume(response);

代码示例来源:origin: devicehive/devicehive-java-server

if (!asyncResponse.isDone()) {
  asyncResponse.resume(ResponseFactory.response(
      OK,
    .sendSubscribeRequest(filters, names, ts, returnUpdated, limit, callback);
pair.getRight().thenAccept(collection -> {
  if (!collection.isEmpty() && !asyncResponse.isDone()) {
    asyncResponse.resume(ResponseFactory.response(
        OK,
if (!asyncResponse.isDone()) {
  asyncResponse.resume(response);

代码示例来源:origin: devicehive/devicehive-java-server

if (!asyncResponse.isDone()) {
  asyncResponse.resume(ResponseFactory.response(
      OK,
future.thenAccept(pair -> {
  final DeviceCommand deviceCommand = pair.getRight();
  if (!asyncResponse.isDone() && deviceCommand.getIsUpdated()) {
    asyncResponse.resume(ResponseFactory.response(
        OK,
    commandService.sendUnsubscribeRequest(Collections.singleton(future.get().getLeft()));
  } catch (InterruptedException | ExecutionException e) {
    if (!asyncResponse.isDone()) {
      asyncResponse.resume(ResponseFactory.response(INTERNAL_SERVER_ERROR));
if (!asyncResponse.isDone()) {
  asyncResponse.resume(ResponseFactory.response(OK, command, COMMAND_TO_DEVICE));

代码示例来源:origin: yahoo/fili

if (!asyncResponse.isDone()) {
  asyncResponse.resume(
    RequestHandlerUtils.makeErrorResponse(

相关文章