当前位置: 首页>>代码示例>>Java>>正文


Java Result类代码示例

本文整理汇总了Java中org.eclipse.jetty.client.api.Result的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Result类属于org.eclipse.jetty.client.api包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResponseComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
protected void onResponseComplete(Result result, byte[] content) {
    LOG.trace("onResponseComplete");
    done.countDown();
    this.response = result.getResponse();
    this.responseContent = content;
    if (callback == null) {
        // this is only for the async callback
        return;
    }
    try {
        jettyBinding.populateResponse(exchange, this);
    } catch (Exception e) {
        exchange.setException(e);
    } finally {
        callback.done(false);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:JettyContentExchange9.java

示例2: onResponseComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
protected void onResponseComplete(Result result, byte[] content, String contentType) {
    LOG.trace("onResponseComplete");
    done.countDown();
    this.response = result.getResponse();
    this.responseContent = content;
    if (callback == null) {
        // this is only for the async callback
        return;
    }
    try {
        jettyBinding.populateResponse(exchange, this);
    } catch (Exception e) {
        exchange.setException(e);
    } finally {
        callback.done(false);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:JettyContentExchange9.java

示例3: downloadStringAsync

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
public void downloadStringAsync(String url, Consumer<DownloadStringAsyncCompletedArgs> consumer) {
    
    newRequest(url)
    .timeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
    .send(new BufferingResponseListener() {
        @Override
        public void onComplete(Result result) {
            if (!result.isFailed() && result.getResponse().getStatus() == 200) {
                try {
                    consumer.accept(new DownloadStringAsyncCompletedArgs(getContentAsString(), null));
                } catch (Exception e) {
                    System.err.println("\n" + getContentAsString());
                    e.printStackTrace();
                }
            } else {
                consumer.accept(new DownloadStringAsyncCompletedArgs(null, "ERROR"));
            }
        }
    });
}
 
开发者ID:azzoti,项目名称:get-rich-with-java8,代码行数:21,代码来源:WebClient.java

示例4: fireResponse

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
private void fireResponse(CapturingRequest request, int errorCode, String responseText, int resultSize, ObservableObserver observer, boolean successfulResponse) throws InterruptedException {
    Response.CompleteListener listener = request.awaitSend(1000, TimeUnit.MILLISECONDS);
    assertNotNull(listener);
    InputStreamResponseListener responseListener = (InputStreamResponseListener) listener;

    Result result = mock(Result.class);
    Response response = mock(Response.class);
    when(result.getResponse()).thenReturn(response);
    when(result.isSucceeded()).thenReturn(successfulResponse);
    when(result.isFailed()).thenReturn(!successfulResponse);
    HttpFields headers = mock(HttpFields.class);
    when(response.getHeaders()).thenReturn(headers);
    when(headers.get(HttpHeader.CONTENT_LENGTH)).thenReturn(String.valueOf(resultSize));
    when(response.getStatus()).thenReturn(errorCode);
    when(response.getVersion()).thenReturn(HttpVersion.HTTP_1_1);

    // fire that event
    responseListener.onHeaders(response);
    responseListener.onContent(response, ByteBuffer.allocate(0));
    responseListener.onComplete(result);

    assertTrue(observer.getLatch().await(1000, TimeUnit.MILLISECONDS));
}
 
开发者ID:betfair,项目名称:cougar,代码行数:24,代码来源:AsyncHttpExecutableTest.java

示例5: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(Result result) {
    emit(new ReactiveResponse.Event(ReactiveResponse.Event.Type.COMPLETE, request.getReactiveResponse()));
    if (result.isSucceeded()) {
        succeed();
    } else {
        fail(result.getFailure());
    }
}
 
开发者ID:jetty-project,项目名称:jetty-reactive-httpclient,代码行数:10,代码来源:ResponseEventPublisher.java

示例6: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(Result result) {
    if (result.isSucceeded()) {
        content.complete();
    } else {
        content.fail(result.getFailure());
    }
}
 
开发者ID:jetty-project,项目名称:jetty-reactive-httpclient,代码行数:9,代码来源:ResponseListenerPublisher.java

示例7: testOnComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Test
public void testOnComplete() {
  CompleteListener sut = new CompleteListener();
  Result result = mock(Result.class);
  Response response = mock(Response.class);

  when(response.getVersion()).thenReturn(HttpVersion.HTTP_2);
  when(result.getResponse()).thenReturn(response);

  sut.onComplete(result);

  verify(result, times(1)).getResponse();
  verify(response, times(1)).getVersion();
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:15,代码来源:CompleteListenerTest.java

示例8: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(Result result) {
    if (result.isSucceeded())
        onResponseSuccess(request, response, result.getResponse());
    else
        onResponseFailure(request, response, result.getResponse(), result.getFailure());

    if (LOG.isDebugEnabled()) LOG.debug("{} proxying complete", getRequestId(request));
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:10,代码来源:ProxyServlet.java

示例9: requestProxyService

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
public void requestProxyService(HttpServletRequest request, DeferredResult<ResponseEntity> deferredResult) {

        this.deferredResult = deferredResult;

        long start = System.currentTimeMillis();

        this.responseInfo = (ResponseInfo) request.getAttribute(Const.RESPONSE_INFO_DATA);
        Request proxyRequest = nettyClientFactory.getNettyClient().newRequest(responseInfo.getRequestURI());

        setHeaderAndQueryInfo(proxyRequest, responseInfo).send(new BufferingResponseListener() {
            @Override
            public void onComplete(Result result) {
                if (!result.isFailed()) {
                    ResponseEntity responseEntity;

                    if (logger.isDebugEnabled()){
                        logger.debug("Http Time " + (System.currentTimeMillis() - start));
                    }

                    HttpFields responseHeaders = result.getResponse().getHeaders();
                    if (responseHeaders.contains(HttpHeader.CONTENT_TYPE)) {
                        String contentTypeValue = responseHeaders.get(HttpHeader.CONTENT_TYPE);
                        if ( contentTypeValue.split(CONST_CONTENT_TYPE_EXTRACT_DELIMITER)[0]
                                .equals(responseInfo.getRequestAccept().split(CONST_CONTENT_TYPE_EXTRACT_DELIMITER)[0])){
                            responseEntity =
                                    new ResponseEntity(Json.parse(getContentAsString(Charset.forName(Const.SERVER_DEFAULT_ENCODING_TYPE))), HttpStatus.OK);
                            deferredResult.setResult(responseEntity);
                        }
                    }
                    deferredResult.setErrorResult(new ProxyServiceFailException(ERROR_MESSAGE_WRONG_CONTENT_TYPE));
                }
            }

            @Override
            public void onFailure(Response response, Throwable failure) {
                deferredResult.setErrorResult(new ProxyServiceFailException("", failure));
            }
        });

    }
 
开发者ID:longcoding,项目名称:undefined-gateway,代码行数:41,代码来源:ProxyServiceImpl.java

示例10: sendToZeppelinHubWithoutResponseBody

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
private String sendToZeppelinHubWithoutResponseBody(Request request) throws IOException {
  request.send(new Response.CompleteListener() {
    @Override
    public void onComplete(Result result) {
      Request req = result.getRequest();
      LOG.info("ZeppelinHub {} {} returned with status {}: {}", req.getMethod(),
          req.getURI(), result.getResponse().getStatus(), result.getResponse().getReason());
    }
  });
  return StringUtils.EMPTY;
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:12,代码来源:ZeppelinhubRestApiHandler.java

示例11: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(Result result) {
  // Extract results.
  Map<String, Object> data = (Map<String, Object>) JSON.parse(utf8Content.toString());
  if (data != null) {
    Object[] results = (Object[]) data.get("results");
    if (results != null) {
      for (Object o : results) {
        onLocationFound((Map<String, Object>) o);
      }
    }
  }
  doComplete();

}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:16,代码来源:AsyncRestServlet.java

示例12: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(Result result) {
    // Remove this request from list of running requests
    runningRequests.remove(mRequestId);
    if (result.isFailed() && result.getResponse().getStatus() != HttpStatus.OK_200) {
        logger.warn("Jetty request {} failed: {}", mRequestId, result.getFailure().getMessage());
        logger.warn("{}", result.getRequestFailure().getMessage());
        logger.warn("{}", result.getResponseFailure().getMessage());
    }

    /**
     * What is this? In some cases where latency is very low the myopenhab service
     * can receive responseFinished before the headers or content are received and I
     * cannot find another workaround to prevent it.
     */
    ThreadPoolManager.getScheduledPool(THREADPOOL_OPENHABCLOUD).schedule(new Runnable() {

        @Override
        public void run() {
            JSONObject responseJson = new JSONObject();
            try {
                responseJson.put("id", mRequestId);
                socket.emit("responseFinished", responseJson);
                logger.debug("Finished responding to request {}", mRequestId);
            } catch (JSONException e) {
                logger.error("{}", e.getMessage());
            }
        }
    }, 1, TimeUnit.MILLISECONDS);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:31,代码来源:CloudClient.java

示例13: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(Result result) {
	if (result.isSucceeded())
		complete.succeeded();
	else
		complete.failed(result.getFailure());
}
 
开发者ID:fuwjax,项目名称:ev-oss,代码行数:8,代码来源:AsyncMiddleManHandler.java

示例14: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(final Result result) {
    final Throwable failure = result.getFailure();

    if (failure != null) {
        _response.setFailure(failure);
    } else {
        final Response response = result.getResponse();

        handleResponse(response);
    }
}
 
开发者ID:mtamme,项目名称:signalr-client,代码行数:13,代码来源:ResponseListener.java

示例15: onComplete

import org.eclipse.jetty.client.api.Result; //导入依赖的package包/类
@Override
public void onComplete(Result result){
    if (result.isSucceeded())
        onResponseSuccess(request, response, result.getResponse());
    else
        onResponseFailure(request, response, result.getResponse(), result.getFailure());
    _log.debug("{} proxying complete", getRequestId(request));
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:9,代码来源:CommandProxyServlet.java


注:本文中的org.eclipse.jetty.client.api.Result类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。