Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caopu16
whatsmars
提交
b82e34a5
W
whatsmars
项目概览
caopu16
/
whatsmars
与 Fork 源项目一致
Fork自
武汉红喜 / whatsmars
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
whatsmars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b82e34a5
编写于
6月 08, 2019
作者:
武汉红喜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade dubbo to 2.7.2
上级
51a2334d
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
787 addition
and
1223 deletion
+787
-1223
README.md
README.md
+1
-1
pom.xml
pom.xml
+1
-1
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DelegatingPropertyResolver.java
...ing/starter/autoconfigure/DelegatingPropertyResolver.java
+83
-0
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboAutoConfiguration.java
.../spring/starter/autoconfigure/DubboAutoConfiguration.java
+24
-34
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboConfigurationProperties.java
...g/starter/autoconfigure/DubboConfigurationProperties.java
+300
-0
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboRelaxedBindingAutoConfiguration.java
...r/autoconfigure/DubboRelaxedBindingAutoConfiguration.java
+53
-0
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/RelaxedDubboConfigBinder.java
...pring/starter/autoconfigure/RelaxedDubboConfigBinder.java
+3
-3
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java
...ry/config/DubboConfigBeanDefinitionConflictProcessor.java
+120
-0
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/DubboApplicationContextInitializer.java
...g/starter/context/DubboApplicationContextInitializer.java
+46
-0
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/AwaitingNonWebApplicationListener.java
...rter/context/event/AwaitingNonWebApplicationListener.java
+35
-11
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/OverrideDubboConfigApplicationListener.java
...context/event/OverrideDubboConfigApplicationListener.java
+6
-11
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/WelcomeLogoApplicationListener.java
...starter/context/event/WelcomeLogoApplicationListener.java
+5
-4
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
...r/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
+24
-28
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/DubboUtils.java
...java/org/apache/dubbo/spring/starter/util/DubboUtils.java
+71
-12
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/EnvironmentUtils.java
...rg/apache/dubbo/spring/starter/util/EnvironmentUtils.java
+1
-1
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json
...ain/resources/META-INF/spring-configuration-metadata.json
+0
-1098
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring.factories
...boot-starter/src/main/resources/META-INF/spring.factories
+5
-1
whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/ConsumerApplication.java
...xi/whatsmars/dubbo/demo/consumer/ConsumerApplication.java
+1
-6
whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java
...org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java
+2
-2
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer2.java
.../hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer2.java
+5
-9
whatsmars-dubbo/whatsmars-dubbo-provider-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/provider/ProviderApplication.java
...xi/whatsmars/dubbo/demo/provider/ProviderApplication.java
+1
-1
未找到文件。
README.md
浏览文件 @
b82e34a5
...
...
@@ -28,7 +28,7 @@ whatsmars-spring-cloud | Spring Cloud 微服务生态
whatsmars-zk | zookeeper remoting 封装
### Rocket Stack
-
[
x] [*Dubbo*
](
https://github.com/a
libaba
/dubbo
)
-
[
x] [*Dubbo*
](
https://github.com/a
pache
/dubbo
)
-
[
x] [*ZooKeeper*
](
https://github.com/apache/zookeeper
)
-
[
x] [*RocketMQ*
](
https://github.com/apache/rocketmq
)
-
[
x] [*Kafka*
](
https://github.com/apache/kafka
)
...
...
pom.xml
浏览文件 @
b82e34a5
...
...
@@ -44,7 +44,7 @@
<commons-lang.version>
2.6
</commons-lang.version>
<commons-logging.version>
1.2
</commons-logging.version>
<curator.version>
2.12.0
</curator.version>
<dubbo.version>
2.7.
0
</dubbo.version>
<dubbo.version>
2.7.
2
</dubbo.version>
<fastjson.version>
1.2.44
</fastjson.version>
<guava.version>
20.0
</guava.version>
<hessian.version>
4.0.7
</hessian.version>
...
...
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DelegatingPropertyResolver.java
0 → 100644
浏览文件 @
b82e34a5
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dubbo.spring.starter.autoconfigure
;
import
org.apache.dubbo.common.utils.Assert
;
import
org.springframework.core.env.PropertyResolver
;
import
org.springframework.lang.Nullable
;
/**
* Delegating {@link PropertyResolver}
*
* @since 2.7.1
*/
class
DelegatingPropertyResolver
implements
PropertyResolver
{
private
final
PropertyResolver
delegate
;
DelegatingPropertyResolver
(
PropertyResolver
delegate
)
{
Assert
.
notNull
(
delegate
,
"The delegate of PropertyResolver must not be null"
);
this
.
delegate
=
delegate
;
}
@Override
public
boolean
containsProperty
(
String
key
)
{
return
delegate
.
containsProperty
(
key
);
}
@Override
@Nullable
public
String
getProperty
(
String
key
)
{
return
delegate
.
getProperty
(
key
);
}
@Override
public
String
getProperty
(
String
key
,
String
defaultValue
)
{
return
delegate
.
getProperty
(
key
,
defaultValue
);
}
@Override
@Nullable
public
<
T
>
T
getProperty
(
String
key
,
Class
<
T
>
targetType
)
{
return
delegate
.
getProperty
(
key
,
targetType
);
}
@Override
public
<
T
>
T
getProperty
(
String
key
,
Class
<
T
>
targetType
,
T
defaultValue
)
{
return
delegate
.
getProperty
(
key
,
targetType
,
defaultValue
);
}
@Override
public
String
getRequiredProperty
(
String
key
)
throws
IllegalStateException
{
return
delegate
.
getRequiredProperty
(
key
);
}
@Override
public
<
T
>
T
getRequiredProperty
(
String
key
,
Class
<
T
>
targetType
)
throws
IllegalStateException
{
return
delegate
.
getRequiredProperty
(
key
,
targetType
);
}
@Override
public
String
resolvePlaceholders
(
String
text
)
{
return
delegate
.
resolvePlaceholders
(
text
);
}
@Override
public
String
resolveRequiredPlaceholders
(
String
text
)
throws
IllegalArgumentException
{
return
delegate
.
resolveRequiredPlaceholders
(
text
);
}
}
\ No newline at end of file
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboAutoConfiguration.java
浏览文件 @
b82e34a5
...
...
@@ -16,69 +16,59 @@
*/
package
org.apache.dubbo.spring.starter.autoconfigure
;
import
org.apache.dubbo.config.AbstractConfig
;
import
org.apache.dubbo.config.ApplicationConfig
;
import
org.apache.dubbo.config.annotation.Reference
;
import
org.apache.dubbo.config.annotation.Service
;
import
org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor
;
import
org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor
;
import
org.apache.dubbo.config.spring.context.annotation.DubboComponentScan
;
import
org.apache.dubbo.config.spring.context.annotation.DubboConfigConfiguration
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubbo
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.bind.Binder
;
import
org.springframework.boot.context.properties.source.ConfigurationPropertySources
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.
Scope
;
import
org.springframework.core.env.
Environment
;
import
org.springframework.context.annotation.
Import
;
import
org.springframework.core.env.
PropertyResolver
;
import
java.util.Set
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.*;
import
static
java
.
util
.
Collections
.
emptySet
;
import
static
org
.
springframework
.
beans
.
factory
.
config
.
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.*
;
/**
* Dubbo Auto {@link Configuration}
*
* @see ApplicationConfig
* @see Service
* @see Reference
* @see
DubboComponentScan
* @see
EnableDubboConfig
* @see
EnableDubbo
* @since
1.0
.0
* @see
Service
* @see
ServiceAnnotationBeanPostProcessor
* @see
ReferenceAnnotationBeanPostProcessor
* @since
2.7
.0
*/
@ConditionalOnProperty
(
prefix
=
DUBBO_PREFIX
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@Configuration
@
ConditionalOnProperty
(
prefix
=
DUBBO_PREFIX
,
name
=
"enabled"
,
matchIfMissing
=
true
,
havingValue
=
"true"
)
@
ConditionalOnClass
(
AbstractConfig
.
class
)
@
AutoConfigureAfter
(
DubboRelaxedBindingAutoConfiguration
.
class
)
@
EnableConfigurationProperties
(
DubboConfigurationProperties
.
class
)
public
class
DubboAutoConfiguration
{
/**
* Creates {@link ServiceAnnotationBeanPostProcessor} Bean
*
* @param
environment {@link Environment
} Bean
* @param
propertyResolver {@link PropertyResolver
} Bean
* @return {@link ServiceAnnotationBeanPostProcessor}
*/
@ConditionalOnProperty
(
name
=
BASE_PACKAGES_PROPERTY_NAME
)
@ConditionalOn
Class
(
ConfigurationPropertySources
.
class
)
@ConditionalOnProperty
(
prefix
=
DUBBO_SCAN_PREFIX
,
name
=
BASE_PACKAGES_PROPERTY_NAME
)
@ConditionalOn
Bean
(
name
=
BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME
)
@Bean
public
ServiceAnnotationBeanPostProcessor
serviceAnnotationBeanPostProcessor
(
Environment
environment
)
{
Set
<
String
>
packagesToScan
=
environment
.
getProperty
(
BASE_PACKAGES_PROPERTY_NAME
,
Set
.
class
,
emptySet
());
public
ServiceAnnotationBeanPostProcessor
serviceAnnotationBeanPostProcessor
(
@Qualifier
(
BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME
)
PropertyResolver
propertyResolver
)
{
Set
<
String
>
packagesToScan
=
propertyResolver
.
getProperty
(
BASE_PACKAGES_PROPERTY_NAME
,
Set
.
class
,
emptySet
());
return
new
ServiceAnnotationBeanPostProcessor
(
packagesToScan
);
}
@ConditionalOnClass
(
Binder
.
class
)
@Bean
@Scope
(
scopeName
=
SCOPE_PROTOTYPE
)
public
RelaxedDubboConfigBinder
relaxedDubboConfigBinder
()
{
return
new
RelaxedDubboConfigBinder
();
}
/**
* Creates {@link ReferenceAnnotationBeanPostProcessor} Bean if Absent
*
...
...
@@ -96,7 +86,7 @@ public class DubboAutoConfiguration {
* @see EnableDubboConfig
* @see DubboConfigConfiguration.Single
*/
@
EnableDubboConfig
@
Import
(
DubboConfigConfiguration
.
Single
.
class
)
protected
static
class
SingleDubboConfigConfiguration
{
}
...
...
@@ -106,8 +96,8 @@ public class DubboAutoConfiguration {
* @see EnableDubboConfig
* @see DubboConfigConfiguration.Multiple
*/
@ConditionalOnProperty
(
name
=
MULTIPLE_CONFIG_PROPERTY_NAME
,
havingValue
=
"true"
)
@
EnableDubboConfig
(
multiple
=
true
)
@ConditionalOnProperty
(
prefix
=
DUBBO_CONFIG_PREFIX
,
name
=
MULTIPLE_CONFIG_PROPERTY_NAME
,
matchIfMissing
=
true
)
@
Import
(
DubboConfigConfiguration
.
Multiple
.
class
)
protected
static
class
MultipleDubboConfigConfiguration
{
}
...
...
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboConfigurationProperties.java
0 → 100644
浏览文件 @
b82e34a5
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dubbo.spring.starter.autoconfigure
;
import
org.apache.dubbo.config.ApplicationConfig
;
import
org.apache.dubbo.config.ConsumerConfig
;
import
org.apache.dubbo.config.MetadataReportConfig
;
import
org.apache.dubbo.config.ModuleConfig
;
import
org.apache.dubbo.config.MonitorConfig
;
import
org.apache.dubbo.config.ProtocolConfig
;
import
org.apache.dubbo.config.ProviderConfig
;
import
org.apache.dubbo.config.RegistryConfig
;
import
org.apache.dubbo.config.spring.ConfigCenterBean
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubbo
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.NestedConfigurationProperty
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.
DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.
DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.
DUBBO_PREFIX
;
/**
* Dubbo {@link ConfigurationProperties Config Properties} only used to generate JSON metadata(non-public class)
*
* @since 2.7.1
*/
@ConfigurationProperties
(
DUBBO_PREFIX
)
class
DubboConfigurationProperties
{
@NestedConfigurationProperty
private
Config
config
=
new
Config
();
@NestedConfigurationProperty
private
Scan
scan
=
new
Scan
();
// Single Config Bindings
@NestedConfigurationProperty
private
ApplicationConfig
application
=
new
ApplicationConfig
();
@NestedConfigurationProperty
private
ModuleConfig
module
=
new
ModuleConfig
();
@NestedConfigurationProperty
private
RegistryConfig
registry
=
new
RegistryConfig
();
@NestedConfigurationProperty
private
ProtocolConfig
protocol
=
new
ProtocolConfig
();
@NestedConfigurationProperty
private
MonitorConfig
monitor
=
new
MonitorConfig
();
@NestedConfigurationProperty
private
ProviderConfig
provider
=
new
ProviderConfig
();
@NestedConfigurationProperty
private
ConsumerConfig
consumer
=
new
ConsumerConfig
();
@NestedConfigurationProperty
private
ConfigCenterBean
configCenter
=
new
ConfigCenterBean
();
@NestedConfigurationProperty
private
MetadataReportConfig
metadataReport
=
new
MetadataReportConfig
();
// Multiple Config Bindings
private
Map
<
String
,
ModuleConfig
>
modules
=
new
LinkedHashMap
<>();
private
Map
<
String
,
RegistryConfig
>
registrys
=
new
LinkedHashMap
<>();
private
Map
<
String
,
ProtocolConfig
>
protocols
=
new
LinkedHashMap
<>();
private
Map
<
String
,
MonitorConfig
>
monitors
=
new
LinkedHashMap
<>();
private
Map
<
String
,
ProviderConfig
>
providers
=
new
LinkedHashMap
<>();
private
Map
<
String
,
ConsumerConfig
>
consumers
=
new
LinkedHashMap
<>();
private
Map
<
String
,
ConfigCenterBean
>
configCenters
=
new
LinkedHashMap
<>();
private
Map
<
String
,
MetadataReportConfig
>
metadataReports
=
new
LinkedHashMap
<>();
public
Config
getConfig
()
{
return
config
;
}
public
void
setConfig
(
Config
config
)
{
this
.
config
=
config
;
}
public
Scan
getScan
()
{
return
scan
;
}
public
void
setScan
(
Scan
scan
)
{
this
.
scan
=
scan
;
}
public
ApplicationConfig
getApplication
()
{
return
application
;
}
public
void
setApplication
(
ApplicationConfig
application
)
{
this
.
application
=
application
;
}
public
ModuleConfig
getModule
()
{
return
module
;
}
public
void
setModule
(
ModuleConfig
module
)
{
this
.
module
=
module
;
}
public
RegistryConfig
getRegistry
()
{
return
registry
;
}
public
void
setRegistry
(
RegistryConfig
registry
)
{
this
.
registry
=
registry
;
}
public
ProtocolConfig
getProtocol
()
{
return
protocol
;
}
public
void
setProtocol
(
ProtocolConfig
protocol
)
{
this
.
protocol
=
protocol
;
}
public
MonitorConfig
getMonitor
()
{
return
monitor
;
}
public
void
setMonitor
(
MonitorConfig
monitor
)
{
this
.
monitor
=
monitor
;
}
public
ProviderConfig
getProvider
()
{
return
provider
;
}
public
void
setProvider
(
ProviderConfig
provider
)
{
this
.
provider
=
provider
;
}
public
ConsumerConfig
getConsumer
()
{
return
consumer
;
}
public
void
setConsumer
(
ConsumerConfig
consumer
)
{
this
.
consumer
=
consumer
;
}
public
ConfigCenterBean
getConfigCenter
()
{
return
configCenter
;
}
public
void
setConfigCenter
(
ConfigCenterBean
configCenter
)
{
this
.
configCenter
=
configCenter
;
}
public
MetadataReportConfig
getMetadataReport
()
{
return
metadataReport
;
}
public
void
setMetadataReport
(
MetadataReportConfig
metadataReport
)
{
this
.
metadataReport
=
metadataReport
;
}
public
Map
<
String
,
ModuleConfig
>
getModules
()
{
return
modules
;
}
public
void
setModules
(
Map
<
String
,
ModuleConfig
>
modules
)
{
this
.
modules
=
modules
;
}
public
Map
<
String
,
RegistryConfig
>
getRegistrys
()
{
return
registrys
;
}
public
void
setRegistrys
(
Map
<
String
,
RegistryConfig
>
registrys
)
{
this
.
registrys
=
registrys
;
}
public
Map
<
String
,
ProtocolConfig
>
getProtocols
()
{
return
protocols
;
}
public
void
setProtocols
(
Map
<
String
,
ProtocolConfig
>
protocols
)
{
this
.
protocols
=
protocols
;
}
public
Map
<
String
,
MonitorConfig
>
getMonitors
()
{
return
monitors
;
}
public
void
setMonitors
(
Map
<
String
,
MonitorConfig
>
monitors
)
{
this
.
monitors
=
monitors
;
}
public
Map
<
String
,
ProviderConfig
>
getProviders
()
{
return
providers
;
}
public
void
setProviders
(
Map
<
String
,
ProviderConfig
>
providers
)
{
this
.
providers
=
providers
;
}
public
Map
<
String
,
ConsumerConfig
>
getConsumers
()
{
return
consumers
;
}
public
void
setConsumers
(
Map
<
String
,
ConsumerConfig
>
consumers
)
{
this
.
consumers
=
consumers
;
}
public
Map
<
String
,
ConfigCenterBean
>
getConfigCenters
()
{
return
configCenters
;
}
public
void
setConfigCenters
(
Map
<
String
,
ConfigCenterBean
>
configCenters
)
{
this
.
configCenters
=
configCenters
;
}
public
Map
<
String
,
MetadataReportConfig
>
getMetadataReports
()
{
return
metadataReports
;
}
public
void
setMetadataReports
(
Map
<
String
,
MetadataReportConfig
>
metadataReports
)
{
this
.
metadataReports
=
metadataReports
;
}
static
class
Config
{
/**
* Indicates multiple properties binding from externalized configuration or not.
*/
private
boolean
multiple
=
DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE
;
/**
* The property name of override Dubbo config
*/
private
boolean
override
=
DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE
;
public
boolean
isOverride
()
{
return
override
;
}
public
void
setOverride
(
boolean
override
)
{
this
.
override
=
override
;
}
public
boolean
isMultiple
()
{
return
multiple
;
}
public
void
setMultiple
(
boolean
multiple
)
{
this
.
multiple
=
multiple
;
}
}
static
class
Scan
{
/**
* The basePackages to scan , the multiple-value is delimited by comma
*
* @see EnableDubbo#scanBasePackages()
*/
private
Set
<
String
>
basePackages
=
new
LinkedHashSet
<>();
public
Set
<
String
>
getBasePackages
()
{
return
basePackages
;
}
public
void
setBasePackages
(
Set
<
String
>
basePackages
)
{
this
.
basePackages
=
basePackages
;
}
}
}
\ No newline at end of file
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/DubboRelaxedBindingAutoConfiguration.java
0 → 100644
浏览文件 @
b82e34a5
package
org.apache.dubbo.spring.starter.autoconfigure
;
import
org.apache.dubbo.config.spring.context.properties.DubboConfigBinder
;
import
org.apache.dubbo.config.spring.util.PropertySourcesUtils
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.source.ConfigurationPropertySources
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.core.env.AbstractEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MutablePropertySources
;
import
org.springframework.core.env.PropertyResolver
;
import
java.util.Map
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.*;
import
static
org
.
springframework
.
beans
.
factory
.
config
.
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
;
/**
* Dubbo Relaxed Binding Auto-{@link Configuration} for Spring Boot 2.0
*
* @since 2.7.0
*/
@Configuration
@ConditionalOnProperty
(
prefix
=
DUBBO_PREFIX
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@ConditionalOnClass
(
name
=
"org.springframework.boot.context.properties.bind.Binder"
)
public
class
DubboRelaxedBindingAutoConfiguration
{
@Bean
(
name
=
BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME
)
public
PropertyResolver
dubboScanBasePackagesPropertyResolver
(
ConfigurableEnvironment
environment
)
{
ConfigurableEnvironment
propertyResolver
=
new
AbstractEnvironment
()
{
@Override
protected
void
customizePropertySources
(
MutablePropertySources
propertySources
)
{
Map
<
String
,
Object
>
dubboScanProperties
=
PropertySourcesUtils
.
getSubProperties
(
environment
,
DUBBO_SCAN_PREFIX
);
propertySources
.
addLast
(
new
MapPropertySource
(
"dubboScanProperties"
,
dubboScanProperties
));
}
};
ConfigurationPropertySources
.
attach
(
propertyResolver
);
return
new
DelegatingPropertyResolver
(
propertyResolver
);
}
@ConditionalOnMissingBean
(
name
=
RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME
,
value
=
DubboConfigBinder
.
class
)
@Bean
(
RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME
)
@Scope
(
scopeName
=
SCOPE_PROTOTYPE
)
public
DubboConfigBinder
relaxedDubboConfigBinder
()
{
return
new
RelaxedDubboConfigBinder
();
}
}
\ No newline at end of file
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/autoconfigure/RelaxedDubboConfigBinder.java
浏览文件 @
b82e34a5
...
...
@@ -35,9 +35,9 @@ import static org.springframework.boot.context.properties.source.ConfigurationPr
* Spring Boot Relaxed {@link DubboConfigBinder} implementation
* see org.springframework.boot.context.properties.ConfigurationPropertiesBinder
*
* @since
0.1.1
* @since
2.7.0
*/
public
class
RelaxedDubboConfigBinder
extends
AbstractDubboConfigBinder
{
class
RelaxedDubboConfigBinder
extends
AbstractDubboConfigBinder
{
@Override
public
<
C
extends
AbstractConfig
>
void
bind
(
String
prefix
,
C
dubboConfig
)
{
...
...
@@ -71,4 +71,4 @@ public class RelaxedDubboConfigBinder extends AbstractDubboConfigBinder {
}
return
handler
;
}
}
}
\ No newline at end of file
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/beans/factory/config/DubboConfigBeanDefinitionConflictProcessor.java
0 → 100644
浏览文件 @
b82e34a5
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dubbo.spring.starter.beans.factory.config
;
import
org.apache.dubbo.config.ApplicationConfig
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.BeanFactoryUtils
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.Environment
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
static
org
.
springframework
.
beans
.
factory
.
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
;
import
static
org
.
springframework
.
context
.
ConfigurableApplicationContext
.
ENVIRONMENT_BEAN_NAME
;
/**
* Dubbo Config {@link BeanDefinition Bean Definition} {@link BeanDefinitionRegistryPostProcessor processor}
* to resolve conflict
*
* @see BeanDefinition
* @see BeanDefinitionRegistryPostProcessor
* @since 2.7.1
*/
public
class
DubboConfigBeanDefinitionConflictProcessor
implements
BeanDefinitionRegistryPostProcessor
,
Ordered
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
BeanDefinitionRegistry
registry
;
private
Environment
environment
;
@Override
public
void
postProcessBeanDefinitionRegistry
(
BeanDefinitionRegistry
registry
)
throws
BeansException
{
this
.
registry
=
registry
;
}
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
throws
BeansException
{
resolveUniqueApplicationConfigBean
(
registry
,
beanFactory
);
}
/**
* Resolve the unique {@link ApplicationConfig} Bean
*
* @param registry {@link BeanDefinitionRegistry} instance
* @param beanFactory {@link ConfigurableListableBeanFactory} instance
* @see EnableDubboConfig
*/
private
void
resolveUniqueApplicationConfigBean
(
BeanDefinitionRegistry
registry
,
ConfigurableListableBeanFactory
beanFactory
)
{
this
.
environment
=
beanFactory
.
getBean
(
ENVIRONMENT_BEAN_NAME
,
Environment
.
class
);
String
[]
beansNames
=
beanNamesForTypeIncludingAncestors
(
beanFactory
,
ApplicationConfig
.
class
);
if
(
beansNames
.
length
<
2
)
{
// If the number of ApplicationConfig beans is less than two, return immediately.
return
;
}
// Remove ApplicationConfig Beans that are configured by "dubbo.application.*"
Stream
.
of
(
beansNames
)
.
filter
(
this
::
isConfiguredApplicationConfigBeanName
)
.
forEach
(
registry:
:
removeBeanDefinition
);
beansNames
=
beanNamesForTypeIncludingAncestors
(
beanFactory
,
ApplicationConfig
.
class
);
if
(
beansNames
.
length
>
1
)
{
throw
new
IllegalStateException
(
String
.
format
(
"There are more than one instances of %s, whose bean definitions : %s"
,
ApplicationConfig
.
class
.
getSimpleName
(),
Stream
.
of
(
beansNames
)
.
map
(
registry:
:
getBeanDefinition
)
.
collect
(
Collectors
.
toList
()))
);
}
}
private
boolean
isConfiguredApplicationConfigBeanName
(
String
beanName
)
{
boolean
removed
=
BeanFactoryUtils
.
isGeneratedBeanName
(
beanName
)
// Dubbo ApplicationConfig id as bean name
||
Objects
.
equals
(
beanName
,
environment
.
getProperty
(
"dubbo.application.id"
));
if
(
removed
)
{
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
"The {} bean [ name : {} ] has been removed!"
,
ApplicationConfig
.
class
.
getSimpleName
(),
beanName
);
}
}
return
removed
;
}
@Override
public
int
getOrder
()
{
return
LOWEST_PRECEDENCE
;
}
}
\ No newline at end of file
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/DubboApplicationContextInitializer.java
0 → 100644
浏览文件 @
b82e34a5
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dubbo.spring.starter.context
;
import
org.apache.dubbo.spring.starter.beans.factory.config.DubboConfigBeanDefinitionConflictProcessor
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.Ordered
;
/**
* Dubbo {@link ApplicationContextInitializer} implementation
*
* @see ApplicationContextInitializer
* @since 2.7.1
*/
public
class
DubboApplicationContextInitializer
implements
ApplicationContextInitializer
,
Ordered
{
@Override
public
void
initialize
(
ConfigurableApplicationContext
applicationContext
)
{
overrideBeanDefinitions
(
applicationContext
);
}
private
void
overrideBeanDefinitions
(
ConfigurableApplicationContext
applicationContext
)
{
applicationContext
.
addBeanFactoryPostProcessor
(
new
DubboConfigBeanDefinitionConflictProcessor
());
}
@Override
public
int
getOrder
()
{
return
HIGHEST_PRECEDENCE
;
}
}
\ No newline at end of file
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/AwaitingNonWebApplicationListener.java
浏览文件 @
b82e34a5
...
...
@@ -19,12 +19,13 @@ package org.apache.dubbo.spring.starter.context.event;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.WebApplicationType
;
import
org.springframework.boot.context.event.ApplicationReadyEvent
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.event.ContextClosedEvent
;
import
org.springframework.context.event.SmartApplicationListener
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.concurrent.ExecutorService
;
...
...
@@ -37,10 +38,15 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* Awaiting Non-Web Spring Boot {@link ApplicationListener}
*
* @since
0.1.1
* @since
2.7.0
*/
public
class
AwaitingNonWebApplicationListener
implements
SmartApplicationListener
{
private
static
final
String
[]
WEB_APPLICATION_CONTEXT_CLASSES
=
new
String
[]{
"org.springframework.web.context.WebApplicationContext"
,
"org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext"
};
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AwaitingNonWebApplicationListener
.
class
);
private
static
final
Class
<?
extends
ApplicationEvent
>[]
SUPPORTED_APPLICATION_EVENTS
=
...
...
@@ -54,6 +60,14 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen
private
final
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
private
static
<
T
>
T
[]
of
(
T
...
values
)
{
return
values
;
}
static
AtomicBoolean
getAwaited
()
{
return
awaited
;
}
@Override
public
boolean
supportsEventType
(
Class
<?
extends
ApplicationEvent
>
eventType
)
{
return
ObjectUtils
.
containsElement
(
SUPPORTED_APPLICATION_EVENTS
,
eventType
);
...
...
@@ -64,10 +78,6 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen
return
true
;
}
private
static
<
T
>
T
[]
of
(
T
...
values
)
{
return
values
;
}
@Override
public
void
onApplicationEvent
(
ApplicationEvent
event
)
{
if
(
event
instanceof
ApplicationReadyEvent
)
{
...
...
@@ -86,12 +96,30 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen
final
SpringApplication
springApplication
=
event
.
getSpringApplication
();
if
(
!
WebApplicationType
.
NONE
.
equals
(
springApplication
.
getWebApplicationType
()))
{
if
(
isWebApplication
(
event
.
getApplicationContext
(),
springApplication
.
getClassLoader
()))
{
return
;
}
await
();
}
private
static
boolean
isWebApplication
(
ApplicationContext
applicationContext
,
ClassLoader
classLoader
)
{
boolean
webApplication
=
false
;
for
(
String
contextClass
:
WEB_APPLICATION_CONTEXT_CLASSES
)
{
if
(
isAssignable
(
contextClass
,
applicationContext
.
getClass
(),
classLoader
))
{
webApplication
=
true
;
break
;
}
}
return
webApplication
;
}
private
static
boolean
isAssignable
(
String
target
,
Class
<?>
type
,
ClassLoader
classLoader
)
{
try
{
return
ClassUtils
.
resolveClassName
(
target
,
classLoader
).
isAssignableFrom
(
type
);
}
catch
(
Throwable
ex
)
{
return
false
;
}
}
protected
void
onContextClosedEvent
(
ContextClosedEvent
event
)
{
...
...
@@ -146,8 +174,4 @@ public class AwaitingNonWebApplicationListener implements SmartApplicationListen
lock
.
unlock
();
}
}
static
AtomicBoolean
getAwaited
()
{
return
awaited
;
}
}
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/OverrideDubboConfigApplicationListener.java
浏览文件 @
b82e34a5
...
...
@@ -28,7 +28,9 @@ import org.springframework.core.env.Environment;
import
java.util.SortedMap
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.*;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.
DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.
OVERRIDE_CONFIG_FULL_PROPERTY_NAME
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.
filterDubboProperties
;
/**
* {@link ApplicationListener} to override the dubbo properties from {@link Environment}into
...
...
@@ -37,7 +39,7 @@ import static org.apache.dubbo.spring.starter.util.DubboUtils.*;
* <p>
*
* @see ConfigUtils
* @since
1.0
.0
* @since
2.7
.0
*/
@Order
// LOWEST_PRECEDENCE Make sure last execution
public
class
OverrideDubboConfigApplicationListener
implements
ApplicationListener
<
ApplicationEnvironmentPreparedEvent
>
{
...
...
@@ -53,7 +55,7 @@ public class OverrideDubboConfigApplicationListener implements ApplicationListen
ConfigurableEnvironment
environment
=
event
.
getEnvironment
();
boolean
override
=
environment
.
getProperty
(
OVERRIDE_CONFIG_PROPERTY_NAME
,
boolean
.
class
,
boolean
override
=
environment
.
getProperty
(
OVERRIDE_CONFIG_
FULL_
PROPERTY_NAME
,
boolean
.
class
,
DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE
);
if
(
override
)
{
...
...
@@ -63,19 +65,12 @@ public class OverrideDubboConfigApplicationListener implements ApplicationListen
ConfigUtils
.
getProperties
().
putAll
(
dubboProperties
);
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
"Dubbo Config was overridden by externalized configuration {}"
,
dubboProperties
);
}
}
else
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
"Disable override Dubbo Config caused by property {} = {}"
,
OVERRIDE_CONFIG_PROPERTY_NAME
,
override
);
logger
.
info
(
"Disable override Dubbo Config caused by property {} = {}"
,
OVERRIDE_CONFIG_FULL_PROPERTY_NAME
,
override
);
}
}
}
...
...
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/context/event/WelcomeLogoApplicationListener.java
浏览文件 @
b82e34a5
...
...
@@ -17,11 +17,12 @@
package
org.apache.dubbo.spring.starter.context.event
;
import
org.apache.dubbo.common.Version
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent
;
import
org.springframework.boot.context.logging.LoggingApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.annotation.Order
;
import
java.util.concurrent.atomic.AtomicBoolean
;
...
...
@@ -32,9 +33,9 @@ import static org.apache.dubbo.spring.starter.util.DubboUtils.*;
* Dubbo Welcome Logo {@link ApplicationListener}
*
* @see ApplicationListener
* @since
1.0
.0
* @since
2.7
.0
*/
@Order
(
LoggingApplicationListener
.
DEFAULT_ORDER
+
1
)
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
+
20
+
1
)
// After LoggingApplicationListener#DEFAULT_ORDER
public
class
WelcomeLogoApplicationListener
implements
ApplicationListener
<
ApplicationEnvironmentPreparedEvent
>
{
private
static
AtomicBoolean
processed
=
new
AtomicBoolean
(
false
);
...
...
@@ -72,7 +73,7 @@ public class WelcomeLogoApplicationListener implements ApplicationListener<Appli
bannerTextBuilder
.
append
(
LINE_SEPARATOR
)
.
append
(
LINE_SEPARATOR
)
.
append
(
" :: Dubbo Spring Boot (v"
).
append
(
Version
.
getVersion
(
getClass
(),
"1.0.0"
)).
append
(
") : "
)
.
append
(
" :: Dubbo Spring Boot (v"
).
append
(
Version
.
getVersion
(
getClass
(),
Version
.
getVersion
()
)).
append
(
") : "
)
.
append
(
DUBBO_SPRING_BOOT_GITHUB_URL
)
.
append
(
LINE_SEPARATOR
)
.
append
(
" :: Dubbo (v"
).
append
(
Version
.
getVersion
()).
append
(
") : "
)
...
...
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
浏览文件 @
b82e34a5
...
...
@@ -16,15 +16,15 @@
*/
package
org.apache.dubbo.spring.starter.env
;
import
org.apache.dubbo.config.ApplicationConfig
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubboConfigBinding
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.context.ContextIdApplicationContextInitializer
;
import
org.springframework.boot.env.EnvironmentPostProcessor
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.*
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MutablePropertySources
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
...
...
@@ -32,6 +32,8 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Properties
;
import
static
org
.
apache
.
dubbo
.
spring
.
starter
.
util
.
DubboUtils
.*;
/**
* The lowest precedence {@link EnvironmentPostProcessor} processes
* {@link SpringApplication#setDefaultProperties(Properties) Spring Boot default properties} for Dubbo
...
...
@@ -42,32 +44,13 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
/**
* The name of default {@link PropertySource} defined in SpringApplication#configurePropertySources method.
*/
private
static
final
String
PROPERTY_SOURCE_NAME
=
"defaultProperties"
;
/**
* The property name of Spring Application
*
* @see ContextIdApplicationContextInitializer
*/
private
static
final
String
SPRING_APPLICATION_NAME_PROPERTY
=
"spring.application.name"
;
/**
* The property name of {@link ApplicationConfig}
*
* @see EnableDubboConfig
* @see EnableDubboConfigBinding
*/
private
static
final
String
DUBBO_APPLICATION_NAME_PROPERTY
=
"dubbo.application.name"
;
public
static
final
String
PROPERTY_SOURCE_NAME
=
"defaultProperties"
;
/**
* The property name of {@link EnableDubboConfig#multiple() @EnableDubboConfig.multiple()}
* The property name of "spring.main.allow-bean-definition-overriding".
* Please refer to: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#bean-overriding
*/
private
static
final
String
DUBBO_CONFIG_MULTIPLE_PROPERTY
=
"dubbo.config.multiple"
;
/**
* The property name of {@link ApplicationConfig#getQosEnable() application's QOS enable}
*/
private
static
final
String
DUBBO_APPLICATION_QOS_ENABLE_PROPERTY
=
"dubbo.application.qos-enable"
;
public
static
final
String
ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY
=
"spring.main.allow-bean-definition-overriding"
;
@Override
public
void
postProcessEnvironment
(
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
...
...
@@ -88,6 +71,7 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
setDubboApplicationNameProperty
(
environment
,
defaultProperties
);
setDubboConfigMultipleProperty
(
defaultProperties
);
setDubboApplicationQosEnableProperty
(
defaultProperties
);
setAllowBeanDefinitionOverriding
(
defaultProperties
);
return
defaultProperties
;
}
...
...
@@ -107,6 +91,18 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
defaultProperties
.
put
(
DUBBO_APPLICATION_QOS_ENABLE_PROPERTY
,
Boolean
.
FALSE
.
toString
());
}
/**
* Set {@link #ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY "spring.main.allow-bean-definition-overriding"} to be
* <code>true</code> as default.
*
* @param defaultProperties the default {@link Properties properties}
* @see #ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY
* @since 2.7.1
*/
private
void
setAllowBeanDefinitionOverriding
(
Map
<
String
,
Object
>
defaultProperties
)
{
defaultProperties
.
put
(
ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY
,
Boolean
.
TRUE
.
toString
());
}
/**
* Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)
*
...
...
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/DubboUtils.java
浏览文件 @
b82e34a5
...
...
@@ -16,7 +16,15 @@
*/
package
org.apache.dubbo.spring.starter.util
;
import
org.apache.dubbo.config.ApplicationConfig
;
import
org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubboConfigBinding
;
import
org.apache.dubbo.config.spring.context.properties.DubboConfigBinder
;
import
org.springframework.boot.context.ContextIdApplicationContextInitializer
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.PropertyResolver
;
import
java.util.Collections
;
import
java.util.Map
;
...
...
@@ -26,7 +34,7 @@ import java.util.TreeMap;
/**
* The utilities class for Dubbo
*
* @since
1.0
.0
* @since
2.7
.0
*/
public
abstract
class
DubboUtils
{
...
...
@@ -49,38 +57,38 @@ public abstract class DubboUtils {
/**
* The prefix of property name for Dubbo scan
*/
public
static
final
String
DUBBO_SCAN_PREFIX
=
DUBBO_PREFIX
+
PROPERTY_NAME_SEPARATOR
+
"scan"
;
public
static
final
String
DUBBO_SCAN_PREFIX
=
DUBBO_PREFIX
+
PROPERTY_NAME_SEPARATOR
+
"scan"
+
PROPERTY_NAME_SEPARATOR
;
/**
* The prefix of property name for Dubbo Config
.ØØ
* The prefix of property name for Dubbo Config
*/
public
static
final
String
DUBBO_CONFIG_PREFIX
=
DUBBO_PREFIX
+
PROPERTY_NAME_SEPARATOR
+
"config"
;
public
static
final
String
DUBBO_CONFIG_PREFIX
=
DUBBO_PREFIX
+
PROPERTY_NAME_SEPARATOR
+
"config"
+
PROPERTY_NAME_SEPARATOR
;
/**
* The property name of base packages to scan
* <p>
* The default value is empty set.
*/
public
static
final
String
BASE_PACKAGES_PROPERTY_NAME
=
DUBBO_SCAN_PREFIX
+
PROPERTY_NAME_SEPARATOR
+
"base-packages"
;
public
static
final
String
BASE_PACKAGES_PROPERTY_NAME
=
"base-packages"
;
/**
* The property name of multiple properties binding from externalized configuration
* <p>
* The default value is {@link #DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE}
*/
public
static
final
String
MULTIPLE_CONFIG_PROPERTY_NAME
=
DUBBO_CONFIG_PREFIX
+
PROPERTY_NAME_SEPARATOR
+
"multiple"
;
public
static
final
String
MULTIPLE_CONFIG_PROPERTY_NAME
=
"multiple"
;
/**
* The default value of multiple properties binding from externalized configuration
*/
public
static
final
boolean
DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE
=
fals
e
;
public
static
final
boolean
DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE
=
tru
e
;
/**
* The property name of override Dubbo config
* <p>
* The default value is {@link #DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE}
*/
public
static
final
String
OVERRIDE_CONFIG_
PROPERTY_NAME
=
DUBBO_CONFIG_PREFIX
+
PROPERTY_NAME_SEPARATOR
+
"override"
;
public
static
final
String
OVERRIDE_CONFIG_
FULL_PROPERTY_NAME
=
DUBBO_CONFIG_PREFIX
+
"override"
;
/**
* The default property value of override Dubbo config
...
...
@@ -91,28 +99,79 @@ public abstract class DubboUtils {
/**
* The github URL of Dubbo Spring Boot
*/
public
static
final
String
DUBBO_SPRING_BOOT_GITHUB_URL
=
"https://github.com/apache/
incubator-
dubbo-spring-boot-project"
;
public
static
final
String
DUBBO_SPRING_BOOT_GITHUB_URL
=
"https://github.com/apache/dubbo-spring-boot-project"
;
/**
* The git URL of Dubbo Spring Boot
*/
public
static
final
String
DUBBO_SPRING_BOOT_GIT_URL
=
"https://github.com/apache/
incubator-
dubbo-spring-boot-project.git"
;
public
static
final
String
DUBBO_SPRING_BOOT_GIT_URL
=
"https://github.com/apache/dubbo-spring-boot-project.git"
;
/**
* The issues of Dubbo Spring Boot
*/
public
static
final
String
DUBBO_SPRING_BOOT_ISSUES_URL
=
"https://github.com/apache/
incubator-
dubbo-spring-boot-project/issues"
;
public
static
final
String
DUBBO_SPRING_BOOT_ISSUES_URL
=
"https://github.com/apache/dubbo-spring-boot-project/issues"
;
/**
* The github URL of Dubbo
*/
public
static
final
String
DUBBO_GITHUB_URL
=
"https://github.com/apache/
incubator-
dubbo"
;
public
static
final
String
DUBBO_GITHUB_URL
=
"https://github.com/apache/dubbo"
;
/**
* The google group URL of Dubbo
*/
public
static
final
String
DUBBO_MAILING_LIST
=
"dev@dubbo.apache.org"
;
/**
* The bean name of Relaxed-binding {@link DubboConfigBinder}
*/
public
static
final
String
RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME
=
"relaxedDubboConfigBinder"
;
/**
* The bean name of {@link PropertyResolver} for {@link ServiceAnnotationBeanPostProcessor}'s base-packages
*/
public
static
final
String
BASE_PACKAGES_PROPERTY_RESOLVER_BEAN_NAME
=
"dubboScanBasePackagesPropertyResolver"
;
/**
* The property name of Spring Application
*
* @see ContextIdApplicationContextInitializer
* @since 2.7.1
*/
public
static
final
String
SPRING_APPLICATION_NAME_PROPERTY
=
"spring.application.name"
;
/**
* The property id of {@link ApplicationConfig} Bean
*
* @see EnableDubboConfig
* @see EnableDubboConfigBinding
* @since 2.7.1
*/
public
static
final
String
DUBBO_APPLICATION_ID_PROPERTY
=
"dubbo.application.id"
;
/**
* The property name of {@link ApplicationConfig}
*
* @see EnableDubboConfig
* @see EnableDubboConfigBinding
* @since 2.7.1
*/
public
static
final
String
DUBBO_APPLICATION_NAME_PROPERTY
=
"dubbo.application.name"
;
/**
* The property name of {@link ApplicationConfig#getQosEnable() application's QOS enable}
*
* @since 2.7.1
*/
public
static
final
String
DUBBO_APPLICATION_QOS_ENABLE_PROPERTY
=
"dubbo.application.qos-enable"
;
/**
* The property name of {@link EnableDubboConfig#multiple() @EnableDubboConfig.multiple()}
*
* @since 2.7.1
*/
public
static
final
String
DUBBO_CONFIG_MULTIPLE_PROPERTY
=
"dubbo.config.multiple"
;
/**
* Filters Dubbo Properties from {@link ConfigurableEnvironment}
*
...
...
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/java/org/apache/dubbo/spring/starter/util/EnvironmentUtils.java
浏览文件 @
b82e34a5
...
...
@@ -27,7 +27,7 @@ import java.util.Map;
* The utilities class for {@link Environment}
*
* @see Environment
* @since
1.0
.0
* @since
2.7
.0
*/
public
abstract
class
EnvironmentUtils
{
...
...
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json
已删除
100644 → 0
浏览文件 @
51a2334d
此差异已折叠。
点击以展开。
whatsmars-dubbo/dubbo-spring-boot-starter/src/main/resources/META-INF/spring.factories
浏览文件 @
b82e34a5
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.apache.dubbo.spring.starter.autoconfigure.DubboRelaxedBindingAutoConfiguration,\
org.apache.dubbo.spring.starter.autoconfigure.DubboAutoConfiguration
...
...
@@ -8,4 +9,7 @@ org.apache.dubbo.spring.starter.context.event.WelcomeLogoApplicationListener,\
org.apache.dubbo.spring.starter.context.event.AwaitingNonWebApplicationListener
org.springframework.boot.env.EnvironmentPostProcessor=\
org.apache.dubbo.spring.starter.env.DubboDefaultPropertiesEnvironmentPostProcessor
\ No newline at end of file
org.apache.dubbo.spring.starter.env.DubboDefaultPropertiesEnvironmentPostProcessor
org.springframework.context.ApplicationContextInitializer=\
org.apache.dubbo.spring.starter.context.DubboApplicationContextInitializer
\ No newline at end of file
whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/ConsumerApplication.java
浏览文件 @
b82e34a5
package
org.hongxi.whatsmars.dubbo.demo.consumer
;
import
org.hongxi.whatsmars.dubbo.demo.consumer.rpc.DemoRpc
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.ConfigurableApplicationContext
;
/**
* Created by javahongxi on 2017/12/4.
...
...
@@ -11,9 +9,6 @@ import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
public
class
ConsumerApplication
{
public
static
void
main
(
String
[]
args
)
{
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
ConsumerApplication
.
class
,
args
);
// DemoRpc demoRpc = context.getBean(DemoRpc.class);
// System.out.println(demoRpc.sayHello("Lily"));
// System.out.println(demoRpc.sayHello2("Lily"));
SpringApplication
.
run
(
ConsumerApplication
.
class
,
args
);
}
}
whatsmars-dubbo/whatsmars-dubbo-consumer-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/rpc/DemoRpc.java
浏览文件 @
b82e34a5
...
...
@@ -15,10 +15,10 @@ public class DemoRpc {
/**
* 当不指定registry时,Reference会从所有含有该service的registry里选择一个registry
*/
@Reference
(
registry
=
"defaultRegistry"
,
check
=
false
)
@Reference
(
registry
=
"defaultRegistry"
)
private
DemoService
demoService
;
@Reference
(
registry
=
"otherRegistry"
,
check
=
false
)
@Reference
(
registry
=
"otherRegistry"
)
private
OtherService
otherService
;
public
String
sayHello
(
String
name
)
{
...
...
whatsmars-dubbo/whatsmars-dubbo-consumer/src/main/java/org/hongxi/whatsmars/dubbo/demo/consumer/AsyncConsumer2.java
浏览文件 @
b82e34a5
...
...
@@ -22,19 +22,15 @@ public class AsyncConsumer2 {
final
DemoService
demoService
=
(
DemoService
)
context
.
getBean
(
"demoService"
);
Future
<
String
>
f
=
RpcContext
.
getContext
().
asyncCall
(
new
Callable
<
String
>()
{
public
String
call
()
throws
Exception
{
return
demoService
.
sayHello
(
"async call request"
);
}
Future
<
String
>
f
=
RpcContext
.
getContext
().
asyncCall
(()
->
{
return
demoService
.
sayHello
(
"async call request"
);
});
System
.
out
.
println
(
"async call ret :"
+
f
.
get
());
RpcContext
.
getContext
().
asyncCall
(
new
Runnable
()
{
public
void
run
()
{
demoService
.
sayHello
(
"oneway call request1"
);
demoService
.
sayHello
(
"oneway call request2"
);
}
RpcContext
.
getContext
().
asyncCall
(()
->
{
demoService
.
sayHello
(
"oneway call request1"
);
demoService
.
sayHello
(
"oneway call request2"
);
});
System
.
in
.
read
();
...
...
whatsmars-dubbo/whatsmars-dubbo-provider-boot/src/main/java/org/hongxi/whatsmars/dubbo/demo/provider/ProviderApplication.java
浏览文件 @
b82e34a5
...
...
@@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
*/
@SpringBootApplication
public
class
ProviderApplication
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ProviderApplication
.
class
,
args
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录