Search in sources :

Example 6 with NamingService

use of com.alibaba.nacos.api.naming.NamingService in project dubbo by alibaba.

the class NacosNamingServiceUtils method createNamingService.

/**
 * 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 NacosNamingServiceWrapper 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 new NacosNamingServiceWrapper(namingService);
}
Also used : NacosNamingServiceWrapper(org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper) NamingService(com.alibaba.nacos.api.naming.NamingService) Properties(java.util.Properties) NacosException(com.alibaba.nacos.api.exception.NacosException)

Aggregations

NacosException (com.alibaba.nacos.api.exception.NacosException)6 NamingService (com.alibaba.nacos.api.naming.NamingService)6 Instance (com.alibaba.nacos.api.naming.pojo.Instance)5 NacosNamingService (com.alibaba.nacos.client.naming.NacosNamingService)5 URL (org.apache.dubbo.common.URL)5 Test (org.junit.jupiter.api.Test)5 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 NotifyListener (org.apache.dubbo.registry.NotifyListener)3 ListView (com.alibaba.nacos.api.naming.pojo.ListView)1 Properties (java.util.Properties)1 NacosNamingServiceWrapper (org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper)1