use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.
the class TestConfigUtil method testCreateDynamicConfigNoConfigCenterSPI.
@Test
public void testCreateDynamicConfigNoConfigCenterSPI() {
new Expectations(SPIServiceUtils.class) {
{
SPIServiceUtils.getTargetService(ConfigCenterConfigurationSource.class);
result = null;
}
};
AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader(dynamicConfig);
List<ConfigModel> list = loader.getConfigModels();
Assert.assertEquals(loader, ConfigUtil.getMicroserviceConfigLoader(dynamicConfig));
Assert.assertEquals(1, list.size());
Assert.assertNotEquals(DynamicWatchedConfiguration.class, ((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.
the class RegistryUtils method init.
public static void init() {
MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
serviceRegistry = ServiceRegistryFactory.getOrCreate(EventManager.eventBus, ServiceRegistryConfig.INSTANCE, microserviceDefinition);
serviceRegistry.init();
}
use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceFactory method testInit.
@Test
public void testInit() {
MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
loader.loadAndSort();
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
MicroserviceFactory factory = new MicroserviceFactory();
Microservice microservice = factory.create(microserviceDefinition);
String microserviceName = "default";
Assert.assertEquals(microserviceName, microservice.getServiceName());
}
use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project java-chassis by ServiceComb.
the class ConfigUtil method createLocalConfig.
public static ConcurrentCompositeConfiguration createLocalConfig() {
MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
loader.loadAndSort();
if (localConfig.size() > 0) {
ConfigModel model = new ConfigModel();
model.setConfig(localConfig);
loader.getConfigModels().add(model);
}
boolean isPrintUrl = DynamicPropertyFactory.getInstance().getBooleanProperty(IS_PRINT_URL, true).get();
if (isPrintUrl) {
LOGGER.info("create local config from paths=[{}]", StringUtils.join(loader.getConfigModels(), ","));
}
ConcurrentCompositeConfiguration config = ConfigUtil.createLocalConfig(loader.getConfigModels());
return config;
}
use of org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader in project incubator-servicecomb-java-chassis by apache.
the class ServiceRegistryFactory method createLocal.
public static ServiceRegistry createLocal() {
EventBus eventBus = new EventBus();
ServiceRegistryConfig serviceRegistryConfig = ServiceRegistryConfig.INSTANCE;
MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
loader.loadAndSort();
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
return new LocalServiceRegistry(eventBus, serviceRegistryConfig, microserviceDefinition);
}
Aggregations