Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
4d87bf1a
Commit
4d87bf1a
authored
Jul 31, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复引入Spring Cloud Config后无法加载Bean的Bug
parent
1b4a111c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
28 deletions
+104
-28
discovery-plugin-framework-consul/src/main/java/com/nepxion/discovery/plugin/framework/decorator/ConsulServiceRegistryDecorator.java
+29
-8
discovery-plugin-framework-eureka/src/main/java/com/nepxion/discovery/plugin/framework/decorator/EurekaServiceRegistryDecorator.java
+29
-8
discovery-plugin-framework-zookeeper/src/main/java/com/nepxion/discovery/plugin/framework/decorator/ZookeeperServiceRegistryDecorator.java
+29
-8
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/decorator/DiscoveryClientDecorator.java
+17
-4
No files found.
discovery-plugin-framework-consul/src/main/java/com/nepxion/discovery/plugin/framework/decorator/ConsulServiceRegistryDecorator.java
View file @
4d87bf1a
...
@@ -9,6 +9,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
...
@@ -9,6 +9,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
* @version 1.0
* @version 1.0
*/
*/
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeansException
;
import
org.springframework.cloud.consul.serviceregistry.ConsulRegistration
;
import
org.springframework.cloud.consul.serviceregistry.ConsulRegistration
;
import
org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistry
;
import
org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistry
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
@@ -18,6 +21,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
...
@@ -18,6 +21,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import
com.nepxion.discovery.plugin.framework.listener.register.RegisterListenerExecutor
;
import
com.nepxion.discovery.plugin.framework.listener.register.RegisterListenerExecutor
;
public
class
ConsulServiceRegistryDecorator
extends
ConsulServiceRegistry
{
public
class
ConsulServiceRegistryDecorator
extends
ConsulServiceRegistry
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ConsulServiceRegistryDecorator
.
class
);
private
ConsulServiceRegistry
serviceRegistry
;
private
ConsulServiceRegistry
serviceRegistry
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableEnvironment
environment
;
private
ConfigurableEnvironment
environment
;
...
@@ -34,8 +39,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
...
@@ -34,8 +39,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
public
void
register
(
ConsulRegistration
registration
)
{
public
void
register
(
ConsulRegistration
registration
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onRegister
(
registration
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onRegister
(
registration
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
register
(
registration
);
serviceRegistry
.
register
(
registration
);
...
@@ -45,8 +54,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
...
@@ -45,8 +54,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
public
void
deregister
(
ConsulRegistration
registration
)
{
public
void
deregister
(
ConsulRegistration
registration
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onDeregister
(
registration
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onDeregister
(
registration
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
deregister
(
registration
);
serviceRegistry
.
deregister
(
registration
);
...
@@ -56,8 +69,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
...
@@ -56,8 +69,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
public
void
setStatus
(
ConsulRegistration
registration
,
String
status
)
{
public
void
setStatus
(
ConsulRegistration
registration
,
String
status
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onSetStatus
(
registration
,
status
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onSetStatus
(
registration
,
status
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
setStatus
(
registration
,
status
);
serviceRegistry
.
setStatus
(
registration
,
status
);
...
@@ -72,8 +89,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
...
@@ -72,8 +89,12 @@ public class ConsulServiceRegistryDecorator extends ConsulServiceRegistry {
public
void
close
()
{
public
void
close
()
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onClose
();
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onClose
();
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
close
();
serviceRegistry
.
close
();
...
...
discovery-plugin-framework-eureka/src/main/java/com/nepxion/discovery/plugin/framework/decorator/EurekaServiceRegistryDecorator.java
View file @
4d87bf1a
...
@@ -9,6 +9,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
...
@@ -9,6 +9,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
* @version 1.0
* @version 1.0
*/
*/
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeansException
;
import
org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration
;
import
org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration
;
import
org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry
;
import
org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
@@ -18,6 +21,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
...
@@ -18,6 +21,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import
com.nepxion.discovery.plugin.framework.listener.register.RegisterListenerExecutor
;
import
com.nepxion.discovery.plugin.framework.listener.register.RegisterListenerExecutor
;
public
class
EurekaServiceRegistryDecorator
extends
EurekaServiceRegistry
{
public
class
EurekaServiceRegistryDecorator
extends
EurekaServiceRegistry
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EurekaServiceRegistryDecorator
.
class
);
private
EurekaServiceRegistry
serviceRegistry
;
private
EurekaServiceRegistry
serviceRegistry
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableEnvironment
environment
;
private
ConfigurableEnvironment
environment
;
...
@@ -32,8 +37,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
...
@@ -32,8 +37,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
public
void
register
(
EurekaRegistration
registration
)
{
public
void
register
(
EurekaRegistration
registration
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onRegister
(
registration
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onRegister
(
registration
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
register
(
registration
);
serviceRegistry
.
register
(
registration
);
...
@@ -43,8 +52,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
...
@@ -43,8 +52,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
public
void
deregister
(
EurekaRegistration
registration
)
{
public
void
deregister
(
EurekaRegistration
registration
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onDeregister
(
registration
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onDeregister
(
registration
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
deregister
(
registration
);
serviceRegistry
.
deregister
(
registration
);
...
@@ -54,8 +67,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
...
@@ -54,8 +67,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
public
void
setStatus
(
EurekaRegistration
registration
,
String
status
)
{
public
void
setStatus
(
EurekaRegistration
registration
,
String
status
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onSetStatus
(
registration
,
status
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onSetStatus
(
registration
,
status
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
setStatus
(
registration
,
status
);
serviceRegistry
.
setStatus
(
registration
,
status
);
...
@@ -70,8 +87,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
...
@@ -70,8 +87,12 @@ public class EurekaServiceRegistryDecorator extends EurekaServiceRegistry {
public
void
close
()
{
public
void
close
()
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onClose
();
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onClose
();
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
close
();
serviceRegistry
.
close
();
...
...
discovery-plugin-framework-zookeeper/src/main/java/com/nepxion/discovery/plugin/framework/decorator/ZookeeperServiceRegistryDecorator.java
View file @
4d87bf1a
...
@@ -9,6 +9,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
...
@@ -9,6 +9,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
* @version 1.0
* @version 1.0
*/
*/
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeansException
;
import
org.springframework.cloud.zookeeper.serviceregistry.ZookeeperRegistration
;
import
org.springframework.cloud.zookeeper.serviceregistry.ZookeeperRegistration
;
import
org.springframework.cloud.zookeeper.serviceregistry.ZookeeperServiceRegistry
;
import
org.springframework.cloud.zookeeper.serviceregistry.ZookeeperServiceRegistry
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
@@ -18,6 +21,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
...
@@ -18,6 +21,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import
com.nepxion.discovery.plugin.framework.listener.register.RegisterListenerExecutor
;
import
com.nepxion.discovery.plugin.framework.listener.register.RegisterListenerExecutor
;
public
class
ZookeeperServiceRegistryDecorator
extends
ZookeeperServiceRegistry
{
public
class
ZookeeperServiceRegistryDecorator
extends
ZookeeperServiceRegistry
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ZookeeperServiceRegistryDecorator
.
class
);
private
ZookeeperServiceRegistry
serviceRegistry
;
private
ZookeeperServiceRegistry
serviceRegistry
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableEnvironment
environment
;
private
ConfigurableEnvironment
environment
;
...
@@ -34,8 +39,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
...
@@ -34,8 +39,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
public
void
register
(
ZookeeperRegistration
registration
)
{
public
void
register
(
ZookeeperRegistration
registration
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onRegister
(
registration
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onRegister
(
registration
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
register
(
registration
);
serviceRegistry
.
register
(
registration
);
...
@@ -45,8 +54,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
...
@@ -45,8 +54,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
public
void
deregister
(
ZookeeperRegistration
registration
)
{
public
void
deregister
(
ZookeeperRegistration
registration
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onDeregister
(
registration
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onDeregister
(
registration
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
deregister
(
registration
);
serviceRegistry
.
deregister
(
registration
);
...
@@ -56,8 +69,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
...
@@ -56,8 +69,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
public
void
setStatus
(
ZookeeperRegistration
registration
,
String
status
)
{
public
void
setStatus
(
ZookeeperRegistration
registration
,
String
status
)
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onSetStatus
(
registration
,
status
);
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onSetStatus
(
registration
,
status
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
setStatus
(
registration
,
status
);
serviceRegistry
.
setStatus
(
registration
,
status
);
...
@@ -72,8 +89,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
...
@@ -72,8 +89,12 @@ public class ZookeeperServiceRegistryDecorator extends ZookeeperServiceRegistry
public
void
close
()
{
public
void
close
()
{
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
Boolean
registerControlEnabled
=
PluginContextAware
.
isRegisterControlEnabled
(
environment
);
if
(
registerControlEnabled
)
{
if
(
registerControlEnabled
)
{
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
try
{
registerListenerExecutor
.
onClose
();
RegisterListenerExecutor
registerListenerExecutor
=
applicationContext
.
getBean
(
RegisterListenerExecutor
.
class
);
registerListenerExecutor
.
onClose
();
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for RegisterListenerExecutor failed, ignore to executor listener"
);
}
}
}
serviceRegistry
.
close
();
serviceRegistry
.
close
();
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/decorator/DiscoveryClientDecorator.java
View file @
4d87bf1a
...
@@ -11,6 +11,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
...
@@ -11,6 +11,9 @@ package com.nepxion.discovery.plugin.framework.decorator;
import
java.util.List
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeansException
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
@@ -20,6 +23,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
...
@@ -20,6 +23,8 @@ import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import
com.nepxion.discovery.plugin.framework.listener.discovery.DiscoveryListenerExecutor
;
import
com.nepxion.discovery.plugin.framework.listener.discovery.DiscoveryListenerExecutor
;
public
class
DiscoveryClientDecorator
implements
DiscoveryClient
{
public
class
DiscoveryClientDecorator
implements
DiscoveryClient
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DiscoveryClientDecorator
.
class
);
private
DiscoveryClient
discoveryClient
;
private
DiscoveryClient
discoveryClient
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableApplicationContext
applicationContext
;
private
ConfigurableEnvironment
environment
;
private
ConfigurableEnvironment
environment
;
...
@@ -36,8 +41,12 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
...
@@ -36,8 +41,12 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
if
(
discoveryControlEnabled
)
{
if
(
discoveryControlEnabled
)
{
DiscoveryListenerExecutor
discoveryListenerExecutor
=
applicationContext
.
getBean
(
DiscoveryListenerExecutor
.
class
);
try
{
discoveryListenerExecutor
.
onGetInstances
(
serviceId
,
instances
);
DiscoveryListenerExecutor
discoveryListenerExecutor
=
applicationContext
.
getBean
(
DiscoveryListenerExecutor
.
class
);
discoveryListenerExecutor
.
onGetInstances
(
serviceId
,
instances
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for DiscoveryListenerExecutor failed, ignore to executor listener"
);
}
}
}
return
instances
;
return
instances
;
...
@@ -53,8 +62,12 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
...
@@ -53,8 +62,12 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
if
(
discoveryControlEnabled
)
{
if
(
discoveryControlEnabled
)
{
DiscoveryListenerExecutor
discoveryListenerExecutor
=
applicationContext
.
getBean
(
DiscoveryListenerExecutor
.
class
);
try
{
discoveryListenerExecutor
.
onGetServices
(
services
);
DiscoveryListenerExecutor
discoveryListenerExecutor
=
applicationContext
.
getBean
(
DiscoveryListenerExecutor
.
class
);
discoveryListenerExecutor
.
onGetServices
(
services
);
}
catch
(
BeansException
e
)
{
LOG
.
warn
(
"Get bean for DiscoveryListenerExecutor failed, ignore to executor listener"
);
}
}
}
return
services
;
return
services
;
...
...
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