Java Code Examples for com.alibaba.nacos.api.NacosFactory#createNamingService()

The following examples show how to use com.alibaba.nacos.api.NacosFactory#createNamingService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NacosRegistry.java    From joyrpc with Apache License 2.0 5 votes vote down vote up
@Override
protected void doOpen() {
    try {
        namingService = NacosFactory.createNamingService(properties);
    } catch (NacosException e) {
        logger.error(e.getErrMsg(), e);
        throw new IllegalStateException(e);
    }
    super.doOpen();
}
 
Example 2
Source File: NacosNamingServiceUtils.java    From dubbo-registry-nacos with Apache License 2.0 5 votes vote down vote up
/**
 * Create an instance of {@link NamingService} from specified {@link URL connection url}
 *
 * @param connectionURL {@link URL connection url}
 * @return {@link NamingService}
 * @since 2.7.5
 */
public static NamingService createNamingService(URL connectionURL) {
    Properties nacosProperties = buildNacosProperties(connectionURL);
    NamingService namingService;
    try {
        namingService = NacosFactory.createNamingService(nacosProperties);
    } catch (NacosException e) {
        if (logger.isErrorEnabled()) {
            logger.error(e.getErrMsg(), e);
        }
        throw new IllegalStateException(e);
    }
    return namingService;
}
 
Example 3
Source File: CacheableEventPublishingNacosServiceFactory.java    From nacos-spring-project with Apache License 2.0 5 votes vote down vote up
@Override
public NamingService run(Properties properties, NamingService service)
		throws NacosException {
	String cacheKey = identify(properties);
	NamingService namingService = namingServicesCache.get(cacheKey);

	if (namingService == null) {
		if (service == null) {
			service = NacosFactory.createNamingService(properties);
		}
		namingService = new DelegatingNamingService(service, properties);
		namingServicesCache.put(cacheKey, namingService);
	}
	return namingService;
}
 
Example 4
Source File: NacosDiscoveryProperties.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
public NamingService namingServiceInstance() {

		if (null != namingService) {
			return namingService;
		}

		try {
			namingService = NacosFactory.createNamingService(getNacosProperties());
		}
		catch (Exception e) {
			log.error("create naming service error!properties={},e=,", this, e);
			return null;
		}
		return namingService;
	}