YarMessageRouter extends ProviderMessageRouter { @Override public void addProvider(Provider<?> provider) { String path = YarProtocolUtil.getYarPath(provider.getInterface(), provider.getUrl()); Provider<?> old = providerMap.putIfAbsent(path, provider); if (old != null) { throw new MotanFrameworkException("duplicate yar provider"); } } YarMessageRouter();  YarMessageRouter(URL url); @Override Object handle(Channel channel, Object message); @Override void addProvider(Provider<?> provider); @Override void removeProvider(Provider<?> provider);  }
@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testAddProvider() { Provider provider = new DefaultProvider(null, null, AnnoService.class); router.addProvider(provider); assertTrue(router.checkProvider(requestPath)); router.removeProvider(provider); assertFalse(router.checkProvider(requestPath)); URL url = new URL("motan", "localhost", 8002, "urlpath"); provider = new DefaultProvider(null, url, normalService.class); router.addProvider(provider); assertTrue(router.checkProvider(YarProtocolUtil.getYarPath(normalService.class, url))); router.removeProvider(provider); assertFalse(router.checkProvider(YarProtocolUtil.getYarPath(normalService.class, url))); }