Skip to content

Commit

Permalink
fix:change modify format
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikliu committed Jun 18, 2024
1 parent b72f549 commit 5a69740
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,6 @@
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-lossless-plugin</artifactId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,39 +121,13 @@ 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 RouterBeanInjector)) {
// LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
// beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
// }
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
LOGGER.info("[PolarisJavaAgent] successfully injected spring cloud tencent application bean definitions");

}
}

// @Override
// public void before(Object target, Object[] args) {
// Set<?> candidates = (Set<?>) args[0];
// BeanDefinitionHolder beanDefinitionHolder = (BeanDefinitionHolder) candidates.iterator().next();
// if (isMainBeanDefinition(beanDefinitionHolder)) {
// Class<?> clazz = ClassUtils.getClazz("org.springframework.context.annotation.ConfigurationClass", null);
// Constructor<?> constructor = ReflectionUtils.accessibleConstructor(clazz, Class.class, String.class);
// Method processConfigurationClass = ReflectionUtils.findMethod(target.getClass(), "processConfigurationClass", clazz, Predicate.class);
// ReflectionUtils.makeAccessible(processConfigurationClass);
//
// BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ReflectionUtils.getObjectByFieldName(target, "registry");
// Environment environment = (Environment) ReflectionUtils.getObjectByFieldName(target, "environment");
// for (BeanInjector beanInjector : beanInjectors) {
// if ((beanInjector instanceof RouterBeanInjector)) {
// LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
// beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
// }
// }
// LOGGER.info("[PolarisJavaAgent] successfully injected spring cloud tencent application bean definitions");
//
// }
// }



}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public ConfigurationParserInterceptor() {
beanInjectors.add(new RouterBeanInjector());
beanInjectors.add(new LoadbalancerBeanInjector());
beanInjectors.add(new ConfigBeanInjector());
beanInjectors.add(new LosslessBeanInjector());
// beanInjectors.add(new LosslessBeanInjector());
}


Expand Down Expand Up @@ -117,38 +117,39 @@ 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)) {
LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
// if (!(beanInjector instanceof CommonBeanInjector)) {
// LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
// beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
// }
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
LOGGER.info("[PolarisJavaAgent] successfully injected spring cloud tencent application bean definitions");

}
}

@Override
public void before(Object target, Object[] args) {
Set<?> candidates = (Set<?>) args[0];
BeanDefinitionHolder beanDefinitionHolder = (BeanDefinitionHolder) candidates.iterator().next();
if (isMainBeanDefinition(beanDefinitionHolder)) {
Class<?> clazz = ClassUtils.getClazz("org.springframework.context.annotation.ConfigurationClass", null);
Constructor<?> constructor = ReflectionUtils.accessibleConstructor(clazz, Class.class, String.class);
Method processConfigurationClass = ReflectionUtils.findMethod(target.getClass(), "processConfigurationClass", clazz, Predicate.class);
ReflectionUtils.makeAccessible(processConfigurationClass);

BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ReflectionUtils.getObjectByFieldName(target, "registry");
Environment environment = (Environment) ReflectionUtils.getObjectByFieldName(target, "environment");
for (BeanInjector beanInjector : beanInjectors) {
if (beanInjector instanceof CommonBeanInjector) {
LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
}
LOGGER.info("[PolarisJavaAgent] successfully injected spring cloud tencent application bean definitions");

}
}
// @Override
// public void before(Object target, Object[] args) {
// Set<?> candidates = (Set<?>) args[0];
// BeanDefinitionHolder beanDefinitionHolder = (BeanDefinitionHolder) candidates.iterator().next();
// if (isMainBeanDefinition(beanDefinitionHolder)) {
// Class<?> clazz = ClassUtils.getClazz("org.springframework.context.annotation.ConfigurationClass", null);
// Constructor<?> constructor = ReflectionUtils.accessibleConstructor(clazz, Class.class, String.class);
// Method processConfigurationClass = ReflectionUtils.findMethod(target.getClass(), "processConfigurationClass", clazz, Predicate.class);
// ReflectionUtils.makeAccessible(processConfigurationClass);
//
// BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ReflectionUtils.getObjectByFieldName(target, "registry");
// Environment environment = (Environment) ReflectionUtils.getObjectByFieldName(target, "environment");
// for (BeanInjector beanInjector : beanInjectors) {
// if (beanInjector instanceof CommonBeanInjector) {
// LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
// beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
// }
// }
// LOGGER.info("[PolarisJavaAgent] successfully injected spring cloud tencent application bean definitions");
//
// }
// }



Expand Down

0 comments on commit 5a69740

Please sign in to comment.