001/* 002 * Copyright 2002-2018 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; 018 019import java.net.URI; 020import java.util.Collections; 021import java.util.List; 022 023import org.springframework.http.HttpMethod; 024import org.springframework.lang.Nullable; 025 026/** 027 * Wrapper for a {@link AsyncClientHttpRequestFactory} that has support for 028 * {@link AsyncClientHttpRequestInterceptor AsyncClientHttpRequestInterceptors}. 029 * 030 * @author Jakub Narloch 031 * @since 4.3 032 * @see InterceptingAsyncClientHttpRequest 033 * @deprecated as of Spring 5.0, with no direct replacement 034 */ 035@Deprecated 036public class InterceptingAsyncClientHttpRequestFactory implements AsyncClientHttpRequestFactory { 037 038 private AsyncClientHttpRequestFactory delegate; 039 040 private List<AsyncClientHttpRequestInterceptor> interceptors; 041 042 043 /** 044 * Create new instance of {@link InterceptingAsyncClientHttpRequestFactory} 045 * with delegated request factory and list of interceptors. 046 * @param delegate the request factory to delegate to 047 * @param interceptors the list of interceptors to use 048 */ 049 public InterceptingAsyncClientHttpRequestFactory(AsyncClientHttpRequestFactory delegate, 050 @Nullable List<AsyncClientHttpRequestInterceptor> interceptors) { 051 052 this.delegate = delegate; 053 this.interceptors = (interceptors != null ? interceptors : Collections.emptyList()); 054 } 055 056 057 @Override 058 public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod method) { 059 return new InterceptingAsyncClientHttpRequest(this.delegate, this.interceptors, uri, method); 060 } 061 062}