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
0cb9e443
Commit
0cb9e443
authored
Jul 02, 2023
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more member to ConfigLoadedEvent
parent
14e8d0e8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
24 deletions
+54
-24
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ApolloConfigurationInitializerEnvironmentPostProcessor.java
...olloConfigurationInitializerEnvironmentPostProcessor.java
+1
-1
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java
...rk/autoconfigure/apollo/ConfigurablePropertiesLoader.java
+5
-3
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/event/ConfigLoadedEvent.java
...amework/autoconfigure/apollo/event/ConfigLoadedEvent.java
+5
-4
starters/dubbo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/dubbo/listener/DubboConfigInitEventListener.java
...onfigure/dubbo/listener/DubboConfigInitEventListener.java
+5
-2
starters/dubbo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/dubbo/listener/DubboConfigLoadedEventListener.java
...figure/dubbo/listener/DubboConfigLoadedEventListener.java
+2
-9
support/schbrain-spring-support/src/main/java/com/schbrain/framework/support/spring/BootstrapContextClosedEventListener.java
...k/support/spring/BootstrapContextClosedEventListener.java
+27
-0
support/schbrain-spring-support/src/main/java/com/schbrain/framework/support/spring/LoggerAwareEnvironmentPostProcessor.java
...k/support/spring/LoggerAwareEnvironmentPostProcessor.java
+9
-5
No files found.
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ApolloConfigurationInitializerEnvironmentPostProcessor.java
View file @
0cb9e443
...
@@ -38,7 +38,7 @@ public class ApolloConfigurationInitializerEnvironmentPostProcessor extends Logg
...
@@ -38,7 +38,7 @@ public class ApolloConfigurationInitializerEnvironmentPostProcessor extends Logg
public
ApolloConfigurationInitializerEnvironmentPostProcessor
(
DeferredLogFactory
deferredLogFactory
,
ConfigurableBootstrapContext
bootstrapContext
)
{
public
ApolloConfigurationInitializerEnvironmentPostProcessor
(
DeferredLogFactory
deferredLogFactory
,
ConfigurableBootstrapContext
bootstrapContext
)
{
super
(
deferredLogFactory
,
bootstrapContext
);
super
(
deferredLogFactory
,
bootstrapContext
);
this
.
configurablePropertiesLoader
=
new
ConfigurablePropertiesLoader
(
deferredLogFactory
);
this
.
configurablePropertiesLoader
=
new
ConfigurablePropertiesLoader
(
deferredLogFactory
,
bootstrapContext
);
}
}
@Override
@Override
...
...
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java
View file @
0cb9e443
...
@@ -10,6 +10,7 @@ import com.schbrain.framework.autoconfigure.apollo.properties.ApolloProperties;
...
@@ -10,6 +10,7 @@ import com.schbrain.framework.autoconfigure.apollo.properties.ApolloProperties;
import
com.schbrain.framework.autoconfigure.apollo.util.ConfigUtils
;
import
com.schbrain.framework.autoconfigure.apollo.util.ConfigUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.springframework.boot.ConfigurableBootstrapContext
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.logging.DeferredLogFactory
;
import
org.springframework.boot.logging.DeferredLogFactory
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
...
@@ -31,12 +32,13 @@ import static org.springframework.core.io.support.SpringFactoriesLoader.loadFact
...
@@ -31,12 +32,13 @@ import static org.springframework.core.io.support.SpringFactoriesLoader.loadFact
class
ConfigurablePropertiesLoader
{
class
ConfigurablePropertiesLoader
{
private
final
Log
log
;
private
final
Log
log
;
private
final
DeferredLogFactory
deferredLogFactory
;
private
final
DeferredLogFactory
deferredLogFactory
;
private
final
ConfigurableBootstrapContext
bootstrapContext
;
ConfigurablePropertiesLoader
(
DeferredLogFactory
deferredLogFactory
)
{
ConfigurablePropertiesLoader
(
DeferredLogFactory
deferredLogFactory
,
ConfigurableBootstrapContext
bootstrapContext
)
{
this
.
deferredLogFactory
=
deferredLogFactory
;
this
.
deferredLogFactory
=
deferredLogFactory
;
this
.
log
=
deferredLogFactory
.
getLog
(
ConfigurablePropertiesLoader
.
class
);
this
.
log
=
deferredLogFactory
.
getLog
(
ConfigurablePropertiesLoader
.
class
);
this
.
bootstrapContext
=
bootstrapContext
;
}
}
/**
/**
...
@@ -83,7 +85,7 @@ class ConfigurablePropertiesLoader {
...
@@ -83,7 +85,7 @@ class ConfigurablePropertiesLoader {
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
);
return
new
ConfigLoadedEvent
(
environment
,
deferredLogFactory
,
propertySource
,
boundProperties
,
application
);
return
new
ConfigLoadedEvent
(
environment
,
deferredLogFactory
,
propertySource
,
boundProperties
,
application
,
bootstrapContext
);
}
}
private
ApplicationEventMulticaster
createEventMulticaster
(
Set
<
ApplicationListener
<?>>
listeners
)
{
private
ApplicationEventMulticaster
createEventMulticaster
(
Set
<
ApplicationListener
<?>>
listeners
)
{
...
...
starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/event/ConfigLoadedEvent.java
View file @
0cb9e443
...
@@ -3,6 +3,7 @@ package com.schbrain.framework.autoconfigure.apollo.event;
...
@@ -3,6 +3,7 @@ package com.schbrain.framework.autoconfigure.apollo.event;
import
com.schbrain.common.util.properties.OrderedMapPropertySource
;
import
com.schbrain.common.util.properties.OrderedMapPropertySource
;
import
com.schbrain.common.util.support.ConfigurableProperties
;
import
com.schbrain.common.util.support.ConfigurableProperties
;
import
lombok.Getter
;
import
lombok.Getter
;
import
org.springframework.boot.ConfigurableBootstrapContext
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.logging.DeferredLogFactory
;
import
org.springframework.boot.logging.DeferredLogFactory
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.ApplicationEvent
;
...
@@ -18,23 +19,23 @@ public class ConfigLoadedEvent extends ApplicationEvent {
...
@@ -18,23 +19,23 @@ public class ConfigLoadedEvent extends ApplicationEvent {
private
static
final
long
serialVersionUID
=
2567291189881702459L
;
private
static
final
long
serialVersionUID
=
2567291189881702459L
;
private
final
ConfigurableEnvironment
environment
;
private
final
ConfigurableEnvironment
environment
;
private
final
DeferredLogFactory
deferredLogFactory
;
private
final
DeferredLogFactory
deferredLogFactory
;
private
final
OrderedMapPropertySource
propertySource
;
private
final
OrderedMapPropertySource
propertySource
;
private
final
SpringApplication
springApplication
;
private
final
SpringApplication
springApplication
;
private
final
ConfigurableBootstrapContext
bootstrapContext
;
public
ConfigLoadedEvent
(
ConfigurableEnvironment
environment
,
public
ConfigLoadedEvent
(
ConfigurableEnvironment
environment
,
DeferredLogFactory
deferredLogFactory
,
DeferredLogFactory
deferredLogFactory
,
OrderedMapPropertySource
propertySource
,
OrderedMapPropertySource
propertySource
,
ConfigurableProperties
properties
,
ConfigurableProperties
properties
,
SpringApplication
springApplication
)
{
SpringApplication
springApplication
,
ConfigurableBootstrapContext
bootstrapContext
)
{
super
(
properties
);
super
(
properties
);
this
.
environment
=
environment
;
this
.
environment
=
environment
;
this
.
propertySource
=
propertySource
;
this
.
propertySource
=
propertySource
;
this
.
deferredLogFactory
=
deferredLogFactory
;
this
.
deferredLogFactory
=
deferredLogFactory
;
this
.
springApplication
=
springApplication
;
this
.
springApplication
=
springApplication
;
this
.
bootstrapContext
=
bootstrapContext
;
}
}
public
ConfigurableProperties
getConfigurableProperties
()
{
public
ConfigurableProperties
getConfigurableProperties
()
{
...
...
starters/dubbo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/dubbo/listener/DubboConfigInitEventListener.java
View file @
0cb9e443
...
@@ -2,9 +2,11 @@ package com.schbrain.framework.autoconfigure.dubbo.listener;
...
@@ -2,9 +2,11 @@ package com.schbrain.framework.autoconfigure.dubbo.listener;
import
org.apache.dubbo.config.ConfigCenterConfig
;
import
org.apache.dubbo.config.ConfigCenterConfig
;
import
org.apache.dubbo.config.context.ConfigManager
;
import
org.apache.dubbo.config.context.ConfigManager
;
import
org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor
;
import
org.apache.dubbo.config.spring.context.event.DubboConfigInitEvent
;
import
org.apache.dubbo.config.spring.context.event.DubboConfigInitEvent
;
import
org.apache.dubbo.config.spring.util.DubboBeanUtils
;
import
org.apache.dubbo.config.spring.util.DubboBeanUtils
;
import
org.apache.dubbo.rpc.model.ApplicationModel
;
import
org.apache.dubbo.rpc.model.ApplicationModel
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.PriorityOrdered
;
import
org.springframework.core.PriorityOrdered
;
...
@@ -15,6 +17,7 @@ import static org.apache.dubbo.config.spring.util.EnvironmentUtils.filterDubboPr
...
@@ -15,6 +17,7 @@ import static org.apache.dubbo.config.spring.util.EnvironmentUtils.filterDubboPr
/**
/**
* @author liaozan
* @author liaozan
* @see ReferenceAnnotationBeanPostProcessor#postProcessBeanFactory(ConfigurableListableBeanFactory)
* @since 2023-05-08
* @since 2023-05-08
*/
*/
class
DubboConfigInitEventListener
implements
ApplicationListener
<
DubboConfigInitEvent
>,
PriorityOrdered
{
class
DubboConfigInitEventListener
implements
ApplicationListener
<
DubboConfigInitEvent
>,
PriorityOrdered
{
...
@@ -42,8 +45,8 @@ class DubboConfigInitEventListener implements ApplicationListener<DubboConfigIni
...
@@ -42,8 +45,8 @@ class DubboConfigInitEventListener implements ApplicationListener<DubboConfigIni
private
ConfigCenterConfig
buildConfigCenterConfig
()
{
private
ConfigCenterConfig
buildConfigCenterConfig
()
{
Map
<
String
,
String
>
externalConfiguration
=
filterDubboProperties
(
applicationContext
.
getEnvironment
());
Map
<
String
,
String
>
externalConfiguration
=
filterDubboProperties
(
applicationContext
.
getEnvironment
());
ConfigCenterConfig
configCenterConfig
=
new
ConfigCenterConfig
();
ConfigCenterConfig
configCenterConfig
=
new
ConfigCenterConfig
();
configCenterConfig
.
setExternalConfig
(
externalConfiguration
);
configCenterConfig
.
set
App
ExternalConfig
(
externalConfiguration
);
return
configCenterConfig
;
return
configCenterConfig
;
}
}
}
}
\ No newline at end of file
starters/dubbo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/dubbo/listener/DubboConfigLoadedEventListener.java
View file @
0cb9e443
package
com.schbrain.framework.autoconfigure.dubbo.listener
;
package
com.schbrain.framework.autoconfigure.dubbo.listener
;
import
com.schbrain.common.util.ApplicationName
;
import
com.schbrain.common.util.properties.OrderedMapPropertySource
;
import
com.schbrain.common.util.properties.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.GenericConfigLoadedEventListener
;
import
com.schbrain.framework.autoconfigure.apollo.event.listener.GenericConfigLoadedEventListener
;
...
@@ -8,7 +7,6 @@ import com.schbrain.framework.autoconfigure.dubbo.properties.DubboProperties;
...
@@ -8,7 +7,6 @@ import com.schbrain.framework.autoconfigure.dubbo.properties.DubboProperties;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
static
org
.
apache
.
dubbo
.
config
.
ConfigKeys
.
DUBBO_SCAN_BASE_PACKAGES
;
import
static
org
.
apache
.
dubbo
.
config
.
ConfigKeys
.
DUBBO_SCAN_BASE_PACKAGES
;
...
@@ -18,8 +16,6 @@ import static org.apache.dubbo.config.ConfigKeys.DUBBO_SCAN_BASE_PACKAGES;
...
@@ -18,8 +16,6 @@ import static org.apache.dubbo.config.ConfigKeys.DUBBO_SCAN_BASE_PACKAGES;
*/
*/
public
class
DubboConfigLoadedEventListener
extends
GenericConfigLoadedEventListener
<
DubboProperties
>
{
public
class
DubboConfigLoadedEventListener
extends
GenericConfigLoadedEventListener
<
DubboProperties
>
{
public
static
final
String
DUBBO_APPLICATION_NAME
=
"dubbo.application.name"
;
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
Ordered
.
HIGHEST_PRECEDENCE
;
return
Ordered
.
HIGHEST_PRECEDENCE
;
...
@@ -32,16 +28,13 @@ public class DubboConfigLoadedEventListener extends GenericConfigLoadedEventList
...
@@ -32,16 +28,13 @@ public class DubboConfigLoadedEventListener extends GenericConfigLoadedEventList
@Override
@Override
protected
void
onConfigLoaded
(
ConfigLoadedEvent
event
,
DubboProperties
properties
)
{
protected
void
onConfigLoaded
(
ConfigLoadedEvent
event
,
DubboProperties
properties
)
{
addRequiredProperties
(
event
.
get
Environment
(),
event
.
get
SpringApplication
(),
event
.
getPropertySource
());
addRequiredProperties
(
event
.
getSpringApplication
(),
event
.
getPropertySource
());
}
}
private
void
addRequiredProperties
(
ConfigurableEnvironment
environment
,
SpringApplication
application
,
OrderedMapPropertySource
propertySource
)
{
private
void
addRequiredProperties
(
SpringApplication
application
,
OrderedMapPropertySource
propertySource
)
{
if
(!
propertySource
.
containsProperty
(
DUBBO_SCAN_BASE_PACKAGES
))
{
if
(!
propertySource
.
containsProperty
(
DUBBO_SCAN_BASE_PACKAGES
))
{
propertySource
.
addProperty
(
DUBBO_SCAN_BASE_PACKAGES
,
getBasePackage
(
application
));
propertySource
.
addProperty
(
DUBBO_SCAN_BASE_PACKAGES
,
getBasePackage
(
application
));
}
}
if
(!
propertySource
.
containsProperty
(
DUBBO_APPLICATION_NAME
))
{
propertySource
.
addProperty
(
DUBBO_APPLICATION_NAME
,
ApplicationName
.
get
(
environment
));
}
}
}
private
String
getBasePackage
(
SpringApplication
application
)
{
private
String
getBasePackage
(
SpringApplication
application
)
{
...
...
support/schbrain-spring-support/src/main/java/com/schbrain/framework/support/spring/BootstrapContextClosedEventListener.java
0 → 100644
View file @
0cb9e443
package
com.schbrain.framework.support.spring
;
import
org.springframework.boot.BootstrapContextClosedEvent
;
import
org.springframework.boot.ConfigurableBootstrapContext
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ConfigurableApplicationContext
;
/**
* @author liaozan
* @since 2023-07-02
*/
class
BootstrapContextClosedEventListener
implements
ApplicationListener
<
BootstrapContextClosedEvent
>
{
private
final
LoggerAwareEnvironmentPostProcessor
delegate
;
BootstrapContextClosedEventListener
(
LoggerAwareEnvironmentPostProcessor
delegate
)
{
this
.
delegate
=
delegate
;
}
@Override
public
void
onApplicationEvent
(
BootstrapContextClosedEvent
event
)
{
ConfigurableBootstrapContext
bootstrapContext
=
(
ConfigurableBootstrapContext
)
event
.
getBootstrapContext
();
ConfigurableApplicationContext
applicationContext
=
event
.
getApplicationContext
();
delegate
.
onBootstrapContextClose
(
bootstrapContext
,
applicationContext
);
}
}
\ No newline at end of file
support/schbrain-spring-support/src/main/java/com/schbrain/framework/support/spring/LoggerAwareEnvironmentPostProcessor.java
View file @
0cb9e443
...
@@ -2,10 +2,11 @@ package com.schbrain.framework.support.spring;
...
@@ -2,10 +2,11 @@ package com.schbrain.framework.support.spring;
import
lombok.Getter
;
import
lombok.Getter
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.springframework.boot.BootstrapContextClosedEvent
;
import
org.springframework.boot.ConfigurableBootstrapContext
;
import
org.springframework.boot.ConfigurableBootstrapContext
;
import
org.springframework.boot.DefaultBootstrapContext
;
import
org.springframework.boot.env.EnvironmentPostProcessor
;
import
org.springframework.boot.env.EnvironmentPostProcessor
;
import
org.springframework.boot.logging.DeferredLogFactory
;
import
org.springframework.boot.logging.DeferredLogFactory
;
import
org.springframework.context.ConfigurableApplicationContext
;
/**
/**
* @author liaozan
* @author liaozan
...
@@ -15,19 +16,22 @@ import org.springframework.boot.logging.DeferredLogFactory;
...
@@ -15,19 +16,22 @@ import org.springframework.boot.logging.DeferredLogFactory;
public
abstract
class
LoggerAwareEnvironmentPostProcessor
implements
EnvironmentPostProcessor
{
public
abstract
class
LoggerAwareEnvironmentPostProcessor
implements
EnvironmentPostProcessor
{
protected
final
Log
log
;
protected
final
Log
log
;
protected
final
DeferredLogFactory
deferredLogFactory
;
protected
final
DeferredLogFactory
deferredLogFactory
;
protected
final
ConfigurableBootstrapContext
bootstrapContext
;
protected
final
ConfigurableBootstrapContext
bootstrapContext
;
public
LoggerAwareEnvironmentPostProcessor
(
DeferredLogFactory
logFactory
,
ConfigurableBootstrapContext
bootstrapContext
)
{
public
LoggerAwareEnvironmentPostProcessor
(
DeferredLogFactory
logFactory
,
ConfigurableBootstrapContext
bootstrapContext
)
{
this
.
log
=
logFactory
.
getLog
(
getClass
());
this
.
log
=
logFactory
.
getLog
(
getClass
());
this
.
bootstrapContext
=
bootstrapContext
;
this
.
bootstrapContext
=
bootstrapContext
;
this
.
deferredLogFactory
=
logFactory
;
this
.
deferredLogFactory
=
logFactory
;
this
.
bootstrapContext
.
addCloseListener
(
this
::
onBootstrapContextClose
);
this
.
bootstrapContext
.
addCloseListener
(
new
BootstrapContextClosedEventListener
(
this
)
);
}
}
protected
void
onBootstrapContextClose
(
BootstrapContextClosedEvent
event
)
{
/**
* This event is triggered after ApplicationContextInitializedEvent
*
* @see DefaultBootstrapContext#close(ConfigurableApplicationContext)
*/
protected
void
onBootstrapContextClose
(
ConfigurableBootstrapContext
bootstrapContext
,
ConfigurableApplicationContext
applicationContext
)
{
}
}
...
...
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