mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
sync & commit in greenwich
This commit is contained in:
@@ -109,7 +109,7 @@ public class NacosDiscoveryProperties {
|
||||
private String clusterName = "DEFAULT";
|
||||
|
||||
/**
|
||||
* group name for nacos
|
||||
* group name for nacos.
|
||||
*/
|
||||
private String group = "DEFAULT_GROUP";
|
||||
|
||||
@@ -430,7 +430,7 @@ public class NacosDiscoveryProperties {
|
||||
String serverAddr = env
|
||||
.resolvePlaceholders("${spring.cloud.nacos.discovery.server-addr:}");
|
||||
if (StringUtils.isEmpty(serverAddr)) {
|
||||
serverAddr = env.resolvePlaceholders("${spring.cloud.nacos.server-addr}");
|
||||
serverAddr = env.resolvePlaceholders("${spring.cloud.nacos.server-addr:}");
|
||||
}
|
||||
this.setServerAddr(serverAddr);
|
||||
}
|
||||
|
@@ -16,34 +16,36 @@
|
||||
*/
|
||||
package com.alibaba.cloud.nacos;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.alibaba.nacos.api.naming.NamingMaintainService;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:liaochunyhm@live.com">liaochuntao</a>
|
||||
*/
|
||||
public class NacosNamingManager implements ApplicationContextAware {
|
||||
public class NacosNamingManager {
|
||||
|
||||
private NamingService namingService;
|
||||
private NamingMaintainService namingMaintainService;
|
||||
private static NamingService namingService = null;
|
||||
|
||||
private static NamingMaintainService namingMaintainService = null;
|
||||
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties discoveryProperties;
|
||||
|
||||
public NamingService getNamingService() {
|
||||
if (Objects.isNull(namingService)) {
|
||||
namingService = discoveryProperties.namingServiceInstance();
|
||||
}
|
||||
return namingService;
|
||||
}
|
||||
|
||||
public NamingMaintainService getNamingMaintainService() {
|
||||
if (Objects.isNull(namingMaintainService)) {
|
||||
namingMaintainService = discoveryProperties.namingMaintainServiceInstance();
|
||||
}
|
||||
return namingMaintainService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
NacosDiscoveryProperties properties = applicationContext
|
||||
.getBean(NacosDiscoveryProperties.class);
|
||||
namingService = properties.namingServiceInstance();
|
||||
namingMaintainService = properties.namingMaintainServiceInstance();
|
||||
}
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
|
||||
try {
|
||||
namingService.registerInstance(serviceId, group, instance);
|
||||
log.info("nacos registry, {} {}:{} register finished", serviceId,
|
||||
log.info("nacos registry, {} {} {}:{} register finished", group, serviceId,
|
||||
instance.getIp(), instance.getPort());
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import java.util.List;
|
||||
|
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import java.util.List;
|
||||
|
Reference in New Issue
Block a user