Skip to content

Commit

Permalink
change application.propertirtes
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikliu committed Jun 20, 2024
1 parent dc0823f commit 9a0a8eb
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ server.port=65002
spring.application.name=service-consumer-2022
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.fail-fast=true

spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
spring.cloud.nacos.password=uu3T2L9q
spring.cloud.nacos.discovery.fail-fast=true

feign.sentinel.enabled=true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
server.port=65001
spring.application.name=service-provider-2022
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=111.230.121.115:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.discovery.instance-enabled=true
#only register IPv4 instance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
server.port=65002
spring.application.name=service-consumer-2022
spring.application.name=service-consumer-2023
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=111.230.121.115:8848
spring.cloud.nacos.config.server-addr=111.230.121.115:8848
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.fail-fast=true
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=uu3T2L9q
spring.cloud.nacos.password=nacos

feign.sentinel.enabled=true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
server.port=65001
spring.application.name=service-provider-2022
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=111.230.121.115:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.discovery.instance-enabled=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
server.port=65001
spring.application.name=service-provider-2022
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=111.230.121.115:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.discovery.instance-enabled=true
#only register IPv4 instance
#spring.cloud.nacos.discovery.ip-type=IPv4
#only register IPv6 instance
#spring.cloud.nacos.discovery.ip-type=IPv6

spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos

management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.main.allow-circular-references=true
#server.port=65001
#spring.application.name=service-provider-2022
#spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
#spring.cloud.nacos.config.server-addr=127.0.0.1:8848
#spring.cloud.nacos.config.enabled=true
#spring.cloud.nacos.discovery.enabled=true
##spring.cloud.nacos.discovery.instance-enabled=true
##only register IPv4 instance
##spring.cloud.nacos.discovery.ip-type=IPv4
##only register IPv6 instance
##spring.cloud.nacos.discovery.ip-type=IPv6
#
#spring.cloud.nacos.username=nacos
#spring.cloud.nacos.password=nacos
#
#management.endpoints.web.exposure.include=*
#management.endpoint.health.show-details=always
#spring.main.allow-circular-references=true
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ spring.application.name=service-consumer-hoxton
server.port=18083
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.fail-fast=true

spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
server.port=0
spring.application.name=service-provider-hoxton
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.discovery.instance-enabled=true
#only register IPv4 instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,7 @@ public void onApplicationStartup(Object configurationParser, Constructor<?> conf
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, applicationContextAwareUtils, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("applicationContextAwareUtils", BeanDefinitionBuilder.genericBeanDefinition(
ApplicationContextAwareUtils.class).getBeanDefinition());
if (null != ClassUtils.getClazz("feign.RequestInterceptor",
Thread.currentThread().getContextClassLoader())) {
Object feignAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, FeignAutoConfiguration.class, "feignAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, feignAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("feignAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
FeignAutoConfiguration.class).getBeanDefinition());
}
Object routerAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, RouterAutoConfiguration.class, "routerAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, routerAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("routerAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
RouterAutoConfiguration.class).getBeanDefinition());

LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ public String getModule() {

@Override
public void onBootstrapStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {
LOGGER.info("[PolarisJavaAgent] success to inject bootstrap bean definitions for module {}", getModule());
}


@Override
@SuppressWarnings("unchecked")
public void onApplicationStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {
LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
if (null != ClassUtils.getClazz("feign.RequestInterceptor",
Thread.currentThread().getContextClassLoader())) {
Object feignAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, FeignAutoConfiguration.class, "feignAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, feignAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("feignAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
FeignAutoConfiguration.class).getBeanDefinition());
}
Object routerAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, RouterAutoConfiguration.class, "routerAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, routerAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("routerAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
RouterAutoConfiguration.class).getBeanDefinition());
Object polarisNearByRouterProperties = ReflectionUtils.invokeConstructor(configClassCreator, PolarisNearByRouterProperties.class, "polarisNearByRouterProperties");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisNearByRouterProperties, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisNearByRouterProperties", BeanDefinitionBuilder.genericBeanDefinition(
Expand All @@ -78,13 +97,5 @@ public void onBootstrapStartup(Object configurationParser, Constructor<?> config
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisContractPropertiesAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisContractPropertiesAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisContractPropertiesAutoConfiguration.class).getBeanDefinition());
LOGGER.info("[PolarisJavaAgent] success to inject bootstrap bean definitions for module {}", getModule());
}


@Override
@SuppressWarnings("unchecked")
public void onApplicationStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {
LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ReflectionUtils.getObjectByFieldName(target, "registry");
Environment environment = (Environment) ReflectionUtils.getObjectByFieldName(target, "environment");
for (BeanInjector beanInjector : beanInjectors) {
if (!(beanInjector instanceof CommonBeanInjector)) {
if (!(beanInjector instanceof RouterBeanInjector)) {
LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
Expand All @@ -140,7 +140,7 @@ public void before(Object target, Object[] args) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ReflectionUtils.getObjectByFieldName(target, "registry");
Environment environment = (Environment) ReflectionUtils.getObjectByFieldName(target, "environment");
for (BeanInjector beanInjector : beanInjectors) {
if (beanInjector instanceof CommonBeanInjector) {
if (beanInjector instanceof RouterBeanInjector) {
LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ logging.level.root=INFO
# switch for nacos discovery enable
spring.cloud.nacos.discovery.enabled=false
# switch for nacos config enable
spring.cloud.nacos.config.enabled=false
spring.cloud.nacos.config.enabled=false
# switch for lossless enable
spring.cloud.polaris.lossless.enabled=true
spring.cloud.polaris.lossless.port=28080
spring.cloud.polaris.lossless.delayRegisterInterval=30000
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static List<PropertiesPropertySource> loadPropertiesSource() {
} catch (IOException e) {
throw new IllegalStateException("fail to load config from " + configPath, e);
}
properties.setProperty("spring.cloud.nacos.config.enabled", "false");
properties.setProperty("spring.cloud.nacos.discovery.enabled", "false");
propertySources.add(new PropertiesPropertySource("__polaris_agent_spring_cloud_tencent__", properties));
propertySources.add(new PropertiesPropertySource("__default_polaris_agent_spring_cloud_tencent__", defaultProperties));
return propertySources;
Expand Down

0 comments on commit 9a0a8eb

Please sign in to comment.