MeshRegistry extends Registry { @Override public void register(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (!config.isRegister()) { return; } List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = MeshRegistryHelper.buildMeshKey(config, server.getProtocol()); ProviderInfo providerInfo = MeshRegistryHelper.convertProviderToProviderInfo(config, server); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_START, serviceName)); } doRegister(appName, serviceName, providerInfo, server.getProtocol()); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_OVER, serviceName)); } } if (EventBus.isEnable(ProviderPubEvent.class)) { ProviderPubEvent event = new ProviderPubEvent(config); EventBus.post(event); } } } protected  MeshRegistry(RegistryConfig registryConfig); @Override void init(); @Override boolean start(); @Override void register(ProviderConfig config); @Override void unRegister(ProviderConfig config); @Override void batchUnRegister(List<ProviderConfig> configs); @Override List<ProviderGroup> subscribe(final ConsumerConfig config); @Override void unSubscribe(ConsumerConfig config); @Override void batchUnSubscribe(List<ConsumerConfig> configs); @Override void destroy();  }
@Test public void testOnlyPublish() throws InterruptedException { Field registedAppField = null; try { registedAppField = MeshRegistry.class.getDeclaredField("registedApp"); registedAppField.setAccessible(true); } catch (NoSuchFieldException e) { e.printStackTrace(); } Boolean registedAppValue = null; try { registedAppValue = (Boolean) registedAppField.get(registry); registedAppField.set(registry, false); } catch (IllegalAccessException e) { e.printStackTrace(); } ServerConfig serverConfig = new ServerConfig() .setProtocol("bolt") .setHost("0.0.0.0") .setPort(12200); ProviderConfig<?> provider = new ProviderConfig(); provider.setInterfaceId("com.alipay.xxx.TestService") .setUniqueId("unique123Id") .setApplication(new ApplicationConfig().setAppName("test-server")) .setProxy("javassist") .setRegister(true) .setRegistry(registryConfig) .setSerialization("hessian2") .setServer(serverConfig) .setWeight(222) .setTimeout(3000); registry.register(provider); Thread.sleep(3000); try { registedAppValue = (Boolean) registedAppField.get(registry); } catch (IllegalAccessException e) { e.printStackTrace(); } LOGGER.info("final registedAppValue is " + registedAppValue); Assert.assertTrue(registedAppValue); }