org.eclipse.jetty.client.HttpClient.start()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(230)

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

HttpClient.start介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void start() {
  try {
    if (!this.httpClient.isRunning()) {
      this.httpClient.start();
    }
  }
  catch (Exception ex) {
    throw new SockJsException("Failed to start JettyXhrTransport", ex);
  }
}

代码示例来源:origin: apache/incubator-druid

@Override
public void init() throws ServletException
{
 super.init();
 // Note that httpClientProvider is setup to return same HttpClient instance on each get() so
 // it is same http client as that is used by parent ProxyServlet.
 broadcastClient = newHttpClient();
 try {
  broadcastClient.start();
 }
 catch (Exception e) {
  throw new ServletException(e);
 }
}

代码示例来源:origin: databricks/learning-spark

public Iterable<Tuple2<String, CallLog[]>> call(Iterator<String> input) {
   // List for our results.
   ArrayList<Tuple2<String, CallLog[]>> callsignQsos =
    new ArrayList<Tuple2<String, CallLog[]>>();
   ArrayList<Tuple2<String, ContentExchange>> requests =
    new ArrayList<Tuple2<String, ContentExchange>>();
   ObjectMapper mapper = createMapper();
   HttpClient client = new HttpClient();
   try {
    client.start();
    while (input.hasNext()) {
     requests.add(createRequestForSign(input.next(), client));
    }
    for (Tuple2<String, ContentExchange> signExchange : requests) {
     callsignQsos.add(fetchResultFromRequest(mapper, signExchange));
    }
   } catch (Exception e) {
   }
   return callsignQsos;
  }});
System.out.println(StringUtils.join(contactsContactLists.collect(), ","));

代码示例来源:origin: databricks/learning-spark

public Iterable<String> call(Iterator<String> input) {
   ArrayList<String> content = new ArrayList<String>();
   ArrayList<ContentExchange> cea = new ArrayList<ContentExchange>();
   HttpClient client = new HttpClient();
   try {
    client.start();
    while (input.hasNext()) {
     ContentExchange exchange = new ContentExchange(true);
     exchange.setURL("http://qrzcq.com/call/" + input.next());
     client.send(exchange);
     cea.add(exchange);
    }
    for (ContentExchange exchange : cea) {
     exchange.waitForDone();
     content.add(exchange.getResponseContent());
    }
   } catch (Exception e) {
   }
   return content;
  }});
System.out.println(StringUtils.join(result.collect(), ","));

代码示例来源:origin: spring-projects/spring-framework

@Override
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
    Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
  if (!uri.isAbsolute()) {
    return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
  }
  if (!this.httpClient.isStarted()) {
    try {
      this.httpClient.start();
    }
    catch (Exception ex) {
      return Mono.error(ex);
    }
  }
  JettyClientHttpRequest clientHttpRequest = new JettyClientHttpRequest(
      this.httpClient.newRequest(uri).method(method.toString()), this.bufferFactory);
  return requestCallback.apply(clientHttpRequest).then(Mono.from(
      clientHttpRequest.getReactiveRequest().response((response, chunks) -> {
        Flux<DataBuffer> content = Flux.from(chunks).map(this::toDataBuffer);
        return Mono.just(new JettyClientHttpResponse(response, content));
      })));
}

代码示例来源:origin: konsoletyper/teavm

httpClient.start();
  wsClient.start();
} catch (Exception e) {

代码示例来源:origin: org.springframework/spring-web

@Override
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
    Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
  if (!uri.isAbsolute()) {
    return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
  }
  if (!this.httpClient.isStarted()) {
    try {
      this.httpClient.start();
    }
    catch (Exception ex) {
      return Mono.error(ex);
    }
  }
  JettyClientHttpRequest clientHttpRequest = new JettyClientHttpRequest(
      this.httpClient.newRequest(uri).method(method.toString()), this.bufferFactory);
  return requestCallback.apply(clientHttpRequest).then(Mono.from(
      clientHttpRequest.getReactiveRequest().response((response, chunks) -> {
        Flux<DataBuffer> content = Flux.from(chunks).map(this::toDataBuffer);
        return Mono.just(new JettyClientHttpResponse(response, content));
      })));
}

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

client.start();
} catch (final Exception e) {
  throw new ProcessingException("Failed to start the client.", e);

代码示例来源:origin: xuxueli/xxl-job

httpClient = new HttpClient();
httpClient.setFollowRedirects(false);	// Configure HttpClient, for example:
httpClient.start();						// Start HttpClient

代码示例来源:origin: xuxueli/xxl-job

httpClient = new HttpClient();
httpClient.setFollowRedirects(false);	// Configure HttpClient, for example:
httpClient.start();						// Start HttpClient

代码示例来源:origin: 4thline/cling

public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
  this.configuration = configuration;
  log.info("Starting Jetty HttpClient...");
  client = new HttpClient();
  // Jetty client needs threads for its internal expiration routines, which we don't need but
  // can't disable, so let's abuse the request executor service for this
  client.setThreadPool(
    new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
      @Override
      protected void doStop() throws Exception {
        // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
      }
    }
  );
  // These are some safety settings, we should never run into these timeouts as we
  // do our own expiration checking
  client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setMaxRetries(configuration.getRequestRetryCount());
  try {
    client.start();
  } catch (Exception ex) {
    throw new InitializationException(
      "Could not start Jetty HTTP client: " + ex, ex
    );
  }
}

