本文整理汇总了Java中org.glassfish.jersey.apache.connector.ApacheConnectorProvider类的典型用法代码示例。如果您正苦于以下问题:Java ApacheConnectorProvider类的具体用法?Java ApacheConnectorProvider怎么用?Java ApacheConnectorProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApacheConnectorProvider类属于org.glassfish.jersey.apache.connector包,在下文中一共展示了ApacheConnectorProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Scim2Provisioner
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的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: init
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的package包/类
private void init() {
final URI originalUri = URI.create(DEFAULT_UNIX_ENDPOINT);
sanitizeUri = UnixFactory.sanitizeUri(originalUri);
final RegistryBuilder<ConnectionSocketFactory> registryBuilder =
RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", SSLConnectionSocketFactory.getSocketFactory())
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("unix", new UnixFactory(originalUri));
final PoolingHttpClientConnectionManager cm =
new PoolingHttpClientConnectionManager(registryBuilder.build());
final RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout((int) SECONDS.toMillis(5))
.setConnectTimeout((int) SECONDS.toMillis(5))
.setSocketTimeout((int) SECONDS.toMillis(30))
.build();
final ClientConfig config = new ClientConfig()
.connectorProvider(new ApacheConnectorProvider())
.property(ApacheClientProperties.CONNECTION_MANAGER, cm)
.property(ApacheClientProperties.REQUEST_CONFIG, requestConfig);
client = ClientBuilder.newBuilder().withConfig(config).build();
}
示例3: AntiochClient
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的package包/类
public AntiochClient(final URI antiochURI, SSLContext sslContext) {
this.antiochURI = antiochURI;
final ObjectMapper objectMapper = new ObjectMapper()//
.registerModule(new Jdk8Module())//
.registerModule(new JavaTimeModule());
final JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
jacksonProvider.setMapper(objectMapper);
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(50);
cm.setDefaultMaxPerRoute(50);
ApacheConnectorProvider connectorProvider = new ApacheConnectorProvider();
ClientConfig clientConfig = new ClientConfig(jacksonProvider)//
.connectorProvider(connectorProvider)//
.property(ApacheClientProperties.CONNECTION_MANAGER, cm)//
.property(ClientProperties.CONNECT_TIMEOUT, 60000)//
.property(ClientProperties.READ_TIMEOUT, 60000);
if (sslContext == null) {
if ("https".equals(antiochURI.getScheme())) {
throw new RuntimeException("SSL connections need an SSLContext, use: new AntiochClient(uri, sslContext) instead.");
}
client = ClientBuilder.newClient(clientConfig);
} else {
client = ClientBuilder.newBuilder()//
.sslContext(sslContext)//
.withConfig(clientConfig)//
.build();
}
rootTarget = client.target(antiochURI);
}
示例4: ExtensionsService
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的package包/类
@Autowired
public ExtensionsService(
@Value("${org.osiam.endpoint:}") String osiamEndpoint,
@Value("${org.osiam.resourceServerEndpoint:}") String resourceServerEndpoint,
GeneralSessionData sessionData, ObjectMapper mapper
) {
this.sessionData = sessionData;
this.mapper = mapper;
Client client = ClientBuilder.newClient(new ClientConfig()
.connectorProvider(new ApacheConnectorProvider())
.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED)
.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT)
.property(ClientProperties.READ_TIMEOUT, READ_TIMEOUT)
.property(ApacheClientProperties.CONNECTION_MANAGER, new PoolingHttpClientConnectionManager()));
if (!Strings.isNullOrEmpty(osiamEndpoint)) {
target = client.target(osiamEndpoint);
} else if (!Strings.isNullOrEmpty(resourceServerEndpoint)) {
target = client.target(resourceServerEndpoint);
} else {
throw new BeanCreationException("Error creating extension client. No OSIAM endpoint set.");
}
}
示例5: buildClient
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的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.apache.connector.ApacheConnectorProvider; //导入依赖的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.apache.connector.ApacheConnectorProvider; //导入依赖的package包/类
private ClientConfig getClientConfig()
{
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
return config;
}
示例8: main
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
String networkId = Containers.createNetwork(SUBNET);
System.out.println("### Network created: " + Containers.getNetworkAsString(networkId));
Container httpdContainer = Container.builder()
.withImageName("httpd")
.withRegistryHost("docker.io/library")
.withTag("alpine")
.withNetwork(SUBNET)
.withIpAddr(IP_ADDR)
.build();
httpdContainer.runContainer();
System.out.println("### Inspect network after attaching container: " + Containers.getNetworkAsString(networkId));
try {
Response response =
ClientBuilder.newClient(new ClientConfig()
.register(new ThreadPoolExecutorProvider("hola"))
.connectorProvider(new ApacheConnectorProvider()))
.target(HTTPD_URI).request("text/plain").get();
System.out.println("### Httpd container response: " + response.getStatusInfo());
} finally {
httpdContainer.removeContainerQuietly();
Containers.removeNetworkQuietly(networkId);
Containers.closeClientQuietly();
}
}
示例9: createConfig
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的package包/类
private ClientConfig createConfig() {
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
jacksonProvider.setMapper(objectMapper);
config.register(jacksonProvider);
return config;
}
示例10: getSymphonyClient
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的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.apache.connector.ApacheConnectorProvider; //导入依赖的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: createJaxrsClient
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的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);
}
示例13: buildClient
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的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;
}
示例14: configureProxy
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的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());
}
示例15: newClient
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; //导入依赖的package包/类
private Client newClient(Map<String, Object> props) {
ClientConfig config = new ClientConfig().connectorProvider(new ApacheConnectorProvider());
if (props != null)
for (Entry<String, Object> entry : props.entrySet())
config.property(entry.getKey(), entry.getValue());
return ClientBuilder.newClient(config);
}