Skip to content

Commit

Permalink
Release 3.16.1 (#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
HzjNeverStop authored Nov 14, 2022
1 parent 6b9f02b commit faa68b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
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

0 comments on commit faa68b0

Please sign in to comment.