dubbo-autoconfigure

A Spring plugin for dubbo

License

License

Categories

Categories

Auto Application Layer Libs Code Generators config Configuration Dubbo Net Networking
GroupId

GroupId

com.github.skyding228
ArtifactId

ArtifactId

dubbo-autoconfigure
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

jar
Description

Description

dubbo-autoconfigure
A Spring plugin for dubbo
Project URL

Project URL

https://github.com/skyding228/dubbo-autoconfigure
Source Code Management

Source Code Management

https://github.com/skyding228/dubbo-autoconfigure

Download dubbo-autoconfigure

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.skyding228/dubbo-autoconfigure/ -->
<dependency>
    <groupId>com.github.skyding228</groupId>
    <artifactId>dubbo-autoconfigure</artifactId>
    <version>1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.skyding228/dubbo-autoconfigure/
implementation 'com.github.skyding228:dubbo-autoconfigure:1.2'
// https://jarcasting.com/artifacts/com.github.skyding228/dubbo-autoconfigure/
implementation ("com.github.skyding228:dubbo-autoconfigure:1.2")
'com.github.skyding228:dubbo-autoconfigure:jar:1.2'
<dependency org="com.github.skyding228" name="dubbo-autoconfigure" rev="1.2">
  <artifact name="dubbo-autoconfigure" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.skyding228', module='dubbo-autoconfigure', version='1.2')
)
libraryDependencies += "com.github.skyding228" % "dubbo-autoconfigure" % "1.2"
[com.github.skyding228/dubbo-autoconfigure "1.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.freemarker : freemarker jar 2.3.28

provided (3)

Group / Artifact Type Version
org.springframework : spring-beans jar 4.1.4.RELEASE
org.slf4j : slf4j-api jar 1.7.10
com.alibaba : dubbo jar 2.6.4

Project Modules

There are no modules declared in this project.

Auto configure dubbo

register dubbo reference or service to Spring automatically.

This plugin can generate dubbo configuration file automatically base on a freemarker template which you can tell it how to do.

Maven dependency

<dependency>
    <groupId>com.github.skyding228</groupId>
    <artifactId>dubbo-autoconfigure</artifactId>
    <version>1.0</version>
</dependency>

Core class

DubboPostProcessor has three required properties.

  • freemarkerRelativePath

the freemarker template path relative to classpath.You can access all the interfaces that need to be registered to Spring through interfaces. The interfaces is a ArrayList<InterfaceInfo>,more details at com.skyding.dubbo.autoconfigure.InterfaceInfo.

  • interfacePackages

where to scan interfaces ,use comma to split multiple packages. Notice: It will NOT scan the subpackages.

  • serviceSide

It's Boolean type. you should set true when configured in service side ,false in consumer side.

Configure dubbo reference side

  • The jar has a default freemarker template file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="http://www.springframework.org/schema/beans          
    http://www.springframework.org/schema/beans/spring-beans.xsd          
    http://code.alibabatech.com/schema/dubbo          
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
	<#list interfaces as inf>
    <dubbo:reference interface="${inf.clazz.name}" version="1.0" id="${inf.clazz.simpleName?uncap_first}" timeout="15000"/>
	</#list>
</beans> 
  • Configure a bean in Spring

Assume your interfaces which you want to expose locate in com.zx.sms.dao, and your freemarker template is dubbo-reference-simple.ftl.

	<bean class="com.skyding.dubbo.autoconfigure.DubboPostProcessor">
		<property name="freemarkerRelativePath" value="dubbo-reference-simple.ftl"></property>
		<property name="interfacePackages" value="com.zx.sms.dao"></property>
		<property name="serviceSide" value="false"></property>
	</bean>

Configure dubbo service side

  • The jar has a default freemarker template file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd          
    http://code.alibabatech.com/schema/dubbo          
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
	<#list interfaces as inf>
    <dubbo:service interface="${inf.clazz.name}" version="1.0" ref="${inf.ref}" timeout="15000"/>
    </#list>
</beans>  
  • Configure a bean in Spring

Assume your interfaces which you want to expose locate in com.zx.sms.dao, and your freemarker template is dubbo-service-simple.ftl.

	<bean class="com.skyding.dubbo.autoconfigure.DubboPostProcessor">
		<property name="freemarkerRelativePath" value="dubbo-service-simple.ftl"></property>
		<property name="interfacePackages" value="com.zx.sms.dao"></property>
		<property name="serviceSide" value="true"></property>
	</bean>

Versions

Version
1.2
1.1
1.0