本文整理汇总了Java中io.vertx.core.net.ProxyOptions类的典型用法代码示例。如果您正苦于以下问题:Java ProxyOptions类的具体用法?Java ProxyOptions怎么用?Java ProxyOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProxyOptions类属于io.vertx.core.net包,在下文中一共展示了ProxyOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWebClient
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
private WebClient initWebClient() {
if (this.client == null) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getConsumerConfig().getProxy();
final int proxyPort = this.getConsumerConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
// TODO: more options
wco.setUserAgent("SFDC VertX REST Provider");
wco.setTryUseCompression(true);
this.client = WebClient.create(this.vertx, wco);
}
return this.client;
}
示例2: login
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Override
protected void login(final Future<AuthInfo> futureAuthinfo) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getAuthConfig().getProxy();
final int proxyPort = this.getAuthConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
wco.setUserAgent("SDFC VertX Authenticator");
wco.setTryUseCompression(true);
final WebClient authClient = WebClient.create(this.vertx, wco);
final Buffer body = this.getAuthBody(this.getAuthConfig().getSfdcUser(),
this.getAuthConfig().getSfdcPassword());
if (!this.shuttingDown && !this.shutdownCompleted) {
authClient.post(Constants.TLS_PORT, this.getAuthConfig().getServerURL(), Constants.AUTH_SOAP_LOGIN)
.putHeader("Content-Type", "text/xml").ssl(true).putHeader("SOAPAction", "Login")
.putHeader("PrettyPrint", "Yes").sendBuffer(body, postReturn -> {
this.resultOfAuthentication(postReturn, futureAuthinfo);
});
} else {
this.shutdownCompleted = true;
futureAuthinfo.fail("Auth disruped by stop command");
}
}
示例3: createHttpClientOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Override
public HttpClientOptions createHttpClientOptions() {
HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setProtocolVersion(ver);
httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleConnectionTimeout());
if (ServiceRegistryConfig.INSTANCE.isProxyEnable()) {
ProxyOptions proxy = new ProxyOptions();
proxy.setHost(ServiceRegistryConfig.INSTANCE.getProxyHost());
proxy.setPort(ServiceRegistryConfig.INSTANCE.getProxyPort());
proxy.setUsername(ServiceRegistryConfig.INSTANCE.getProxyUsername());
proxy.setPassword(ServiceRegistryConfig.INSTANCE.getProxyPasswd());
httpClientOptions.setProxyOptions(proxy);
}
if (ver == HttpVersion.HTTP_2) {
LOGGER.debug("service center client protocol version is HTTP/2");
httpClientOptions.setHttp2ClearTextUpgrade(false);
}
if (ServiceRegistryConfig.INSTANCE.isSsl()) {
LOGGER.debug("service center client performs requests over TLS");
VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
}
return httpClientOptions;
}
示例4: initWebClient
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
private WebClient initWebClient() {
if (this.client == null) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getListenerConfig().getProxy();
final int proxyPort = this.getListenerConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
// TODO: more options
wco.setUserAgent("SDFC VertX EventBus Client");
wco.setTryUseCompression(true);
this.client = WebClient.create(this.vertx, wco);
}
return this.client;
}
示例5: httpClientOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Bean
public HttpClientOptions httpClientOptions() {
final HttpClientOptions options = new HttpClientOptions()
.setPipelining(true);
if (httpClientProxyHost != null) {
final ProxyOptions proxyOptions = new ProxyOptions()
.setHost(httpClientProxyHost)
.setPort(httpClientProxyPort)
.setType(httpClientProxyType)
.setUsername(httpClientProxyUsername)
.setPassword(httpClientProxyPassword);
options.setProxyOptions(proxyOptions);
}
return options;
}
示例6: load
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
public void load(Handler<AsyncResult<Void>> resultHandler) {
WebClientOptions options = new WebClientOptions();
if (!"none".equalsIgnoreCase(PROXY_HOST)) {
options.setProxyOptions(new ProxyOptions()
.setType(ProxyType.HTTP)
.setHost(PROXY_HOST)
.setPort(PROXY_PORT));
}
String wellKnownUrl = this.config.getWellKnownUrl();
WebClient.create(this.vertx, options)
.getAbs(wellKnownUrl)
.ssl(wellKnownUrl.startsWith("https://") ? true : false)
.send(ar -> {
if (ar.succeeded()) {
JsonObject response = Optional.ofNullable(ar.result().bodyAsJsonObject()).orElseGet(JsonObject::new);
this.parseAndStoreWellKnownFields(response, resultHandler);
} else {
LOG.error("Unable to retrieve well known fields from {}", wellKnownUrl, ar.cause());
resultHandler.handle(Future.failedFuture(ar.cause()));
}
});
}
示例7: initWebClientOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
private WebClientOptions initWebClientOptions(Request request) {
WebClientOptions options = new WebClientOptions();
options.setKeepAlive(true).setReuseAddress(true);
if (Preconditions.isNotBlank(request.getUserAgent())) {
options.setUserAgent(request.getUserAgent());
}
if (Preconditions.isNotBlank(request.getUrl())) {
try {
url = new URL(request.getUrl());
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
if (Preconditions.isNotBlank(request.getProxy())) {
ProxyOptions proxyOptions = new ProxyOptions();
proxyOptions.setHost(request.getProxy().getIp());
proxyOptions.setPort(request.getProxy().getPort());
options.setProxyOptions(proxyOptions);
}
if (Preconditions.isNotBlank(request.getHeader())) {
header = request.getHeader();
}
return options;
}
示例8: withProxyOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
private static HttpClientOptions withProxyOptions (HttpClientOptions options) {
String https_proxy = System.getenv ("https_proxy");
if (StringUtils.isNotEmpty (https_proxy)) {
URI proxy = URI.create (https_proxy);
options.setProxyOptions (new ProxyOptions ().setHost (proxy.getHost ()).setPort (proxy.getPort ()));
}
return options;
}
示例9: setProxyOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Override
public PgConnectOptions setProxyOptions(ProxyOptions proxyOptions) {
return (PgConnectOptions)super.setProxyOptions(proxyOptions);
}
示例10: getProxyOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
public ProxyOptions getProxyOptions() {
return proxyOptions;
}
示例11: setProxyOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
public TelegramOptions setProxyOptions(ProxyOptions proxyOptions) {
this.proxyOptions = proxyOptions;
return this;
}
示例12: doStart
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
// TODO: Prepare HttpClientOptions according to the endpoint to improve performance when creating a new
// instance of the Vertx client
httpClientOptions = new HttpClientOptions();
httpClientOptions.setPipelining(endpoint.getHttpClientOptions().isPipelining());
httpClientOptions.setKeepAlive(endpoint.getHttpClientOptions().isKeepAlive());
httpClientOptions.setIdleTimeout((int) (endpoint.getHttpClientOptions().getIdleTimeout() / 1000));
httpClientOptions.setConnectTimeout((int) endpoint.getHttpClientOptions().getConnectTimeout());
httpClientOptions.setUsePooledBuffers(true);
httpClientOptions.setMaxPoolSize(endpoint.getHttpClientOptions().getMaxConcurrentConnections());
httpClientOptions.setTryUseCompression(endpoint.getHttpClientOptions().isUseCompression());
// Configure proxy
HttpProxy proxy = endpoint.getHttpProxy();
if (proxy != null && proxy.isEnabled()) {
ProxyOptions proxyOptions = new ProxyOptions();
proxyOptions.setHost(proxy.getHost());
proxyOptions.setPort(proxy.getPort());
proxyOptions.setUsername(proxy.getUsername());
proxyOptions.setPassword(proxy.getPassword());
proxyOptions.setType(ProxyType.valueOf(proxy.getType().name()));
httpClientOptions.setProxyOptions(proxyOptions);
}
URI target = URI.create(endpoint.getTarget());
// Configure SSL
HttpClientSslOptions sslOptions = endpoint.getHttpClientSslOptions();
if (sslOptions != null && sslOptions.isEnabled()) {
httpClientOptions
.setSsl(sslOptions.isEnabled())
.setVerifyHost(sslOptions.isHostnameVerifier())
.setTrustAll(sslOptions.isTrustAll());
if (sslOptions.getPem() != null && ! sslOptions.getPem().isEmpty()) {
httpClientOptions.setPemTrustOptions(
new PemTrustOptions().addCertValue(
io.vertx.core.buffer.Buffer.buffer(sslOptions.getPem())));
}
} else if(HTTPS_SCHEME.equalsIgnoreCase(target.getScheme())) {
// SSL is not configured but the endpoint scheme is HTTPS so let's enable the SSL on Vert.x HTTP client
// automatically
httpClientOptions.setSsl(true).setTrustAll(true);
}
printHttpClientConfiguration(httpClientOptions);
}
示例13: setProxyOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Override
public AmqpBridgeOptions setProxyOptions(ProxyOptions proxyOptions) {
super.setProxyOptions(proxyOptions);
return this;
}
示例14: setProxyOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Override
public ProtonClientOptions setProxyOptions(ProxyOptions proxyOptions) {
super.setProxyOptions(proxyOptions);
return this;
}
示例15: setProxyOptions
import io.vertx.core.net.ProxyOptions; //导入依赖的package包/类
@Override
public WebClientOptions setProxyOptions(ProxyOptions proxyOptions) {
return (WebClientOptions) super.setProxyOptions(proxyOptions);
}