org.apache.http.client.fluent.Executor.newInstance()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(430)

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

Executor.newInstance介绍

暂无

代码示例

代码示例来源:origin: dreamhead/moco

public MocoTestHelper() {
  // make fluent HC accept any certificates so we can test HTTPS calls as well
  Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
      .register("http", PlainConnectionSocketFactory.getSocketFactory())
      .register("https", new SSLConnectionSocketFactory(createClientContext()))
      .build();
  HttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
  CloseableHttpClient client = HttpClients.custom()
      .setConnectionManager(cm)
      .setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build())
      .build();
  executor = Executor.newInstance(client);
}

代码示例来源:origin: jooby-project/jooby

private Executor executor() {
 if (executor == null) {
  if (this.host.startsWith("https://")) {
   Try.run(() -> {
    SSLContext sslContext = SSLContexts.custom()
      .loadTrustMaterial(null, (chain, authType) -> true)
      .build();
    builder.setSSLContext(sslContext);
    builder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
   }).throwException();
  }
  client = builder.build();
  executor = Executor.newInstance(client);
  if (creds != null) {
   executor.auth(creds);
  }
 }
 return executor;
}

代码示例来源:origin: mesosphere/dcos-commons

/**
 * Validates that the provided client is valid before constructing an {@link Executor} which may
 * be used via {@link #execute(Request)}.
 */
public DcosHttpExecutor(HttpClientBuilder clientBuilder) {
 this.executor = Executor.newInstance(clientBuilder.build());
}

代码示例来源:origin: linux-china/spring-boot-starter-httpclient

@Bean
public Executor httpClientExecutor(HttpClient httpClient) {
  return Executor.newInstance(httpClient);
}

代码示例来源:origin: org.coursera/metrics-datadog

private HttpTransport(String apiKey,
           int connectTimeout,
           int socketTimeout,
           HttpHost proxy,
           Executor executor,
           boolean useCompression) {
 this.seriesUrl = String.format("%s/series?api_key=%s", BASE_URL, apiKey);
 this.connectTimeout = connectTimeout;
 this.socketTimeout = socketTimeout;
 this.proxy = proxy;
 this.useCompression = useCompression;
 if (executor != null) {
  this.executor = executor;
 } else {
  this.executor = Executor.newInstance();
 }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

private Executor buildAuthExecutor(String username, String password) {
  URI uri = distributionEndpoint.getUri();
  Executor executor = Executor.newInstance()
      .auth(new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()), username, password)
      .authPreemptive(new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()));
  log.debug("authenticate user={}, endpoint={}", username, uri);
  return executor;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

private Executor buildAuthExecutor(String authorizationHeader) {
  HttpClientBuilder builder = HttpClients.custom();
  builder.setDefaultHeaders(Collections.singletonList(new BasicHeader(HttpHeaders.AUTHORIZATION, authorizationHeader)));
  Executor executor = Executor.newInstance(builder.build());
  log.debug("set Authorization header, endpoint={}", distributionEndpoint.getUri());
  return executor;
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

public <T> Future<T> execute(
    final Request request, final ResponseHandler<T> handler, final FutureCallback<T> callback) {
  final BasicFuture<T> future = new BasicFuture<T>(callback);
  final ExecRunnable<T> runnable = new ExecRunnable<T>(
      future,
      request,
      this.executor != null ? this.executor : Executor.newInstance(),
      handler);
  if (this.concurrentExec != null) {
    this.concurrentExec.execute(runnable);
  } else {
    final Thread t = new Thread(runnable);
    t.setDaemon(true);
    t.start();
  }
  return future;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public <T> Future<T> execute(
    final Request request, final ResponseHandler<T> handler, final FutureCallback<T> callback) {
  final BasicFuture<T> future = new BasicFuture<T>(callback);
  final ExecRunnable<T> runnable = new ExecRunnable<T>(
      future,
      request,
      this.executor != null ? this.executor : Executor.newInstance(),
      handler);
  if (this.concurrentExec != null) {
    this.concurrentExec.execute(runnable);
  } else {
    final Thread t = new Thread(runnable);
    t.setDaemon(true);
    t.start();
  }
  return future;
}

代码示例来源:origin: Talend/components

/**
 * Constructor sets schema(http or https), host(google.com) and port number(8080) using one hostPort parameter
 * 
 * @param hostPort URL
 */
public Rest(String hostPort) {
  headers = new LinkedList<>();
  if (!hostPort.endsWith("/")) {
    hostPort = hostPort + "/";
  }
  this.hostPort = hostPort;
  contentType = ContentType.create("application/json", StandardCharsets.UTF_8);
  executor = Executor.newInstance(createHttpClient());
  executor.use(new BasicCookieStore());
}

代码示例来源:origin: org.talend.components/components-jira

/**
 * Constructor sets schema(http or https), host(google.com) and port number(8080) using one hostPort parameter
 * 
 * @param hostPort URL
 */
public Rest(String hostPort) {
  headers = new LinkedList<>();
  if (!hostPort.endsWith("/")) {
    hostPort = hostPort + "/";
  }
  this.hostPort = hostPort;
  contentType = ContentType.create("application/json", StandardCharsets.UTF_8);
  executor = Executor.newInstance(createHttpClient());
  executor.use(new BasicCookieStore());
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

executor = Executor.newInstance(httpClient);

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

private Executor buildExecutor() {
  DistributionTransportSecret secret = secretProvider.getSecret(distributionEndpoint.getUri());
  Map<String, String> credentialsMap = secret.asCredentialsMap();
  return (credentialsMap != null)
      ? buildAuthExecutor(credentialsMap)
      : Executor.newInstance();
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

executor = Executor.newInstance(httpClient);

代码示例来源:origin: org.biopax.validator/biopax-validator-client

String content = Executor.newInstance()
    .execute(Request.Post(url).body(httpEntity))
      .returnContent().asString();

代码示例来源:origin: net.aequologica.neo/dagr-vebchar

.build();
  this.executor = Executor.newInstance(httpClient);
} catch (Exception e) {
  throw new RuntimeException(e);

代码示例来源:origin: org.apache.james/james-server-jmap-integration-testing

@When("^someone upload a content without authentification$")
public void userUploadContentWithoutAuthentification() throws Throwable {
  Request request = Request.Post(uploadUri)
    .bodyStream(new BufferedInputStream(new ZeroedInputStream(_1M), _1M), org.apache.http.entity.ContentType.DEFAULT_BINARY);
  response = Executor.newInstance(HttpClientBuilder.create().disableAutomaticRetries().build()).execute(request).returnResponse();
}

代码示例来源:origin: org.apache.james/james-server-jmap-integration-testing

@When("^\"([^\"]*)\" upload a content$")
public void userUploadContent(String username) throws Throwable {
  AccessToken accessToken = userStepdefs.authenticate(username);
  Request request = Request.Post(uploadUri)
    .bodyStream(new BufferedInputStream(new ZeroedInputStream(_1M), _1M), org.apache.http.entity.ContentType.DEFAULT_BINARY);
  request.addHeader("Authorization", accessToken.serialize());
  response = Executor.newInstance(HttpClientBuilder.create().disableAutomaticRetries().build()).execute(request).returnResponse();
}

相关文章