org.springframework.http.client.AsyncClientHttpRequestFactory Java Examples
The following examples show how to use
org.springframework.http.client.AsyncClientHttpRequestFactory.
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: ITTracingAsyncClientHttpRequestInterceptor.java From brave with Apache License 2.0 | 6 votes |
@Override protected void get(AsyncClientHttpRequestFactory client, String path, BiConsumer<Integer, Throwable> callback) { AsyncRestTemplate restTemplate = new AsyncRestTemplate(client); restTemplate.setInterceptors(Collections.singletonList(interceptor)); restTemplate.getForEntity(url(path), String.class) .addCallback(new ListenableFutureCallback<ResponseEntity<String>>() { @Override public void onFailure(Throwable throwable) { if (throwable instanceof HttpStatusCodeException) { callback.accept(((HttpStatusCodeException) throwable).getRawStatusCode(), null); } else { callback.accept(null, throwable); } } @Override public void onSuccess(ResponseEntity<String> entity) { callback.accept(entity.getStatusCodeValue(), null); } }); }
Example #2
Source File: InterceptingAsyncHttpAccessor.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public AsyncClientHttpRequestFactory getAsyncRequestFactory() { AsyncClientHttpRequestFactory delegate = super.getAsyncRequestFactory(); if (!CollectionUtils.isEmpty(getInterceptors())) { return new InterceptingAsyncClientHttpRequestFactory(delegate, getInterceptors()); } else { return delegate; } }
Example #3
Source File: ITTracingAsyncClientHttpRequestInterceptor.java From brave with Apache License 2.0 | 5 votes |
AsyncClientHttpRequestFactory configureClient(AsyncClientHttpRequestInterceptor interceptor) { HttpComponentsAsyncClientHttpRequestFactory factory = new HttpComponentsAsyncClientHttpRequestFactory(asyncClient); factory.setReadTimeout(1000); factory.setConnectTimeout(1000); this.interceptor = interceptor; return factory; }
Example #4
Source File: ApplicationAutoConfiguration.java From opencensus-java with Apache License 2.0 | 5 votes |
/** * Factory for AsyncClientHttpRequest. * * @return AsyncClientHttpRequestFactory */ @Bean public AsyncClientHttpRequestFactory getAsyncClientHttpRequestFactory() { int timeout = 5000; HttpComponentsAsyncClientHttpRequestFactory asyncClientHttpRequestFactory = new HttpComponentsAsyncClientHttpRequestFactory(); asyncClientHttpRequestFactory.setConnectTimeout(timeout); return asyncClientHttpRequestFactory; }
Example #5
Source File: DefaultHttpBuilder.java From riptide with MIT License | 4 votes |
@Override @SuppressWarnings("deprecation") public ConfigurationStage asyncRequestFactory(final AsyncClientHttpRequestFactory factory) { return withIo(new NonBlockingIO(factory)); }
Example #6
Source File: ITTracingAsyncClientHttpRequestInterceptor.java From brave with Apache License 2.0 | 4 votes |
@Override protected void post(AsyncClientHttpRequestFactory client, String uri, String content) { AsyncRestTemplate restTemplate = new AsyncRestTemplate(client); restTemplate.setInterceptors(Collections.singletonList(interceptor)); restTemplate.postForEntity(url(uri), RequestEntity.post(URI.create(url(uri))).body(content), String.class).completable().join(); }
Example #7
Source File: ITTracingAsyncClientHttpRequestInterceptor.java From brave with Apache License 2.0 | 4 votes |
@Override protected void options(AsyncClientHttpRequestFactory client, String path) { AsyncRestTemplate restTemplate = new AsyncRestTemplate(client); restTemplate.setInterceptors(Collections.singletonList(interceptor)); restTemplate.optionsForAllow(url(path)).completable().join(); }
Example #8
Source File: ITTracingAsyncClientHttpRequestInterceptor.java From brave with Apache License 2.0 | 4 votes |
@Override protected void get(AsyncClientHttpRequestFactory client, String pathIncludingQuery) { AsyncRestTemplate restTemplate = new AsyncRestTemplate(client); restTemplate.setInterceptors(Collections.singletonList(interceptor)); restTemplate.getForEntity(url(pathIncludingQuery), String.class).completable().join(); }
Example #9
Source File: ITTracingAsyncClientHttpRequestInterceptor.java From brave with Apache License 2.0 | 4 votes |
@Override protected void closeClient(AsyncClientHttpRequestFactory client) { // done in close() }
Example #10
Source File: ITTracingAsyncClientHttpRequestInterceptor.java From brave with Apache License 2.0 | 4 votes |
@Override protected AsyncClientHttpRequestFactory newClient(int port) { return configureClient(TracingAsyncClientHttpRequestInterceptor.create(httpTracing)); }
Example #11
Source File: RestClient.java From light with Apache License 2.0 | 4 votes |
private AsyncClientHttpRequestFactory asyncHttpRequestFactory() throws Exception { return new HttpComponentsAsyncClientHttpRequestFactory( asyncHttpClient()); }
Example #12
Source File: MultipleAsyncRestTemplateTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
private AsyncClientHttpRequestFactory asyncClientFactory() { AsyncClientHttpRequestFactory factory = new CustomAsyncClientHttpRequestFactory(); // CUSTOMIZE HERE return factory; }
Example #13
Source File: AsyncRest.java From myfeed with Apache License 2.0 | 4 votes |
public AsyncRest(AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate) { super(requestFactory, restTemplate); }
Example #14
Source File: AsyncRest.java From myfeed with Apache License 2.0 | 4 votes |
public AsyncRest(AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) { super(asyncRequestFactory, syncRequestFactory); }
Example #15
Source File: AsyncRest.java From myfeed with Apache License 2.0 | 4 votes |
public AsyncRest(AsyncClientHttpRequestFactory asyncRequestFactory) { super(asyncRequestFactory); }
Example #16
Source File: ApplicationAutoConfiguration.java From opencensus-java with Apache License 2.0 | 4 votes |
@Bean public AsyncRestTemplate getAsyncRestTemplate(AsyncClientHttpRequestFactory factory) { return new AsyncRestTemplate(factory); }
Example #17
Source File: AsyncHttpAccessor.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Set the request factory that this accessor uses for obtaining {@link * org.springframework.http.client.ClientHttpRequest HttpRequests}. */ public void setAsyncRequestFactory(AsyncClientHttpRequestFactory asyncRequestFactory) { Assert.notNull(asyncRequestFactory, "'asyncRequestFactory' must not be null"); this.asyncRequestFactory = asyncRequestFactory; }
Example #18
Source File: AsyncHttpAccessor.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Set the request factory that this accessor uses for obtaining {@link * org.springframework.http.client.ClientHttpRequest HttpRequests}. */ public void setAsyncRequestFactory(AsyncClientHttpRequestFactory asyncRequestFactory) { Assert.notNull(asyncRequestFactory, "AsyncClientHttpRequestFactory must not be null"); this.asyncRequestFactory = asyncRequestFactory; }
Example #19
Source File: AsyncRestTemplate.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create a new instance of the {@code AsyncRestTemplate} using the given * {@link AsyncClientHttpRequestFactory}. * <p>This constructor will cast the given asynchronous * {@code AsyncClientHttpRequestFactory} to a {@link ClientHttpRequestFactory}. Since * all implementations of {@code ClientHttpRequestFactory} provided in Spring also * implement {@code AsyncClientHttpRequestFactory}, this should not result in a * {@code ClassCastException}. */ public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory) { this(asyncRequestFactory, (ClientHttpRequestFactory) asyncRequestFactory); }
Example #20
Source File: AsyncHttpAccessor.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Return the request factory that this accessor uses for obtaining {@link * org.springframework.http.client.ClientHttpRequest HttpRequests}. */ public AsyncClientHttpRequestFactory getAsyncRequestFactory() { return this.asyncRequestFactory; }
Example #21
Source File: AsyncRestTemplate.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Create a new instance of the {@code AsyncRestTemplate} using the given * {@link AsyncClientHttpRequestFactory} and synchronous {@link RestTemplate}. * @param requestFactory the asynchronous request factory to use * @param restTemplate the synchronous template to use */ public AsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate) { Assert.notNull(restTemplate, "RestTemplate must not be null"); this.syncTemplate = restTemplate; setAsyncRequestFactory(requestFactory); }
Example #22
Source File: AsyncRestTemplate.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Creates a new instance of the {@code AsyncRestTemplate} using the given * asynchronous and synchronous request factories. * @param asyncRequestFactory the asynchronous request factory * @param syncRequestFactory the synchronous request factory */ public AsyncRestTemplate( AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) { this(asyncRequestFactory, new RestTemplate(syncRequestFactory)); }
Example #23
Source File: AsyncRestTemplate.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Create a new instance of the {@code AsyncRestTemplate} using the given * {@link AsyncClientHttpRequestFactory}. * <p>This constructor will cast the given asynchronous * {@code AsyncClientHttpRequestFactory} to a {@link ClientHttpRequestFactory}. Since * all implementations of {@code ClientHttpRequestFactory} provided in Spring also * implement {@code AsyncClientHttpRequestFactory}, this should not result in a * {@code ClassCastException}. */ public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory) { this(asyncRequestFactory, (ClientHttpRequestFactory) asyncRequestFactory); }
Example #24
Source File: AsyncHttpAccessor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Return the request factory that this accessor uses for obtaining {@link * org.springframework.http.client.ClientHttpRequest HttpRequests}. */ public AsyncClientHttpRequestFactory getAsyncRequestFactory() { return this.asyncRequestFactory; }
Example #25
Source File: AsyncRestTemplate.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create a new instance of the {@code AsyncRestTemplate} using the given * {@link AsyncClientHttpRequestFactory} and synchronous {@link RestTemplate}. * @param requestFactory the asynchronous request factory to use * @param restTemplate the synchronous template to use */ public AsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate) { Assert.notNull(restTemplate, "RestTemplate must not be null"); this.syncTemplate = restTemplate; setAsyncRequestFactory(requestFactory); }
Example #26
Source File: AsyncRestTemplate.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Creates a new instance of the {@code AsyncRestTemplate} using the given * asynchronous and synchronous request factories. * @param asyncRequestFactory the asynchronous request factory * @param syncRequestFactory the synchronous request factory */ public AsyncRestTemplate( AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) { this(asyncRequestFactory, new RestTemplate(syncRequestFactory)); }