本文整理汇总了Java中org.glassfish.jersey.client.ClientConfig.connectorProvider方法的典型用法代码示例。如果您正苦于以下问题:Java ClientConfig.connectorProvider方法的具体用法?Java ClientConfig.connectorProvider怎么用?Java ClientConfig.connectorProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.glassfish.jersey.client.ClientConfig
的用法示例。
在下文中一共展示了ClientConfig.connectorProvider方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Scim2Provisioner
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
public Scim2Provisioner(final String target, final String oauthToken,
final String username, final String password,
final Scim2PrincipalAttributeMapper mapper) {
final ClientConfig config = new ClientConfig();
final ApacheConnectorProvider connectorProvider = new ApacheConnectorProvider();
config.connectorProvider(connectorProvider);
final Client client = ClientBuilder.newClient(config);
if (StringUtils.isNotBlank(oauthToken)) {
client.register(OAuth2ClientSupport.feature(oauthToken));
}
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
client.register(HttpAuthenticationFeature.basic(username, password));
}
final WebTarget webTarget = client.target(target);
this.scimService = new ScimService(webTarget);
this.mapper = mapper;
}
示例2: ParaClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
/**
* Default constructor.
* @param accessKey app access key
* @param secretKey app secret key
*/
public ParaClient(String accessKey, String secretKey) {
this.accessKey = accessKey;
this.secretKey = secretKey;
if (StringUtils.length(secretKey) < 6) {
logger.warn("Secret key appears to be invalid. Make sure you call 'signIn()' first.");
}
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(GenericExceptionMapper.class);
clientConfig.register(new JacksonJsonProvider(ParaObjectUtils.getJsonMapper()));
clientConfig.connectorProvider(new HttpUrlConnectorProvider().useSetMethodWorkaround());
SSLContext sslContext = SslConfigurator.newInstance().securityProtocol("TLSv1").createSSLContext();
System.setProperty("https.protocols", "TLSv1");
apiClient = ClientBuilder.newBuilder().
sslContext(sslContext).
withConfig(clientConfig).build();
}
示例3: createClientConfig
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
protected ClientConfig createClientConfig() {
ClientConfig config = new ClientConfig();
if ( proxy != null && proxy.getUri() != null ) {
config.property(ClientProperties.PROXY_URI, proxy.getUriString());
config.property(ClientProperties.PROXY_USERNAME, proxy.getUserName());
config.property(ClientProperties.PROXY_PASSWORD, proxy.getPassword());
}
config.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED);
config.property(ApacheClientProperties.CREDENTIALS_PROVIDER, getCredentialsProvider());
config.property(ApacheClientProperties.SERVICE_UNAVAILABLE_RETRY_STRATEGY, getServiceUnavailableRetryStrategy());
config.property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, doPreemptiveBasicAuthentication());
config.connectorProvider(new ApacheConnectorProvider());
config.register(JacksonFeature.class);
config.register(new LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), Level.FINE, LoggingFeature.Verbosity.PAYLOAD_ANY, 10000));
return config;
}
示例4: createJaxrsClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private static javax.ws.rs.client.Client createJaxrsClient(
final HttpClientConnectionManager connectionManager, final int connectionTimeout,
final int socketTimeout, @Nullable final ProxyConfig proxy) {
// Configure requests
final RequestConfig requestConfig = RequestConfig.custom()//
.setExpectContinueEnabled(false) //
.setRedirectsEnabled(false) //
.setConnectionRequestTimeout(connectionTimeout) //
.setConnectTimeout(connectionTimeout) //
.setSocketTimeout(socketTimeout)
.build();
// Configure client
final ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
config.property(ApacheClientProperties.CONNECTION_MANAGER, connectionManager);
config.property(ApacheClientProperties.REQUEST_CONFIG, requestConfig);
config.property(ApacheClientProperties.DISABLE_COOKIES, true); // not needed
config.property(ClientProperties.REQUEST_ENTITY_PROCESSING,
RequestEntityProcessing.CHUNKED); // required to stream data to the server
if (proxy != null) {
config.property(ClientProperties.PROXY_URI, proxy.getURL());
config.property(ClientProperties.PROXY_USERNAME, proxy.getUsername());
config.property(ClientProperties.PROXY_PASSWORD, proxy.getPassword());
}
// Register filter and custom serializer
config.register(Serializer.class);
config.register(GZipEncoder.class);
// Create and return a configured JAX-RS client
return ClientBuilder.newClient(config);
}
示例5: buildClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private static void buildClient() {
if ( USE_PROXY ) {
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
CredentialsProvider credentials = new BasicCredentialsProvider();
credentials.setCredentials(AuthScope.ANY, new NTCredentials(PROXY_USER, PROXY_PASS, null, PROXY_DOMAIN));
config.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentials);
config.property(ClientProperties.PROXY_URI, PROXY_PROTOCOL + PROXY_SERVER);
client = ClientBuilder.newClient(config);
}
else
client = ClientBuilder.newClient();
}
示例6: getInvocationBuilder
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
protected Builder getInvocationBuilder(String url, Map<String, String> queryParameters) {
ClientConfig clientConfig = new ClientConfig();
if (getProxyAddress() != null) {
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ClientProperties.PROXY_URI, getProxyAddress());
}
Client client = ClientBuilder.newClient(clientConfig);
client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
WebTarget webTarget = client.target(url);
if (queryParameters != null) {
for (Map.Entry<String, String> queryParameter: queryParameters.entrySet())
// webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue().replace("_", "_1").replace("%", "_0"));
webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue());
}
return webTarget.request(MediaType.APPLICATION_JSON).accept("application/ld+json").header("Authorization", getCloudTokenValue());
}
示例7: getClientConfig
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private ClientConfig getClientConfig()
{
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
return config;
}
示例8: createConfig
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private ClientConfig createConfig() {
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
jacksonProvider.setMapper(objectMapper);
config.register(jacksonProvider);
return config;
}
示例9: defaultClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private Client defaultClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
return ClientBuilder.newClient(config);
}
示例10: getSymphonyClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
public static SymphonyClient getSymphonyClient(SymphonyClientConfig symphonyClientConfig) throws InitException, AuthenticationException {
SymphonyClient symClient = SymphonyClientFactory.getClient(SymphonyClientFactory.TYPE.BASIC);
String proxy = symphonyClientConfig.get("proxy.url");
if (proxy == null) {
symClient.init(symphonyClientConfig);
return symClient;
} else {
ClientConfig clientConfig = new ClientConfig();
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ClientProperties.PROXY_URI, proxy);
try {
Client httpClient = CustomHttpClient.getClient(
symphonyClientConfig.get(SymphonyClientConfigID.USER_CERT_FILE),
symphonyClientConfig.get(SymphonyClientConfigID.USER_CERT_PASSWORD),
symphonyClientConfig.get(SymphonyClientConfigID.TRUSTSTORE_FILE),
symphonyClientConfig.get(SymphonyClientConfigID.TRUSTSTORE_PASSWORD),
clientConfig);
symClient.init(httpClient, symphonyClientConfig);
return symClient;
} catch (Exception e) {
e.printStackTrace();
}
}
return symClient;
}
示例11: buildClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private static JerseyClient buildClient(GuildWars2ApiConfig config) {
ClientConfig jerseyConfig = config.getClientConfig();
JerseyClientBuilder builder = new JerseyClientBuilder().withConfig(jerseyConfig);
if (config.isGoDaddyFixEnabled()) {
GoDaddyFix.insertFix(builder);
}
if (config.isApacheHttpClientEnabled()) {
jerseyConfig.connectorProvider(new ApacheConnectorProvider());
}
return builder.build();
}
示例12: buildClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private static Client buildClient(ClientConfiguration clientConfiguration) {
ClientConfig clientConfig = new ClientConfig();
clientConfig
.register(JsonMappingExceptionMapper.class)
.register(JsonParseExceptionMapper.class)
.register(JacksonJaxbJsonProvider.class, new Class[]{MessageBodyReader.class, MessageBodyWriter.class})
.register(RequestBodyLogger.class)
.register(HttpAuthenticationFeature.basic(clientConfiguration.getUsername(), clientConfiguration.getPassword()))
;
if (clientConfiguration.isEnableBatchCompression()) {
clientConfig.register(GZipWriterInterceptor.class);
}
if (log.isDebugEnabled()) {
clientConfig.register(new LoggingFilter(legacyLogger, true));
}
configureHttps(clientConfiguration, clientConfig);
clientConfig.connectorProvider(new ApacheConnectorProvider());
Client builtClient = ClientBuilder.newBuilder().withConfig(clientConfig).build();
builtClient.property(ClientProperties.CONNECT_TIMEOUT, clientConfiguration.getConnectTimeoutMillis());
builtClient.property(ClientProperties.READ_TIMEOUT, clientConfiguration.getReadTimeoutMillis());
return builtClient;
}
示例13: configureProxy
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private void configureProxy(
ClientConfig config,
String proxyUri,
String username,
String password
) {
config.property(ClientProperties.PROXY_URI, proxyUri);
if (username != null && !username.isEmpty()) {
config.property(ClientProperties.PROXY_USERNAME, username);
}
if (password != null && !password.isEmpty()) {
config.property(ClientProperties.PROXY_PASSWORD, password);
}
config.connectorProvider(new ApacheConnectorProvider());
}
示例14: getClient
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
/**
* REturn REST client with specific authentication
*
* @param user
* @param pwd
* @return
*/
Client getClient(String user, String pwd) {
ClientConfig clientConfig = new ClientConfig();
// clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.connectorProvider(new JettyConnectorProvider()); // use jetty connector for keep jsession cookies, apache connector works too, grizzly connector, failed
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(user, pwd);
Client client = ClientBuilder.newClient(clientConfig);
client.register(feature);
return client;
}
示例15: resetVarnishCache
import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private void resetVarnishCache() {
ClientConfig cc = new ClientConfig();
cc.connectorProvider(new ApacheConnectorProvider());
ClientBuilder
.newClient(cc)
.target("http://read.backdrop.perfplat.dev/data/test/test")
.request()
.accept(MediaType.APPLICATION_JSON_TYPE)
.method("PURGE");
}