Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
schbrain-parent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
schbrain-parent
Commits
c61e54e4
Commit
c61e54e4
authored
Jul 31, 2023
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish ConfigurableProperties load
parent
f2781612
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
89 additions
and
96 deletions
+89
-96
commons/common-util/src/main/java/com/schbrain/common/util/ConfigurationPropertiesUtils.java
...om/schbrain/common/util/ConfigurationPropertiesUtils.java
+17
-6
commons/common-util/src/main/java/com/schbrain/common/util/support/ConfigurableProperties.java
.../schbrain/common/util/support/ConfigurableProperties.java
+2
-9
commons/web-common/src/main/java/com/schbrain/common/web/properties/WebProperties.java
...ava/com/schbrain/common/web/properties/WebProperties.java
+1
-1
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java
...rk/autoconfigure/apollo/ConfigurablePropertiesLoader.java
+54
-19
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/config/OrderedMapPropertySource.java
...autoconfigure/apollo/config/OrderedMapPropertySource.java
+4
-4
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/util/ConfigUtils.java
...rain/framework/autoconfigure/apollo/util/ConfigUtils.java
+0
-46
starters/cache-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/cache/properties/CacheProperties.java
...ework/autoconfigure/cache/properties/CacheProperties.java
+1
-1
starters/cache-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/cache/provider/redis/RedisProperties.java
...k/autoconfigure/cache/provider/redis/RedisProperties.java
+1
-1
starters/elasticsearch-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/elasticsearch/properties/ElasticsearchProperties.java
...ure/elasticsearch/properties/ElasticsearchProperties.java
+1
-1
starters/logger-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/logger/listener/LoggerConfigLoadedEventListener.java
...gure/logger/listener/LoggerConfigLoadedEventListener.java
+3
-3
starters/logger-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/logger/properties/LoggerProperties.java
...ork/autoconfigure/logger/properties/LoggerProperties.java
+1
-1
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/properties/DataSourceProperties.java
...utoconfigure/mybatis/properties/DataSourceProperties.java
+1
-1
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/properties/MybatisProperties.java
...k/autoconfigure/mybatis/properties/MybatisProperties.java
+1
-1
starters/oss-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/oss/properties/OssProperties.java
...framework/autoconfigure/oss/properties/OssProperties.java
+1
-1
starters/xxl-job-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/xxl/properties/XxlJobProperties.java
...mework/autoconfigure/xxl/properties/XxlJobProperties.java
+1
-1
No files found.
commons/common-util/src/main/java/com/schbrain/common/util/ConfigurationPropertiesUtils.java
View file @
c61e54e4
package
com.schbrain.common.util
;
package
com.schbrain.common.util
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
com.google.common.base.CaseFormat
;
import
com.google.common.base.CaseFormat
;
import
com.google.common.base.Converter
;
import
com.google.common.base.Converter
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.NestedConfigurationProperty
;
import
org.springframework.core.annotation.MergedAnnotation
;
import
org.springframework.core.annotation.MergedAnnotation
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -22,11 +24,11 @@ public class ConfigurationPropertiesUtils {
...
@@ -22,11 +24,11 @@ public class ConfigurationPropertiesUtils {
return
toMap
(
source
,
true
);
return
toMap
(
source
,
true
);
}
}
public
static
Map
<
String
,
Object
>
toMap
(
Object
source
,
boolean
ignoreNull
)
{
public
static
Map
<
String
,
Object
>
toMap
(
Object
source
,
boolean
ignoreNull
Value
)
{
return
toMap
(
source
,
true
,
DEFAULT_CONVERTER
);
return
toMap
(
source
,
true
,
DEFAULT_CONVERTER
);
}
}
public
static
Map
<
String
,
Object
>
toMap
(
Object
source
,
boolean
ignoreNull
,
Converter
<
String
,
String
>
converter
)
{
public
static
Map
<
String
,
Object
>
toMap
(
Object
source
,
boolean
ignoreNull
Value
,
Converter
<
String
,
String
>
converter
)
{
if
(
source
==
null
)
{
if
(
source
==
null
)
{
return
Collections
.
emptyMap
();
return
Collections
.
emptyMap
();
}
}
...
@@ -35,15 +37,24 @@ public class ConfigurationPropertiesUtils {
...
@@ -35,15 +37,24 @@ public class ConfigurationPropertiesUtils {
if
(
sourceClass
.
isAnnotationPresent
(
ConfigurationProperties
.
class
))
{
if
(
sourceClass
.
isAnnotationPresent
(
ConfigurationProperties
.
class
))
{
String
prefix
=
getPrefix
(
sourceClass
);
String
prefix
=
getPrefix
(
sourceClass
);
Map
<
String
,
Object
>
sourceMap
=
new
LinkedHashMap
<>();
Map
<
String
,
Object
>
sourceMap
=
new
LinkedHashMap
<>();
return
BeanUtil
.
beanToMap
(
source
,
sourceMap
,
ignoreNull
,
key
->
prefix
+
"."
+
converter
.
convert
(
key
));
CopyOptions
copyOptions
=
CopyOptions
.
create
()
.
setIgnoreNullValue
(
ignoreNullValue
)
.
setPropertiesFilter
((
field
,
value
)
->
!
field
.
isAnnotationPresent
(
NestedConfigurationProperty
.
class
))
.
setFieldNameEditor
(
key
->
prefix
+
"."
+
converter
.
convert
(
key
));
return
BeanUtil
.
beanToMap
(
source
,
sourceMap
,
copyOptions
);
}
}
return
BeanUtil
.
beanToMap
(
source
);
return
BeanUtil
.
beanToMap
(
source
);
}
}
public
static
String
getPrefix
(
Class
<?>
sourceClass
)
{
public
static
String
getPrefix
(
Class
<?>
sourceClass
)
{
ConfigurationProperties
configurationProperties
=
sourceClass
.
getAnnotation
(
ConfigurationProperties
.
class
);
ConfigurationProperties
annotation
=
sourceClass
.
getAnnotation
(
ConfigurationProperties
.
class
);
MergedAnnotation
<
ConfigurationProperties
>
mergedAnnotation
=
MergedAnnotation
.
from
(
configurationProperties
);
if
(
annotation
==
null
)
{
String
className
=
ConfigurationProperties
.
class
.
getName
();
String
errorDetail
=
sourceClass
.
getSimpleName
()
+
" must annotated @"
+
className
+
" or overwrite getPropertiesPrefix method"
;
throw
new
IllegalStateException
(
errorDetail
);
}
MergedAnnotation
<
ConfigurationProperties
>
mergedAnnotation
=
MergedAnnotation
.
from
(
annotation
);
return
mergedAnnotation
.
getString
(
MergedAnnotation
.
VALUE
);
return
mergedAnnotation
.
getString
(
MergedAnnotation
.
VALUE
);
}
}
}
}
\ No newline at end of file
commons/common-util/src/main/java/com/schbrain/common/util/support/ConfigurableProperties.java
View file @
c61e54e4
package
com.schbrain.common.util.support
;
package
com.schbrain.common.util.support
;
import
com.schbrain.common.util.ConfigurationPropertiesUtils
;
import
com.schbrain.common.util.ConfigurationPropertiesUtils
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.bind.Bindable
;
import
org.springframework.boot.context.properties.bind.Bindable
;
import
org.springframework.boot.context.properties.bind.Binder
;
import
org.springframework.boot.context.properties.bind.Binder
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.Ordered
;
...
@@ -33,14 +32,8 @@ public interface ConfigurableProperties extends Ordered {
...
@@ -33,14 +32,8 @@ public interface ConfigurableProperties extends Ordered {
/**
/**
* the prefix of properties
* the prefix of properties
*/
*/
private
String
getPropertiesPrefix
()
{
default
String
getPropertiesPrefix
()
{
ConfigurationProperties
annotation
=
getClass
().
getAnnotation
(
ConfigurationProperties
.
class
);
if
(
annotation
==
null
)
{
String
className
=
ConfigurationProperties
.
class
.
getName
();
String
errorDetail
=
getClass
().
getSimpleName
()
+
" must annotated @"
+
className
+
" or overwrite getPrefix method"
;
throw
new
IllegalStateException
(
errorDetail
);
}
return
ConfigurationPropertiesUtils
.
getPrefix
(
getClass
());
return
ConfigurationPropertiesUtils
.
getPrefix
(
getClass
());
}
}
}
}
\ No newline at end of file
commons/web-common/src/main/java/com/schbrain/common/web/properties/WebProperties.java
View file @
c61e54e4
...
@@ -44,4 +44,4 @@ public class WebProperties implements ConfigurableProperties {
...
@@ -44,4 +44,4 @@ public class WebProperties implements ConfigurableProperties {
return
"web-common"
;
return
"web-common"
;
}
}
}
}
\ No newline at end of file
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java
View file @
c61e54e4
...
@@ -2,13 +2,15 @@ package com.schbrain.framework.autoconfigure.apollo;
...
@@ -2,13 +2,15 @@ package com.schbrain.framework.autoconfigure.apollo;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.google.common.collect.Maps
;
import
com.schbrain.common.util.ConfigurationPropertiesUtils
;
import
com.schbrain.common.util.support.ConfigurableProperties
;
import
com.schbrain.common.util.support.ConfigurableProperties
;
import
com.schbrain.framework.autoconfigure.apollo.config.OrderedMapPropertySource
;
import
com.schbrain.framework.autoconfigure.apollo.config.OrderedMapPropertySource
;
import
com.schbrain.framework.autoconfigure.apollo.event.ConfigLoadedEvent
;
import
com.schbrain.framework.autoconfigure.apollo.event.ConfigLoadedEvent
;
import
com.schbrain.framework.autoconfigure.apollo.event.listener.ConfigLoadedEventListener
;
import
com.schbrain.framework.autoconfigure.apollo.event.listener.ConfigLoadedEventListener
;
import
com.schbrain.framework.autoconfigure.apollo.properties.ApolloProperties
;
import
com.schbrain.framework.autoconfigure.apollo.properties.ApolloProperties
;
import
com.schbrain.framework.autoconfigure.apollo.util.ConfigUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.springframework.boot.ConfigurableBootstrapContext
;
import
org.springframework.boot.ConfigurableBootstrapContext
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
...
@@ -18,10 +20,11 @@ import org.springframework.context.event.ApplicationEventMulticaster;
...
@@ -18,10 +20,11 @@ import org.springframework.context.event.ApplicationEventMulticaster;
import
org.springframework.context.event.SimpleApplicationEventMulticaster
;
import
org.springframework.context.event.SimpleApplicationEventMulticaster
;
import
org.springframework.core.ResolvableType
;
import
org.springframework.core.ResolvableType
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
java.util.
List
;
import
java.util.
*
;
import
java.util.
Set
;
import
java.util.
Map.Entry
;
import
static
org
.
springframework
.
core
.
io
.
support
.
SpringFactoriesLoader
.
loadFactories
;
import
static
org
.
springframework
.
core
.
io
.
support
.
SpringFactoriesLoader
.
loadFactories
;
...
@@ -47,7 +50,7 @@ class ConfigurablePropertiesLoader {
...
@@ -47,7 +50,7 @@ class ConfigurablePropertiesLoader {
void
load
(
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
void
load
(
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
List
<
ConfigurableProperties
>
propertiesList
=
loadFactories
(
ConfigurableProperties
.
class
,
getClass
().
getClassLoader
());
List
<
ConfigurableProperties
>
propertiesList
=
loadFactories
(
ConfigurableProperties
.
class
,
getClass
().
getClassLoader
());
if
(
CollectionUtils
.
isEmpty
(
propertiesList
))
{
if
(
CollectionUtils
.
isEmpty
(
propertiesList
))
{
log
.
warn
(
"There is no configura
tion
properties found"
);
log
.
warn
(
"There is no configura
ble
properties found"
);
return
;
return
;
}
}
...
@@ -55,33 +58,34 @@ class ConfigurablePropertiesLoader {
...
@@ -55,33 +58,34 @@ class ConfigurablePropertiesLoader {
boolean
remoteFirst
=
ApolloProperties
.
get
(
environment
).
isRemoteFirst
();
boolean
remoteFirst
=
ApolloProperties
.
get
(
environment
).
isRemoteFirst
();
for
(
ConfigurableProperties
properties
:
propertiesList
)
{
for
(
ConfigurableProperties
properties
:
propertiesList
)
{
OrderedMapPropertySource
propertySource
=
loadFromRemote
(
environment
,
remoteFirst
,
properties
.
getNamespace
());
OrderedMapPropertySource
propertySource
=
buildPropertySource
(
environment
,
remoteFirst
,
properties
);
if
(
propertySource
==
null
)
{
continue
;
}
// multicast event
ConfigLoadedEvent
event
=
createEvent
(
environment
,
application
,
propertySource
,
properties
);
ConfigLoadedEvent
event
=
createEvent
(
environment
,
application
,
propertySource
,
properties
);
eventMulticaster
.
multicastEvent
(
event
,
ResolvableType
.
forClass
(
event
.
getClass
()));
eventMulticaster
.
multicastEvent
(
event
,
ResolvableType
.
forClass
(
event
.
getClass
()));
}
}
}
}
private
OrderedMapPropertySource
loadFromRemote
(
ConfigurableEnvironment
environment
,
boolean
remoteFirst
,
String
namespace
)
{
private
OrderedMapPropertySource
buildPropertySource
(
ConfigurableEnvironment
environment
,
boolean
remoteFirst
,
ConfigurableProperties
properties
)
{
Config
config
=
ConfigService
.
getConfig
(
namespace
);
Map
<
String
,
Object
>
mergedProperties
=
loadAndMergeLocalDefaults
(
properties
);
OrderedMapPropertySource
propertySource
=
ConfigUtils
.
toPropertySource
(
namespace
,
config
);
OrderedMapPropertySource
propertySource
=
createPropertySource
(
environment
,
properties
.
getNamespace
(),
mergedProperties
);
if
(
propertySource
==
null
)
{
log
.
warn
(
"No configuration properties loaded under namespace: "
+
namespace
);
return
null
;
}
if
(
remoteFirst
)
{
if
(
remoteFirst
)
{
environment
.
getPropertySources
().
addFirst
(
propertySource
);
environment
.
getPropertySources
().
addFirst
(
propertySource
);
}
else
{
}
else
{
environment
.
getPropertySources
().
addLast
(
propertySource
);
environment
.
getPropertySources
().
addLast
(
propertySource
);
}
}
// resolve any placeHolders
ConfigUtils
.
resolvePlaceHolders
(
environment
,
propertySource
);
return
propertySource
;
return
propertySource
;
}
}
private
Map
<
String
,
Object
>
loadAndMergeLocalDefaults
(
ConfigurableProperties
properties
)
{
String
namespace
=
properties
.
getNamespace
();
Config
config
=
ConfigService
.
getConfig
(
namespace
);
Map
<
String
,
Object
>
loadedProperties
=
toPropertiesMap
(
config
);
if
(
MapUtils
.
isEmpty
(
loadedProperties
))
{
log
.
warn
(
"No configuration properties loaded under namespace: "
+
namespace
);
}
Map
<
String
,
Object
>
defaultProperties
=
ConfigurationPropertiesUtils
.
toMap
(
properties
);
return
mergeProperties
(
loadedProperties
,
defaultProperties
);
}
private
ConfigLoadedEvent
createEvent
(
ConfigurableEnvironment
environment
,
SpringApplication
application
,
private
ConfigLoadedEvent
createEvent
(
ConfigurableEnvironment
environment
,
SpringApplication
application
,
OrderedMapPropertySource
propertySource
,
ConfigurableProperties
properties
)
{
OrderedMapPropertySource
propertySource
,
ConfigurableProperties
properties
)
{
ConfigurableProperties
boundProperties
=
properties
.
bind
(
environment
);
ConfigurableProperties
boundProperties
=
properties
.
bind
(
environment
);
...
@@ -98,4 +102,35 @@ class ConfigurablePropertiesLoader {
...
@@ -98,4 +102,35 @@ class ConfigurablePropertiesLoader {
return
eventMulticaster
;
return
eventMulticaster
;
}
}
}
private
Map
<
String
,
Object
>
toPropertiesMap
(
Config
config
)
{
\ No newline at end of file
Set
<
String
>
propertyNames
=
config
.
getPropertyNames
();
if
(
propertyNames
.
isEmpty
())
{
return
Collections
.
emptyMap
();
}
Map
<
String
,
Object
>
configs
=
Maps
.
newLinkedHashMapWithExpectedSize
(
propertyNames
.
size
());
for
(
String
propertyName
:
propertyNames
)
{
String
property
=
config
.
getProperty
(
propertyName
,
null
);
configs
.
put
(
propertyName
,
property
);
}
return
configs
;
}
private
Map
<
String
,
Object
>
mergeProperties
(
Map
<
String
,
Object
>
loadedProperties
,
Map
<
String
,
Object
>
defaultProperties
)
{
Map
<
String
,
Object
>
mergedProperties
=
new
LinkedHashMap
<>();
mergedProperties
.
putAll
(
defaultProperties
);
mergedProperties
.
putAll
(
loadedProperties
);
return
mergedProperties
;
}
private
OrderedMapPropertySource
createPropertySource
(
Environment
environment
,
String
namespace
,
Map
<
String
,
Object
>
source
)
{
for
(
Entry
<
String
,
Object
>
entry
:
source
.
entrySet
())
{
Object
value
=
entry
.
getValue
();
if
(
value
instanceof
String
)
{
String
resolvedValue
=
environment
.
resolvePlaceholders
((
String
)
value
);
source
.
put
(
entry
.
getKey
(),
resolvedValue
);
}
}
return
new
OrderedMapPropertySource
(
namespace
,
source
);
}
}
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/config/OrderedMapPropertySource.java
View file @
c61e54e4
...
@@ -13,16 +13,16 @@ import java.util.Map;
...
@@ -13,16 +13,16 @@ import java.util.Map;
*/
*/
public
class
OrderedMapPropertySource
extends
MapPropertySource
{
public
class
OrderedMapPropertySource
extends
MapPropertySource
{
public
OrderedMapPropertySource
(
String
name
,
Map
<
String
,
String
>
source
)
{
public
OrderedMapPropertySource
(
String
name
,
Map
<
String
,
Object
>
source
)
{
super
(
name
,
new
LinkedHashMap
<>(
source
));
super
(
name
,
new
LinkedHashMap
<>(
source
));
}
}
public
void
addProperties
(
Map
<
String
,
String
>
properties
)
{
public
void
addProperties
(
Map
<
String
,
Object
>
properties
)
{
getSource
().
putAll
(
properties
);
getSource
().
putAll
(
properties
);
}
}
public
void
addProperty
(
String
propertyName
,
String
propertyValue
)
{
public
void
addProperty
(
String
propertyName
,
Object
propertyValue
)
{
getSource
().
put
(
propertyName
,
propertyValue
);
getSource
().
put
(
propertyName
,
propertyValue
);
}
}
}
}
\ No newline at end of file
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/util/ConfigUtils.java
deleted
100644 → 0
View file @
f2781612
package
com.schbrain.framework.autoconfigure.apollo.util
;
import
com.ctrip.framework.apollo.Config
;
import
com.google.common.collect.Maps
;
import
com.schbrain.framework.autoconfigure.apollo.config.OrderedMapPropertySource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
javax.annotation.Nullable
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
/**
* @author liaozan
* @since 2021/12/6
*/
@Slf4j
public
class
ConfigUtils
{
@Nullable
public
static
OrderedMapPropertySource
toPropertySource
(
String
name
,
Config
config
)
{
Set
<
String
>
propertyNames
=
config
.
getPropertyNames
();
if
(
propertyNames
.
isEmpty
())
{
return
null
;
}
Map
<
String
,
String
>
configs
=
Maps
.
newLinkedHashMapWithExpectedSize
(
propertyNames
.
size
());
for
(
String
propertyName
:
propertyNames
)
{
String
property
=
config
.
getProperty
(
propertyName
,
null
);
configs
.
put
(
propertyName
,
property
);
}
return
new
OrderedMapPropertySource
(
name
,
configs
);
}
public
static
void
resolvePlaceHolders
(
ConfigurableEnvironment
environment
,
OrderedMapPropertySource
propertySource
)
{
Map
<
String
,
Object
>
source
=
propertySource
.
getSource
();
for
(
Entry
<
String
,
Object
>
entry
:
source
.
entrySet
())
{
Object
value
=
entry
.
getValue
();
if
(
value
instanceof
String
)
{
String
resolvedValue
=
environment
.
resolvePlaceholders
((
String
)
value
);
source
.
put
(
entry
.
getKey
(),
resolvedValue
);
}
}
}
}
\ No newline at end of file
starters/cache-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/cache/properties/CacheProperties.java
View file @
c61e54e4
...
@@ -32,4 +32,4 @@ public class CacheProperties implements ConfigurableProperties {
...
@@ -32,4 +32,4 @@ public class CacheProperties implements ConfigurableProperties {
return
"cache-common"
;
return
"cache-common"
;
}
}
}
}
\ No newline at end of file
starters/cache-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/cache/provider/redis/RedisProperties.java
View file @
c61e54e4
...
@@ -17,4 +17,4 @@ public class RedisProperties implements ConfigurableProperties {
...
@@ -17,4 +17,4 @@ public class RedisProperties implements ConfigurableProperties {
return
"redis-common"
;
return
"redis-common"
;
}
}
}
}
\ No newline at end of file
starters/elasticsearch-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/elasticsearch/properties/ElasticsearchProperties.java
View file @
c61e54e4
...
@@ -17,4 +17,4 @@ public class ElasticsearchProperties implements ConfigurableProperties {
...
@@ -17,4 +17,4 @@ public class ElasticsearchProperties implements ConfigurableProperties {
return
"elasticsearch-common"
;
return
"elasticsearch-common"
;
}
}
}
}
\ No newline at end of file
starters/logger-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/logger/listener/LoggerConfigLoadedEventListener.java
View file @
c61e54e4
...
@@ -43,7 +43,7 @@ public class LoggerConfigLoadedEventListener extends GenericConfigLoadedEventLis
...
@@ -43,7 +43,7 @@ public class LoggerConfigLoadedEventListener extends GenericConfigLoadedEventLis
@Override
@Override
protected
void
onConfigLoaded
(
ConfigLoadedEvent
event
,
LoggerProperties
properties
)
{
protected
void
onConfigLoaded
(
ConfigLoadedEvent
event
,
LoggerProperties
properties
)
{
HostInfo
hostInfo
=
InetUtils
.
findFirstNonLoopBackHostInfo
();
HostInfo
hostInfo
=
InetUtils
.
findFirstNonLoopBackHostInfo
();
Map
<
String
,
String
>
hostInfoProperties
=
buildHostInfoProperties
(
hostInfo
);
Map
<
String
,
Object
>
hostInfoProperties
=
buildHostInfoProperties
(
hostInfo
);
event
.
getPropertySource
().
addProperties
(
hostInfoProperties
);
event
.
getPropertySource
().
addProperties
(
hostInfoProperties
);
configLoggingFileLocation
(
event
.
getEnvironment
(),
properties
.
getLogConfigNamespace
());
configLoggingFileLocation
(
event
.
getEnvironment
(),
properties
.
getLogConfigNamespace
());
this
.
loggerInitializer
=
new
LoggerConfigurationInitializer
(
event
.
getEnvironment
(),
properties
,
hostInfo
);
this
.
loggerInitializer
=
new
LoggerConfigurationInitializer
(
event
.
getEnvironment
(),
properties
,
hostInfo
);
...
@@ -52,8 +52,8 @@ public class LoggerConfigLoadedEventListener extends GenericConfigLoadedEventLis
...
@@ -52,8 +52,8 @@ public class LoggerConfigLoadedEventListener extends GenericConfigLoadedEventLis
/**
/**
* hostInfo properties, for logging pattern
* hostInfo properties, for logging pattern
*/
*/
private
Map
<
String
,
String
>
buildHostInfoProperties
(
HostInfo
hostInfo
)
{
private
Map
<
String
,
Object
>
buildHostInfoProperties
(
HostInfo
hostInfo
)
{
Map
<
String
,
String
>
properties
=
Maps
.
newHashMapWithExpectedSize
(
2
);
Map
<
String
,
Object
>
properties
=
Maps
.
newHashMapWithExpectedSize
(
2
);
properties
.
put
(
"application.hostname"
,
hostInfo
.
getHostname
());
properties
.
put
(
"application.hostname"
,
hostInfo
.
getHostname
());
properties
.
put
(
"application.ipAddress"
,
hostInfo
.
getIpAddress
());
properties
.
put
(
"application.ipAddress"
,
hostInfo
.
getIpAddress
());
return
properties
;
return
properties
;
...
...
starters/logger-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/logger/properties/LoggerProperties.java
View file @
c61e54e4
...
@@ -41,4 +41,4 @@ public class LoggerProperties implements ConfigurableProperties, PriorityOrdered
...
@@ -41,4 +41,4 @@ public class LoggerProperties implements ConfigurableProperties, PriorityOrdered
return
HIGHEST_PRECEDENCE
;
return
HIGHEST_PRECEDENCE
;
}
}
}
}
\ No newline at end of file
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/properties/DataSourceProperties.java
View file @
c61e54e4
...
@@ -17,4 +17,4 @@ public class DataSourceProperties implements ConfigurableProperties {
...
@@ -17,4 +17,4 @@ public class DataSourceProperties implements ConfigurableProperties {
return
"jdbc-common"
;
return
"jdbc-common"
;
}
}
}
}
\ No newline at end of file
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/properties/MybatisProperties.java
View file @
c61e54e4
...
@@ -37,4 +37,4 @@ public class MybatisProperties implements ConfigurableProperties {
...
@@ -37,4 +37,4 @@ public class MybatisProperties implements ConfigurableProperties {
return
"mybatis-common"
;
return
"mybatis-common"
;
}
}
}
}
\ No newline at end of file
starters/oss-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/oss/properties/OssProperties.java
View file @
c61e54e4
...
@@ -50,4 +50,4 @@ public class OssProperties implements ConfigurableProperties {
...
@@ -50,4 +50,4 @@ public class OssProperties implements ConfigurableProperties {
}
}
}
}
\ No newline at end of file
starters/xxl-job-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/xxl/properties/XxlJobProperties.java
View file @
c61e54e4
...
@@ -30,4 +30,4 @@ public class XxlJobProperties implements ConfigurableProperties {
...
@@ -30,4 +30,4 @@ public class XxlJobProperties implements ConfigurableProperties {
return
"xxl-job-common"
;
return
"xxl-job-common"
;
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment