forked from apache/dubbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#1205, annotation enhancement and bugfixes
* Fixed apache#1116 apache#1120 apache#1121 apache#1122 apache#1141 apache#1125 * DubboConfigConfiguration's Single and Multiple to be public classes * @DubboComponentScan is compatible with Spring @service completely * @service and @reference issues on <dubbo:annotation> * To fix an issue on <dubbo:annotation> when id attribute is absent * To change the prefixes of properties when @EnableDubboConfig binds multiple Config Bean
- Loading branch information
1 parent
66486e4
commit c59adee
Showing
18 changed files
with
303 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
.../src/main/java/com/alibaba/dubbo/config/spring/schema/AnnotationBeanDefinitionParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.alibaba.dubbo.config.spring.schema; | ||
|
||
import com.alibaba.dubbo.config.spring.AnnotationBean; | ||
import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; | ||
import com.alibaba.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor; | ||
import com.alibaba.dubbo.config.spring.util.BeanRegistrar; | ||
import org.springframework.beans.factory.BeanFactory; | ||
import org.springframework.beans.factory.config.BeanDefinition; | ||
import org.springframework.beans.factory.support.BeanDefinitionBuilder; | ||
import org.springframework.beans.factory.support.BeanDefinitionRegistry; | ||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; | ||
import org.springframework.beans.factory.xml.BeanDefinitionParser; | ||
import org.springframework.beans.factory.xml.ParserContext; | ||
import org.w3c.dom.Element; | ||
|
||
import static org.springframework.util.StringUtils.commaDelimitedListToStringArray; | ||
import static org.springframework.util.StringUtils.trimArrayElements; | ||
|
||
/** | ||
* {@link AnnotationBean} {@link BeanDefinitionParser} | ||
* | ||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a> | ||
* @see ServiceAnnotationBeanPostProcessor | ||
* @see ReferenceAnnotationBeanPostProcessor | ||
* @since 2.5.9 | ||
*/ | ||
public class AnnotationBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { | ||
|
||
/** | ||
* parse | ||
* <prev> | ||
* <dubbo:annotation package="" /> | ||
* </prev> | ||
* | ||
* @param element | ||
* @param parserContext | ||
* @param builder | ||
*/ | ||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { | ||
|
||
String packageToScan = element.getAttribute("package"); | ||
|
||
String[] packagesToScan = trimArrayElements(commaDelimitedListToStringArray(packageToScan)); | ||
|
||
builder.addConstructorArgValue(packagesToScan); | ||
|
||
builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); | ||
|
||
// Registers ReferenceAnnotationBeanPostProcessor | ||
registerReferenceAnnotationBeanPostProcessor(parserContext.getRegistry()); | ||
|
||
} | ||
|
||
protected boolean shouldGenerateIdAsFallback() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Registers {@link ReferenceAnnotationBeanPostProcessor} into {@link BeanFactory} | ||
* | ||
* @param registry {@link BeanDefinitionRegistry} | ||
*/ | ||
private void registerReferenceAnnotationBeanPostProcessor(BeanDefinitionRegistry registry) { | ||
|
||
// Register @Reference Annotation Bean Processor | ||
BeanRegistrar.registerInfrastructureBean(registry, | ||
ReferenceAnnotationBeanPostProcessor.BEAN_NAME, ReferenceAnnotationBeanPostProcessor.class); | ||
|
||
} | ||
|
||
protected Class<?> getBeanClass(Element element) { | ||
return ServiceAnnotationBeanPostProcessor.class; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.