com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config Java Examples
The following examples show how to use
com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestClient.java From ribbon with Apache License 2.0 | 6 votes |
@Override public void initWithNiwsConfig(IClientConfig clientConfig) { super.initWithNiwsConfig(clientConfig); this.ncc = clientConfig; this.restClientName = ncc.getClientName(); this.isSecure = ncc.get(CommonClientConfigKey.IsSecure, this.isSecure); this.isHostnameValidationRequired = ncc.get(CommonClientConfigKey.IsHostnameValidationRequired, this.isHostnameValidationRequired); this.isClientAuthRequired = ncc.get(CommonClientConfigKey.IsClientAuthRequired, this.isClientAuthRequired); this.bFollowRedirects = ncc.get(CommonClientConfigKey.FollowRedirects, true); this.ignoreUserToken = ncc.get(CommonClientConfigKey.IgnoreUserTokenInConnectionPoolForSecureClient, this.ignoreUserToken); this.config = new DefaultApacheHttpClient4Config(); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_CONNECT_TIMEOUT, ncc.get(CommonClientConfigKey.ConnectTimeout)); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_READ_TIMEOUT, ncc.get(CommonClientConfigKey.ReadTimeout)); this.restClient = apacheHttpClientSpecificInitialization(); this.setRetryHandler(new HttpClientLoadBalancerErrorHandler(ncc)); }
Example #2
Source File: RestClient.java From s2g-zuul with MIT License | 6 votes |
@Override public void initWithNiwsConfig(IClientConfig clientConfig) { super.initWithNiwsConfig(clientConfig); this.ncc = clientConfig; this.restClientName = ncc.getClientName(); this.isSecure = getBooleanFromConfig(ncc, CommonClientConfigKey.IsSecure, this.isSecure); this.isHostnameValidationRequired = getBooleanFromConfig(ncc, CommonClientConfigKey.IsHostnameValidationRequired, this.isHostnameValidationRequired); this.isClientAuthRequired = getBooleanFromConfig(ncc, CommonClientConfigKey.IsClientAuthRequired, this.isClientAuthRequired); this.bFollowRedirects = getBooleanFromConfig(ncc, CommonClientConfigKey.FollowRedirects, true); this.ignoreUserToken = getBooleanFromConfig(ncc, CommonClientConfigKey.IgnoreUserTokenInConnectionPoolForSecureClient, this.ignoreUserToken); this.config = new DefaultApacheHttpClient4Config(); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_CONNECT_TIMEOUT, Integer.parseInt(String.valueOf(ncc.getProperty(CommonClientConfigKey.ConnectTimeout)))); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_READ_TIMEOUT, Integer.parseInt(String.valueOf(ncc.getProperty(CommonClientConfigKey.ReadTimeout)))); this.restClient = apacheHttpClientSpecificInitialization(); this.restClient.setFollowRedirects(bFollowRedirects); }
Example #3
Source File: DataStoreClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
Example #4
Source File: TestUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public TestUtil(TestProperties testProperties) { this.testProperties = testProperties; // create admin user: ClientConfig clientConfig = new DefaultApacheHttpClient4Config(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); client = ApacheHttpClient4.create(clientConfig); defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient(); }
Example #5
Source File: AbstractWebIntegrationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void createClient(String ctxPath) throws Exception { testProperties = new TestProperties(); APP_BASE_PATH = testProperties.getApplicationPath("/" + ctxPath); LOGGER.info("Connecting to application "+APP_BASE_PATH); ClientConfig clientConfig = new DefaultApacheHttpClient4Config(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); client = ApacheHttpClient4.create(clientConfig); defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient(); HttpParams params = defaultHttpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, 3 * 60 * 1000); HttpConnectionParams.setSoTimeout(params, 10 * 60 * 1000); }
Example #6
Source File: AbstractWebIT.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void createClient(String ctxPath) throws Exception { testProperties = new TestProperties(); APP_BASE_PATH = testProperties.getApplicationPath("/" + ctxPath); LOGGER.info("Connecting to application "+APP_BASE_PATH); ClientConfig clientConfig = new DefaultApacheHttpClient4Config(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); client = ApacheHttpClient4.create(clientConfig); defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient(); HttpParams params = defaultHttpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, 3 * 60 * 1000); HttpConnectionParams.setSoTimeout(params, 10 * 60 * 1000); }
Example #7
Source File: DatabusClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
Example #8
Source File: DedupQueueClientFactory.java From emodb with Apache License 2.0 | 5 votes |
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
Example #9
Source File: QueueClientFactory.java From emodb with Apache License 2.0 | 5 votes |
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
Example #10
Source File: DataStoreClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
Example #11
Source File: DedupQueueClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
Example #12
Source File: QueueClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
Example #13
Source File: DatabusClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
Example #14
Source File: BlobStoreClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
Example #15
Source File: UserAccessControlClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
Example #16
Source File: PurgeDatabusEventsCommand.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
Example #17
Source File: BlobStoreClientFactory.java From emodb with Apache License 2.0 | 5 votes |
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
Example #18
Source File: RestTest.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Test public void testCallEndpointWithDeleteVerb() throws KettleException { MultivaluedMap<String, String> headers = new MultivaluedMapImpl(); headers.add( "Content-Type", "application/json" ); ClientResponse response = mock( ClientResponse.class ); doReturn( 200 ).when( response ).getStatus(); doReturn( headers ).when( response ).getHeaders(); doReturn( "true" ).when( response ).getEntity( String.class ); WebResource.Builder builder = mock( WebResource.Builder.class ); doReturn( response ).when( builder ).delete( ClientResponse.class ); WebResource resource = mock( WebResource.class ); doReturn( builder ).when( resource ).getRequestBuilder(); ApacheHttpClient4 client = mock( ApacheHttpClient4.class ); doReturn( resource ).when( client ).resource( anyString() ); mockStatic( ApacheHttpClient4.class ); when( ApacheHttpClient4.create( any() ) ).thenReturn( client ); RestMeta meta = mock( RestMeta.class ); doReturn( false ).when( meta ).isDetailed(); doReturn( false ).when( meta ).isUrlInField(); doReturn( false ).when( meta ).isDynamicMethod(); RowMetaInterface rmi = mock( RowMetaInterface.class ); doReturn( 1 ).when( rmi ).size(); RestData data = mock( RestData.class ); DefaultApacheHttpClient4Config config = mock( DefaultApacheHttpClient4Config.class ); doReturn( new HashSet<>() ).when( config ).getSingletons(); data.method = RestMeta.HTTP_METHOD_DELETE; data.inputRowMeta = rmi; data.resultFieldName = "result"; data.resultCodeFieldName = "status"; data.resultHeaderFieldName = "headers"; data.config = config; Rest rest = mock( Rest.class ); doCallRealMethod().when( rest ).callRest( any() ); doCallRealMethod().when( rest ).searchForHeaders( any() ); setInternalState( rest, "meta", meta ); setInternalState( rest, "data", data ); Object[] output = rest.callRest( new Object[] { 0 } ); verify( builder, times( 1 ) ).delete( ClientResponse.class ); assertEquals( "true", output[1] ); assertEquals( 200L, output[2] ); assertEquals( "{\"Content-Type\":\"application\\/json\"}", output[3] ); }