代码示例来源:origin: resteasy/Resteasy

public JettyClientEngine(final HttpClient client) {
 if (!client.isStarted()) {
   try {
    client.start();
   } catch (Exception e) {
    throw new RuntimeException(e);
   }
 }
 this.client = client;
}

代码示例来源:origin: sixt/ja-micro

private HttpClient createHttpClient() {
  SslContextFactory sslContextFactory = new SslContextFactory();
  sslContextFactory.setExcludeCipherSuites("");
  HttpClient client = new HttpClient(sslContextFactory);
  client.setFollowRedirects(false);
  client.setMaxConnectionsPerDestination(2);
  //You can set more restrictive timeouts per request, but not less, so
  //  we set the maximum timeout of 1 hour here.
  client.setIdleTimeout(60 * 60 * 1000);
  try {
    client.start();
  } catch (Exception e) {
    logger.error("Error building http client", e);
  }
  return client;
}

代码示例来源:origin: sixt/ja-micro

@Provides
public HttpClient getHttpClient() {
  HttpClient client = new HttpClient();
  client.setFollowRedirects(false);
  client.setMaxConnectionsPerDestination(32);
  client.setConnectTimeout(100);
  client.setAddressResolutionTimeout(100);
  //You can set more restrictive timeouts per request, but not less, so
  //  we set the maximum timeout of 1 hour here.
  client.setIdleTimeout(60 * 60 * 1000);
  try {
    client.start();
  } catch (Exception e) {
    logger.error("Error building http client", e);
  }
  return client;
}

代码示例来源:origin: sixt/ja-micro

private HttpClient createHttpClient() {
  //Allow ssl by default
  SslContextFactory sslContextFactory = new SslContextFactory();
  //Don't exclude RSA because Sixt needs them, dammit!
  sslContextFactory.setExcludeCipherSuites("");
  HttpClient client = new HttpClient(sslContextFactory);
  client.setFollowRedirects(false);
  client.setMaxConnectionsPerDestination(16);
  client.setRequestBufferSize(65536);
  client.setConnectTimeout(FeatureFlags.getHttpConnectTimeout(serviceProperties));
  client.setAddressResolutionTimeout(FeatureFlags.getHttpAddressResolutionTimeout(serviceProperties));
  //You can set more restrictive timeouts per request, but not less, so
  //  we set the maximum timeout of 1 hour here.
  client.setIdleTimeout(60 * 60 * 1000);
  try {
    client.start();
  } catch (Exception e) {
    logger.error("Error building http client", e);
  }
  return client;
}

代码示例来源:origin: kingthy/TVRemoteIME

public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
  this.configuration = configuration;
  log.info("Starting Jetty HttpClient...");
  client = new HttpClient();
  // Jetty client needs threads for its internal expiration routines, which we don't need but
  // can't disable, so let's abuse the request executor service for this
  client.setThreadPool(
    new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
      @Override
      protected void doStop() throws Exception {
        // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
      }
    }
  );
  // These are some safety settings, we should never run into these timeouts as we
  // do our own expiration checking
  client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
  client.setMaxRetries(configuration.getRequestRetryCount());
  try {
    client.start();
  } catch (Exception ex) {
    throw new InitializationException(
      "Could not start Jetty HTTP client: " + ex, ex
    );
  }
}

代码示例来源:origin: allegro/hermes

@Override
public void start() {
  try {
    this.httpClient.start();
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: allegro/hermes

private void startClient(HttpClient client) {
  if (client.isStopped()) {
    try {
      client.start();
    } catch (Exception ex) {
      logger.error("Could not start http client.", ex);
    }
  }
}

代码示例来源:origin: org.eclipse.smarthome.ui/org.eclipse.smarthome.ui

BlockingProxyServlet(ProxyServletService service) {
  super();
  this.service = service;
  if (!httpClient.isStarted()) {
    try {
      httpClient.start();
    } catch (Exception e) {
      logger.warn("Cannot start HttpClient!", e);
    }
  }
}

代码示例来源:origin: allegro/hermes

@BeforeClass
public static void setupEnvironment() throws Exception {
  wireMockServer = new WireMockServer(ENDPOINT_PORT);
  wireMockServer.start();
  client = new HttpClient();
  client.setCookieStore(new HttpCookieStore.Empty());
  client.setConnectTimeout(1000);
  client.setIdleTimeout(1000);
  client.start();
}

相关文章

HttpClient类方法