修改组件中部分 Spring Bean 命名, 降低客户端命名冲突几率.

pull/10/head
chen.ma 3 years ago
parent 35dc458a02
commit ef3eeccafa

@ -31,15 +31,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
@AllArgsConstructor
@ConditionalOnBean(MarkerConfiguration.Marker.class)
@EnableConfigurationProperties(BootstrapProperties.class)
@ImportAutoConfiguration(
{
HttpClientConfig.class,
DiscoveryConfig.class,
MessageAlarmConfig.class,
UtilAutoConfiguration.class,
CorsConfig.class
}
)
@ImportAutoConfiguration({HttpClientConfig.class, DiscoveryConfig.class, MessageAlarmConfig.class, UtilAutoConfiguration.class, CorsConfig.class})
public class DynamicThreadPoolAutoConfiguration {
private final BootstrapProperties properties;
@ -53,14 +45,14 @@ public class DynamicThreadPoolAutoConfiguration {
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ApplicationContextHolder applicationContextHolder() {
public ApplicationContextHolder hippo4JApplicationContextHolder() {
return new ApplicationContextHolder();
}
@Bean
@SuppressWarnings("all")
public ConfigService configService(HttpAgent httpAgent, InetUtils inetUtils) {
String ip = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
public ConfigService configService(HttpAgent httpAgent, InetUtils hippo4JInetUtils) {
String ip = hippo4JInetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
String port = environment.getProperty("server.port");
String identification = StrUtil.builder(ip, ":", port).toString();
return new ThreadPoolConfigService(httpAgent, identification);
@ -74,7 +66,7 @@ public class DynamicThreadPoolAutoConfiguration {
@Bean
@SuppressWarnings("all")
public DynamicThreadPoolPostProcessor threadPoolBeanPostProcessor(HttpAgent httpAgent, ThreadPoolOperation threadPoolOperation,
ApplicationContextHolder applicationContextHolder) {
ApplicationContextHolder hippo4JApplicationContextHolder) {
return new DynamicThreadPoolPostProcessor(properties, httpAgent, threadPoolOperation);
}

@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
public class HttpClientConfig {
@Bean
public OkHttpClient okHttpClient() {
public OkHttpClient hippo4JOkHttpClient() {
OkHttpClient.Builder build = new OkHttpClient.Builder();
build.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
@ -32,13 +32,13 @@ public class HttpClientConfig {
}
@Bean
public HttpClientUtil httpClientUtil() {
public HttpClientUtil hippo4JHttpClientUtil() {
return new HttpClientUtil();
}
@Bean
public HttpAgent httpAgent(BootstrapProperties properties, HttpClientUtil httpClientUtil) {
return new ServerHttpAgent(properties, httpClientUtil);
public HttpAgent httpAgent(BootstrapProperties properties, HttpClientUtil hippo4JHttpClientUtil) {
return new ServerHttpAgent(properties, hippo4JHttpClientUtil);
}
@SneakyThrows

@ -24,11 +24,11 @@ public class MessageAlarmConfig {
private ConfigurableEnvironment environment;
public static final String SEND_MESSAGE_BEAN_NAME = "sendMessageService";
public static final String SEND_MESSAGE_BEAN_NAME = "hippo4JSendMessageService";
@DependsOn("applicationContextHolder")
@DependsOn("hippo4JApplicationContextHolder")
@Bean(MessageAlarmConfig.SEND_MESSAGE_BEAN_NAME)
public SendMessageService sendMessageService(HttpAgent httpAgent, AlarmControlHandler alarmControlHandler) {
public SendMessageService hippo4JSendMessageService(HttpAgent httpAgent, AlarmControlHandler alarmControlHandler) {
return new BaseSendMessageService(httpAgent, properties, alarmControlHandler);
}

@ -17,7 +17,7 @@ public class UtilAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public InetUtils inetUtils(InetUtilsProperties properties) {
public InetUtils hippo4JInetUtils(InetUtilsProperties properties) {
return new InetUtils(properties);
}

@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSON;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -19,8 +19,8 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class HttpClientUtil {
@Autowired
private OkHttpClient okHttpClient;
@Resource
private OkHttpClient hippo4JOkHttpClient;
private MediaType jsonMediaType = MediaType.parse("application/json; charset=utf-8");
@ -151,7 +151,7 @@ public class HttpClientUtil {
.url(url)
.post(requestBody)
.build();
Response resp = okHttpClient.newCall(request).execute();
Response resp = hippo4JOkHttpClient.newCall(request).execute();
if (resp.code() != HTTP_OK_CODE) {
String msg = String.format("HttpPost 响应 code 异常. [code] %s [url] %s [body] %s", resp.code(), url, jsonBody);
throw new RuntimeException(msg);
@ -162,7 +162,7 @@ public class HttpClientUtil {
@SneakyThrows
private byte[] doGet(String url) {
Request request = new Request.Builder().get().url(url).build();
Response resp = okHttpClient.newCall(request).execute();
Response resp = hippo4JOkHttpClient.newCall(request).execute();
if (resp.code() != HTTP_OK_CODE) {
String msg = String.format("HttpGet 响应 code 异常. [code] %s [url] %s", resp.code(), url);
throw new RuntimeException(msg);
@ -181,7 +181,7 @@ public class HttpClientUtil {
Request request = builder.url(buildUrl).build();
Call call = okHttpClient.newCall(request);
Call call = hippo4JOkHttpClient.newCall(request);
call.timeout().timeout(readTimeoutMs, TimeUnit.MILLISECONDS);
Response resp = call.execute();
@ -204,7 +204,7 @@ public class HttpClientUtil {
.post(RequestBody.create(jsonMediaType, ""))
.build();
Call call = okHttpClient.newCall(request);
Call call = hippo4JOkHttpClient.newCall(request);
call.timeout().timeout(readTimeoutMs, TimeUnit.MILLISECONDS);
Response resp = call.execute();

Loading…
Cancel
Save