當前位置: 首頁>>代碼示例>>Java>>正文


Java RestConfig類代碼示例

本文整理匯總了Java中io.confluent.rest.RestConfig的典型用法代碼示例。如果您正苦於以下問題:Java RestConfig類的具體用法?Java RestConfig怎麽用?Java RestConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RestConfig類屬於io.confluent.rest包,在下文中一共展示了RestConfig類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createResponse

import io.confluent.rest.RestConfig; //導入依賴的package包/類
/**
 * Create a Response object using the given exception, status, and message. When debugging is
 * enabled, the message will be replaced with the exception class, exception message, and
 * stacktrace.
 *
 * @param exc    Throwable that triggered this ExceptionMapper
 * @param status HTTP response status
 */
public Response.ResponseBuilder createResponse(Throwable exc, int errorCode,
                                               Response.Status status, String msg) {
  String readableMessage = msg;
  if (restConfig != null && restConfig.getBoolean(RestConfig.DEBUG_CONFIG)) {
    readableMessage += " " + exc.getClass().getName() + ": " + exc.getMessage();
    try {
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      PrintStream stream = new PrintStream(os, false, StandardCharsets.UTF_8.name());
      exc.printStackTrace(stream);
      stream.close();
      os.close();
      readableMessage += System.lineSeparator() + os.toString(StandardCharsets.UTF_8.name());
    } catch (IOException e) {
      // Ignore
    }
  }
  final ErrorMessage message = new ErrorMessage(errorCode, readableMessage);

  return Response.status(status)
      .entity(message);
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:30,代碼來源:DebuggableExceptionMapper.java

示例2: testListenerHandlesDispatchErrorsGracefully

import io.confluent.rest.RestConfig; //導入依賴的package包/類
@Test
public void testListenerHandlesDispatchErrorsGracefully() {
  // request events do not follow the typical order when an error is raised during dispatch
  // this test ensures we probably handle the case where we might encounter events in the
  // following order.
  //
  // MATCHING_START -> REQUEST_MATCHED -> REQUEST_FILTERED
  //   -> RESOURCE_METHOD_START -> RESOURCE_METHOD_FINISHED -> ON_EXCEPTION -> FINISHED

  // RequestEvent.Type.FINISHED before RequestEvent.Type.RESP_FILTERS_START
  Response response = ClientBuilder.newClient(app.resourceConfig.getConfiguration())
      .target("http://localhost:" + config.getInt(RestConfig.PORT_CONFIG))
      .path("/private/endpoint")
      .request(MediaType.APPLICATION_JSON_TYPE)
      .get();
  assertEquals(500, response.getStatus());
  assertTrue(response.readEntity(String.class).contains("Resource Java method invocation error"));
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:19,代碼來源:MetricsResourceMethodApplicationListenerIntegrationTest.java

示例3: negotiateContentType

import io.confluent.rest.RestConfig; //導入依賴的package包/類
private String negotiateContentType() {
  List<MediaType> acceptable = headers.getAcceptableMediaTypes();
  for (MediaType mt : acceptable) {
    for (String providable : restConfig.getList(RestConfig.RESPONSE_MEDIATYPE_PREFERRED_CONFIG)) {
      if (mt.toString().equals(providable)) {
        return providable;
      }
    }
  }
  return restConfig.getString(RestConfig.RESPONSE_MEDIATYPE_DEFAULT_CONFIG);
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:12,代碼來源:WebApplicationExceptionMapper.java

示例4: GenericExceptionMapper

import io.confluent.rest.RestConfig; //導入依賴的package包/類
public GenericExceptionMapper(RestConfig restConfig) {
  super(restConfig);
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:4,代碼來源:GenericExceptionMapper.java

示例5: WebApplicationExceptionMapper

import io.confluent.rest.RestConfig; //導入依賴的package包/類
public WebApplicationExceptionMapper(RestConfig restConfig) {
  super(restConfig);
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:4,代碼來源:WebApplicationExceptionMapper.java

示例6: DebuggableExceptionMapper

import io.confluent.rest.RestConfig; //導入依賴的package包/類
public DebuggableExceptionMapper(RestConfig restConfig) {
  this.restConfig = restConfig;
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:4,代碼來源:DebuggableExceptionMapper.java


注:本文中的io.confluent.rest.RestConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。