Dubbo-Transforming the Dubbo to be compatible with the Spring 4 annotation configuration

Source: Internet
Author: User

http://blog.csdn.net/l1028386804/article/details/70040928


Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/70040928

Dubbo itself is based on the spring environment, but Dubbo Spring was only 2. Version. Now spring has grown to 4.3, and this year (2017) should release Spring 5.
With the hot spring boot, the Java-base configuration spring is becoming more and more popular.
Dubbo + Boot Development mode, is also a more common combination of methods.
However, when using Dubbo in a high-version spring environment with annotation-mode configuration, there are problems with consolidation due to some code version causes.
1. Dubbo Native Annotation Configuration

The Dubbo itself is spring-based and natively provides annotation configurations:
Service Provider configuration:

[HTML] view plain copy <!--Scan Note package path, multiple packets separated by commas, not filled pacakge means to scan all the classes in the current ApplicationContext and <dubbo:anno Tation package= "Com.foo.bar.service"/> Service provider notes:
[Java] view plain copy import Com.alibaba.dubbo.config.annotation.Service; @Service (version= "1.0.0") public class Fooserviceimpl implements Fooservice {//...}

Service Consumer NOTES:

[Java] view plain copy import com.alibaba.dubbo.config.annotation.Reference;      Import org.springframework.stereotype.Component;      @Component public class Baraction {@Reference (version= "1.0.0") private Fooservice Fooservice; } Service Consumer configuration:
[HTML] view plain copy <!--Scan Note package path, multiple packets separated by commas, not filled pacakge means to scan all the classes in the current ApplicationContext and <dubbo:anno Tation package= "Com.foo.bar.action"/>

With the official example, you can see that Dubbo uses the XML configuration <dubbo:annotation/> To turn on annotation configuration and provides Com.alibaba.dubbo.config.annotation.Service Annotations Perform service registration and provide com.alibaba.dubbo.config.annotation.Reference annotations for service injection.
2. Implementation Mechanism

It can be seen that internal mechanisms are based on <dubbo:annotation/> tags. Through source analysis, Dubbo for Spring XML parsing processing is provided by Com.alibaba.dubbo.config.spring.schema.DubboNamespaceHandler:
Dubbonamespacehandler.java

[Java] view plain copy package Com.alibaba.dubbo.config.spring.schema;      Import Org.springframework.beans.factory.xml.NamespaceHandlerSupport;   Import com.alibaba.dubbo.common.Version;   Import Com.alibaba.dubbo.config.ApplicationConfig;   Import Com.alibaba.dubbo.config.ConsumerConfig; Import Com.alibaba.dubbo.config.ModuleConfig;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.