use of com.weibo.api.motan.registry.RegistryFactory in project motan by weibocom.
the class SimpleConfigHandler method unRegister.
private void unRegister(Collection<URL> registryUrls, URL serviceUrl) {
for (URL url : registryUrls) {
// 不管check的设置如何,做完所有unregistry,做好清理工作
try {
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getExtension(url.getProtocol());
Registry registry = registryFactory.getRegistry(url);
registry.unregister(serviceUrl);
} catch (Exception e) {
LoggerUtil.warn(String.format("unregister url false:%s", url), e);
}
}
}
use of com.weibo.api.motan.registry.RegistryFactory in project motan by weibocom.
the class SimpleConfigHandler method unRegister.
private void unRegister(Collection<URL> registryUrls) {
for (URL url : registryUrls) {
// 不管check的设置如何,做完所有unregistry,做好清理工作
try {
String serviceStr = StringTools.urlDecode(url.getParameter(URLParamType.embed.getName()));
URL serviceUrl = URL.valueOf(serviceStr);
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getExtension(url.getProtocol());
Registry registry = registryFactory.getRegistry(url);
registry.unregister(serviceUrl);
} catch (Exception e) {
LoggerUtil.warn(String.format("unregister url false:%s", url), e);
}
}
}
use of com.weibo.api.motan.registry.RegistryFactory in project motan by weibocom.
the class MeshRegistry method initProxyRegistry.
protected void initProxyRegistry() {
String proxyRegistryString = getUrl().getParameter(URLParamType.proxyRegistryUrlString.getName());
if (StringUtils.isNotBlank(proxyRegistryString)) {
List<URL> urls = UrlUtils.stringToURLs(proxyRegistryString);
if (!CollectionUtil.isEmpty(urls)) {
// 仅支持对单注册中心的代理。如果有多注册中心的强需求在考虑扩展
URL proxyUrl = urls.get(0);
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getExtension(proxyUrl.getProtocol(), false);
if (registryFactory == null) {
LoggerUtil.warn("mesh registry can not find proxy registry. proxy registry url:" + proxyUrl.toSimpleString());
return;
}
Registry registry = registryFactory.getRegistry(proxyUrl);
if (registry != null) {
this.proxyRegistry = registry;
canBackup = true;
LoggerUtil.info("mesh registry add proxy registry. url:" + getUrl().toFullStr());
}
}
}
}
use of com.weibo.api.motan.registry.RegistryFactory in project motan by weibocom.
the class BaseTest method before.
@Before
public void before() {
mockery = new JUnit4Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
final Server mockServer = mockery.mock(Server.class);
final Client mockClient = mockery.mock(Client.class);
mockery.checking(new Expectations() {
{
allowing(mockClient).open();
will(returnValue(true));
allowing(mockClient).close();
will(returnValue(null));
allowing(mockClient).isAvailable();
will(returnValue(true));
allowing(mockServer).open();
will(returnValue(true));
allowing(mockServer).close();
will(returnValue(null));
allowing(mockServer).isAvailable();
will(returnValue(true));
}
});
ExtensionLoader loader = ExtensionLoader.getExtensionLoader(EndpointFactory.class);
endpointFactory = (MockEndpointFactory) loader.getExtension("mockEndpoint", false);
if (endpointFactory == null) {
loader.addExtensionClass(MockEndpointFactory.class);
endpointFactory = (MockEndpointFactory) loader.getExtension("mockEndpoint");
}
loader = ExtensionLoader.getExtensionLoader(RegistryFactory.class);
MockRegistryFactory registryFactory = (MockRegistryFactory) loader.getExtension("mockRegistry", false);
if (registryFactory == null) {
loader.addExtensionClass(MockRegistryFactory.class);
}
endpointFactory.setClient(mockClient);
endpointFactory.setServer(mockServer);
cp = new ClassPathXmlApplicationContext("classpath:schemaTestContext.xml");
}
use of com.weibo.api.motan.registry.RegistryFactory in project motan by weibocom.
the class SimpleConfigHandler method register.
private void register(List<URL> registryUrls, URL serviceUrl) {
for (URL url : registryUrls) {
// 根据check参数的设置,register失败可能会抛异常,上层应该知晓
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getExtension(url.getProtocol(), false);
if (registryFactory == null) {
throw new MotanFrameworkException(new MotanErrorMsg(500, MotanErrorMsgConstant.FRAMEWORK_REGISTER_ERROR_CODE, "register error! Could not find extension for registry protocol:" + url.getProtocol() + ", make sure registry module for " + url.getProtocol() + " is in classpath!"));
}
Registry registry = registryFactory.getRegistry(url);
registry.register(serviceUrl);
}
}
Aggregations