diff --git a/pom.xml b/pom.xml
index 8c13a4dda..6328a8e8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,7 +37,7 @@
SOFABoot Build
- 3.16.0
+ 3.16.1
${revision}
1.6.7
diff --git a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/ServiceBeanFactoryPostProcessor.java b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/ServiceBeanFactoryPostProcessor.java
index f31e409ca..35976906a 100644
--- a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/ServiceBeanFactoryPostProcessor.java
+++ b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/ServiceBeanFactoryPostProcessor.java
@@ -40,13 +40,14 @@
import com.alipay.sofa.runtime.spring.parser.ServiceDefinitionParser;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -56,7 +57,6 @@
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.core.type.MethodMetadata;
import org.springframework.core.type.StandardMethodMetadata;
@@ -79,9 +79,9 @@
* @author qilong.zql
* @since 3.1.0
*/
-@Order(Ordered.HIGHEST_PRECEDENCE + 10)
-public class ServiceBeanFactoryPostProcessor implements BeanDefinitionRegistryPostProcessor,
- ApplicationContextAware, EnvironmentAware {
+public class ServiceBeanFactoryPostProcessor implements BeanFactoryPostProcessor,
+ ApplicationContextAware, EnvironmentAware,
+ InitializingBean, Ordered {
private final PlaceHolderBinder binder = new DefaultPlaceHolderBinder();
private ApplicationContext applicationContext;
private SofaRuntimeContext sofaRuntimeContext;
@@ -98,16 +98,12 @@ public ServiceBeanFactoryPostProcessor(SofaRuntimeContext sofaRuntimeContext,
this.bindingConverterFactory = bindingConverterFactory;
}
- @Override
- public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
- Arrays.stream(registry.getBeanDefinitionNames())
- .collect(Collectors.toMap(Function.identity(), registry::getBeanDefinition))
- .forEach((key, value) -> transformSofaBeanDefinition(key, value, registry));
- }
-
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
+ Arrays.stream(beanFactory.getBeanDefinitionNames())
+ .collect(Collectors.toMap(Function.identity(), beanFactory::getBeanDefinition))
+ .forEach((key, value) -> transformSofaBeanDefinition(key, value, (BeanDefinitionRegistry) beanFactory));
}
/**
@@ -386,10 +382,6 @@ private List getSofaReferenceBinding(SofaReference sofaReferenceAnnotat
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
- this.sofaRuntimeContext = applicationContext.getBean("sofaRuntimeContext",
- SofaRuntimeContext.class);
- this.bindingConverterFactory = applicationContext.getBean("bindingConverterFactory",
- BindingConverterFactory.class);
}
@Override
@@ -397,6 +389,19 @@ public void setEnvironment(Environment environment) {
this.environment = environment;
}
+ @Override
+ public int getOrder() {
+ return Ordered.HIGHEST_PRECEDENCE + 10;
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ this.sofaRuntimeContext = applicationContext.getBean("sofaRuntimeContext",
+ SofaRuntimeContext.class);
+ this.bindingConverterFactory = applicationContext.getBean("bindingConverterFactory",
+ BindingConverterFactory.class);
+ }
+
class DefaultPlaceHolderBinder implements PlaceHolderBinder {
@Override
public String bind(String text) {
diff --git a/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/BeanDefinitionUtil.java b/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/BeanDefinitionUtil.java
index 8511a3e80..60a454911 100644
--- a/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/BeanDefinitionUtil.java
+++ b/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/BeanDefinitionUtil.java
@@ -21,6 +21,7 @@
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ScannedGenericBeanDefinition;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.MethodMetadata;
@@ -79,6 +80,12 @@ public static Class> resolveBeanClassType(BeanDefinition beanDefinition) {
}
}
+ if (clazz == null) {
+ if (beanDefinition instanceof RootBeanDefinition) {
+ clazz = ((RootBeanDefinition) beanDefinition).getTargetType();
+ }
+ }
+
if (ClassUtils.isCglibProxyClass(clazz)) {
return clazz.getSuperclass();
} else {