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
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
panwangnan
schbrain-parent
Commits
76a1295e
Commit
76a1295e
authored
May 02, 2023
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure the PropertiesPreparedEventListener can print log correctly
parent
a1c2069a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
8 deletions
+20
-8
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java
...rk/autoconfigure/apollo/ConfigurablePropertiesLoader.java
+6
-3
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/listener/PropertiesPreparedEvent.java
...utoconfigure/apollo/listener/PropertiesPreparedEvent.java
+9
-2
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/listener/PropertiesPreparedEventListenerAdapter.java
...ollo/listener/PropertiesPreparedEventListenerAdapter.java
+5
-1
starters/logger-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/logger/listener/LoggerPropertiesPreparedEventListener.java
...ogger/listener/LoggerPropertiesPreparedEventListener.java
+0
-2
No files found.
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java
View file @
76a1295e
...
...
@@ -35,10 +35,13 @@ class ConfigurablePropertiesLoader {
*/
private
static
final
String
PROPERTIES_PROPERTY_SOURCE
=
"ConfigurablePropertiesPropertySource"
;
private
final
DeferredLogFactory
deferredLogFactory
;
private
final
Log
log
;
ConfigurablePropertiesLoader
(
DeferredLogFactory
logFactory
)
{
this
.
log
=
logFactory
.
getLog
(
ConfigurablePropertiesLoader
.
class
);
ConfigurablePropertiesLoader
(
DeferredLogFactory
deferredLogFactory
)
{
this
.
deferredLogFactory
=
deferredLogFactory
;
this
.
log
=
deferredLogFactory
.
getLog
(
ConfigurablePropertiesLoader
.
class
);
}
void
load
(
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
...
...
@@ -74,7 +77,7 @@ class ConfigurablePropertiesLoader {
compositePropertySource
.
addPropertySource
(
propertySource
);
ConfigurableProperties
boundProperties
=
properties
.
bind
(
environment
);
eventMulticaster
.
multicastEvent
(
new
PropertiesPreparedEvent
(
boundProperties
,
propertySource
,
environment
,
application
));
eventMulticaster
.
multicastEvent
(
new
PropertiesPreparedEvent
(
environment
,
deferredLogFactory
,
propertySource
,
boundProperties
,
application
));
});
}
...
...
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/listener/PropertiesPreparedEvent.java
View file @
76a1295e
...
...
@@ -4,6 +4,7 @@ import com.schbrain.common.util.properties.SchbrainMapPropertySource;
import
com.schbrain.common.util.support.ConfigurableProperties
;
import
lombok.Getter
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.logging.DeferredLogFactory
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.core.env.ConfigurableEnvironment
;
...
...
@@ -18,15 +19,21 @@ public class PropertiesPreparedEvent extends ApplicationEvent {
private
final
ConfigurableEnvironment
environment
;
private
final
DeferredLogFactory
deferredLogFactory
;
private
final
SchbrainMapPropertySource
propertySource
;
private
final
SpringApplication
application
;
public
PropertiesPreparedEvent
(
ConfigurableProperties
properties
,
SchbrainMapPropertySource
propertySource
,
ConfigurableEnvironment
environment
,
SpringApplication
application
)
{
public
PropertiesPreparedEvent
(
ConfigurableEnvironment
environment
,
DeferredLogFactory
deferredLogFactory
,
SchbrainMapPropertySource
propertySource
,
ConfigurableProperties
properties
,
SpringApplication
application
)
{
super
(
properties
);
this
.
environment
=
environment
;
this
.
propertySource
=
propertySource
;
this
.
deferredLogFactory
=
deferredLogFactory
;
this
.
application
=
application
;
}
...
...
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/listener/PropertiesPreparedEventListenerAdapter.java
View file @
76a1295e
package
com.schbrain.framework.autoconfigure.apollo.listener
;
import
com.schbrain.common.util.support.ConfigurableProperties
;
import
org.apache.commons.logging.Log
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
...
...
@@ -14,6 +15,8 @@ public class PropertiesPreparedEventListenerAdapter<T extends ConfigurableProper
private
final
Class
<
T
>
propertyType
;
protected
Log
log
;
public
PropertiesPreparedEventListenerAdapter
()
{
ParameterizedType
parameterizedType
=
(
ParameterizedType
)
getClass
().
getGenericSuperclass
();
Type
[]
actualTypeArguments
=
parameterizedType
.
getActualTypeArguments
();
...
...
@@ -23,7 +26,8 @@ public class PropertiesPreparedEventListenerAdapter<T extends ConfigurableProper
@Override
public
void
onApplicationEvent
(
PropertiesPreparedEvent
event
)
{
if
(
event
.
getConfigurableProperties
().
getClass
()
==
propertyType
)
{
onPropertiesPrepared
(
event
,
(
T
)
event
.
getConfigurableProperties
());
this
.
log
=
event
.
getDeferredLogFactory
().
getLog
(
this
.
getClass
());
this
.
onPropertiesPrepared
(
event
,
(
T
)
event
.
getConfigurableProperties
());
}
}
...
...
starters/logger-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/logger/listener/LoggerPropertiesPreparedEventListener.java
View file @
76a1295e
...
...
@@ -11,7 +11,6 @@ import com.schbrain.framework.autoconfigure.apollo.listener.PropertiesPreparedEv
import
com.schbrain.framework.autoconfigure.apollo.listener.PropertiesPreparedEventListenerAdapter
;
import
com.schbrain.framework.autoconfigure.logger.LoggerConfigurationInitializer
;
import
com.schbrain.framework.autoconfigure.logger.properties.LoggerProperties
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.util.StringUtils
;
...
...
@@ -25,7 +24,6 @@ import static org.springframework.boot.context.logging.LoggingApplicationListene
* @author liaozan
* @since 2023-04-28
*/
@Slf4j
public
class
LoggerPropertiesPreparedEventListener
extends
PropertiesPreparedEventListenerAdapter
<
LoggerProperties
>
{
@Override
...
...
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