001/* 002 * Copyright 2002-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.http.client.support; 018 019import java.util.ArrayList; 020import java.util.List; 021 022import org.springframework.util.CollectionUtils; 023 024/** 025 * The HTTP accessor that extends the base {@link AsyncHttpAccessor} with 026 * request intercepting functionality. 027 * 028 * @author Jakub Narloch 029 * @author Rossen Stoyanchev 030 * @since 4.3 031 * @deprecated as of Spring 5.0, with no direct replacement 032 */ 033@Deprecated 034public abstract class InterceptingAsyncHttpAccessor extends AsyncHttpAccessor { 035 036 private List<org.springframework.http.client.AsyncClientHttpRequestInterceptor> interceptors = 037 new ArrayList<>(); 038 039 040 /** 041 * Set the request interceptors that this accessor should use. 042 * @param interceptors the list of interceptors 043 */ 044 public void setInterceptors(List<org.springframework.http.client.AsyncClientHttpRequestInterceptor> interceptors) { 045 this.interceptors = interceptors; 046 } 047 048 /** 049 * Return the request interceptor that this accessor uses. 050 */ 051 public List<org.springframework.http.client.AsyncClientHttpRequestInterceptor> getInterceptors() { 052 return this.interceptors; 053 } 054 055 056 @Override 057 public org.springframework.http.client.AsyncClientHttpRequestFactory getAsyncRequestFactory() { 058 org.springframework.http.client.AsyncClientHttpRequestFactory delegate = super.getAsyncRequestFactory(); 059 if (!CollectionUtils.isEmpty(getInterceptors())) { 060 return new org.springframework.http.client.InterceptingAsyncClientHttpRequestFactory(delegate, getInterceptors()); 061 } 062 else { 063 return delegate; 064 } 065 } 066 067}