• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConnectorProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: BaseRestClient

import org.glassfish.jersey.client.spi.ConnectorProvider; //导入依赖的package包/类
/**
     * 
     * @param serviceUrl
     */
    public BaseRestClient(String serviceUrl, final String proxyServer, final Integer proxyPort) {
        setBaseUrl(serviceUrl);
        if (StringUtils.isNotEmpty(proxyServer)) {
        	ConnectorProvider connectorprovider = new HttpUrlConnectorProvider() {
                private Proxy proxy;

                private void initializeProxy() {
                    int port = proxyPort != null ? proxyPort : 80;
                    proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyServer, port));
                }

                public HttpURLConnection getHttpURLConnection(URL url) throws IOException {
                    initializeProxy();
                    return (HttpURLConnection) url.openConnection(proxy);
                }
            };
            client = ClientBuilder.newBuilder().register(connectorprovider).build();
        } else {
            client = ClientBuilder.newClient();
        }
//        client.setConnectTimeout(5000);
//        client.setFollowRedirects(true);
        LOG.info("client for url " + baseUrl + ": proxy="
                + (proxyServer != null ? proxyServer + ":" + proxyPort : "none"));
    }
 
开发者ID:intuit,项目名称:Tank,代码行数:30,代码来源:BaseRestClient.java


示例2: buildJerseyClient

import org.glassfish.jersey.client.spi.ConnectorProvider; //导入依赖的package包/类
public Client buildJerseyClient(JerseyClientConfiguration configuration, String clientName)
{
    ConnectorProvider localConnectorProvider;
    if ( connectorProvider != null )
    {
        localConnectorProvider = connectorProvider;
    }
    else
    {
        HttpClientBuilder apacheHttpClientBuilder = new HttpClientBuilder(environment).using(configuration);
        CloseableHttpClient closeableHttpClient = apacheHttpClientBuilder.build(clientName);
        localConnectorProvider = new JerseyRetryConnectorProvider(retryComponents, closeableHttpClient, configuration.isChunkedEncodingEnabled());
    }
    JerseyClientBuilder builder = new JerseyClientBuilder(environment)
        .using(configuration)
        .using(localConnectorProvider);
    for ( Class<?> klass : providerClasses )
    {
        builder = builder.withProvider(klass);
    }
    for ( Object provider : providers )
    {
        builder = builder.withProvider(provider);
    }
    Client client = builder
        .build(clientName);

    SoaBundle.getFeatures(environment).putNamed(client, Client.class, clientName);

    return client;
}
 
开发者ID:soabase,项目名称:soabase,代码行数:32,代码来源:ClientBuilder.java


示例3: getClientConfig

import org.glassfish.jersey.client.spi.ConnectorProvider; //导入依赖的package包/类
public static ClientConfig getClientConfig(final ServerContext.Type type,
                                           final Credentials credentials,
                                           final String serverUri,
                                           final boolean includeProxySettings) {

    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, credentials);

    final ConnectorProvider connectorProvider = new ApacheConnectorProvider();
    // custom json provider ignores new fields that aren't recognized
    final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    final ClientConfig clientConfig = new ClientConfig(jacksonJsonProvider).connectorProvider(connectorProvider);
    clientConfig.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
    clientConfig.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED);

    // For TFS OnPrem we only support NTLM authentication right now. Since 2016 servers support Basic as well,
    // we need to let the server and client negotiate the protocol instead of preemptively assuming Basic.
    // TODO: This prevents PATs from being used OnPrem. We need to fix this soon to support PATs onPrem.
    clientConfig.property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, type != ServerContext.Type.TFS);

    //Define a local HTTP proxy
    if (includeProxySettings) {
        final HttpProxyService proxyService = PluginServiceProvider.getInstance().getHttpProxyService();
        final String proxyUrl = proxyService.getProxyURL();
        clientConfig.property(ClientProperties.PROXY_URI, proxyUrl);
        if (proxyService.isAuthenticationRequired()) {
            // To work with authenticated proxies and TFS, we provide the proxy credentials if they are registered
            final AuthScope ntlmAuthScope =
                    new AuthScope(proxyService.getProxyHost(), proxyService.getProxyPort(),
                            AuthScope.ANY_REALM, AuthScope.ANY_SCHEME);
            credentialsProvider.setCredentials(ntlmAuthScope,
                    new UsernamePasswordCredentials(proxyService.getUserName(), proxyService.getPassword()));
        }
    }

    // if this is a onPrem server and the uri starts with https, we need to setup ssl
    if (isSSLEnabledOnPrem(type, serverUri)) {
        clientConfig.property(ApacheClientProperties.SSL_CONFIG, getSslConfigurator());
    }

    // register a filter to set the User Agent header
    clientConfig.register(new ClientRequestFilter() {
        @Override
        public void filter(final ClientRequestContext requestContext) throws IOException {
            // The default user agent is something like "Jersey/2.6"
            final String defaultUserAgent = VersionInfo.getUserAgent("Apache-HttpClient", "org.apache.http.client", HttpClientBuilder.class);
            // We get the user agent string from the Telemetry context
            final String userAgent = PluginServiceProvider.getInstance().getTelemetryContextInitializer().getUserAgent(defaultUserAgent);
            // Finally, we can add the header
            requestContext.getHeaders().add(HttpHeaders.USER_AGENT, userAgent);
        }
    });

    return clientConfig;
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:58,代码来源:RestClientHelper.java


示例4: withConnectorProvider

import org.glassfish.jersey.client.spi.ConnectorProvider; //导入依赖的package包/类
public ClientBuilder withConnectorProvider(ConnectorProvider connectorProvider) {
    this.connectorProvider = connectorProvider;
    return this;
}
 
开发者ID:soabase,项目名称:soabase,代码行数:5,代码来源:ClientBuilder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BatchExecutionCommand类代码示例发布时间:2022-05-22
下一篇:
Java XSSimpleTypeDecl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap