java110
2022-09-18 31e6175d07e4cf9611d1cd0910a5e7e10f30c536
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.java110.core.trace;
 
import okhttp3.ConnectionPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
import java.util.concurrent.TimeUnit;
 
@Configuration
public class Java110TraceConfigurer extends WebMvcConfigurerAdapter {
    @Autowired
    private Java110TraceHandlerInterceptor java110TraceHandlerInterceptor;
 
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
 
    }
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(java110TraceHandlerInterceptor).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
 
//    @Bean
//    @ConditionalOnBean(Java110FeignClientInterceptor.class)
//    public okhttp3.OkHttpClient okHttpClient(@Autowired
//                                                     Java110FeignClientInterceptor okHttpLoggingInterceptor){
//        okhttp3.OkHttpClient.Builder ClientBuilder = new okhttp3.OkHttpClient.Builder()
//                .readTimeout(30, TimeUnit.SECONDS) //读取超时
//                .connectTimeout(10, TimeUnit.SECONDS) //连接超时
//                .writeTimeout(60, TimeUnit.SECONDS) //写入超时
//                .connectionPool(new ConnectionPool(10 /*maxIdleConnections*/, 3, TimeUnit.MINUTES))
//                .addInterceptor(okHttpLoggingInterceptor);
//        return ClientBuilder.build();
//    }
}