@@ -23,13 +23,24 @@ public class ModelNameServiceImpl implements ModelNameService {
2323 @ Autowired
2424 private ApplicationConfig applicationConfig ;
2525
26- @ Autowired
27- private ProviderConfig providerConfig ;
28-
2926 @ Autowired
3027 private ApplicationContext applicationContext ;
3128
32- public RegistryConfig getRegistryConfig (){
29+ private ProviderConfig providerConfig (){
30+ Map <String , ProviderConfig > beans = applicationContext .getBeansOfType (ProviderConfig .class );
31+ ProviderConfig providerConfig = null ;
32+ if (beans !=null ){
33+ String defaultKey = "default" ;
34+ for (String key :beans .keySet ()){
35+ defaultKey = key ;
36+ }
37+
38+ providerConfig = beans .get (defaultKey );
39+ }
40+ return providerConfig ;
41+ }
42+
43+ private RegistryConfig getRegistryConfig (){
3344 Map <String , RegistryConfig > beans = applicationContext .getBeansOfType (RegistryConfig .class );
3445 RegistryConfig registryConfig = null ;
3546 if (beans !=null ){
@@ -64,7 +75,7 @@ private String getIp() {
6475
6576 @ Override
6677 public String getUniqueKey () {
67- String address = getIp () + providerConfig . getPort ();
78+ String address = getIp () + getPort ();
6879 return MD5Util .md5 (address .getBytes ());
6980 }
7081
@@ -75,8 +86,8 @@ public String getIpAddress() {
7586 }
7687
7788 private int getPort (){
78- if (providerConfig .getPort ()!=null ){
79- return providerConfig .getPort ();
89+ if (providerConfig ()!= null && providerConfig () .getPort ()!=null ){
90+ return providerConfig () .getPort ();
8091 }
8192
8293 RegistryConfig registryConfig = getRegistryConfig ();
0 commit comments