Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.16.1 #1034

Merged
merged 3 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<description>SOFABoot Build</description>

<properties>
<revision>3.16.0</revision>
<revision>3.16.1</revision>
<sofa.boot.version>${revision}</sofa.boot.version>
<!--maven plugin-->
<maven.staging.plugin>1.6.7</maven.staging.plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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));
}

/**
Expand Down Expand Up @@ -386,17 +382,26 @@ private List<Binding> 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
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down