ServiceConfig extends AbstractServiceConfig { public synchronized void export() { if (exported.get()) { LoggerUtil.warn(String.format("%s has already been expoted, so ignore the export request!", interfaceClass.getName())); return; } checkInterfaceAndMethods(interfaceClass, methods); loadRegistryUrls(); if (registryUrls == null || registryUrls.size() == 0) { throw new IllegalStateException("Should set registry config for service:" + interfaceClass.getName()); } Map<String, Integer> protocolPorts = getProtocolAndPort(); for (ProtocolConfig protocolConfig : protocols) { Integer port = protocolPorts.get(protocolConfig.getId()); if (port == null) { throw new MotanServiceException(String.format("Unknow port in service:%s, protocol:%s", interfaceClass.getName(), protocolConfig.getId())); } doExport(protocolConfig, port); } afterExport(); }  static ConcurrentHashSet<String> getExistingServices(); Class<?> getInterface(); void setInterface(Class<T> interfaceClass); List<MethodConfig> getMethods(); void setMethods(MethodConfig methods); void setMethods(List<MethodConfig> methods); boolean hasMethods(); T getRef(); void setRef(T ref); List<Exporter<T>> getExporters(); synchronized void export(); synchronized void unexport(); @ConfigDesc(excluded = true) BasicServiceInterfaceConfig getBasicService(); void setBasicService(BasicServiceInterfaceConfig basicService); Map<String, Integer> getProtocolAndPort(); @ConfigDesc(excluded = true) String getHost(); void setHost(String host); AtomicBoolean getExported();  }
@Test public void testExport() { serviceConfig.export(); assertTrue(serviceConfig.getExported().get()); assertEquals(serviceConfig.getExporters().size(), 1); assertEquals(serviceConfig.getRegistryUrls().size(), 1); }