use of org.apache.servicecomb.registry.api.registry.BasePath in project java-chassis by ServiceComb.
the class ProducerBootListener method saveBasePaths.
// just compatible to old 3rd components, servicecomb not use it......
private void saveBasePaths(MicroserviceMeta microserviceMeta) {
if (!DynamicPropertyFactory.getInstance().getBooleanProperty(DefinitionConst.REGISTER_SERVICE_PATH, false).get()) {
return;
}
String urlPrefix = ClassLoaderScopeContext.getClassLoaderScopeProperty(DefinitionConst.URL_PREFIX);
Map<String, BasePath> basePaths = new LinkedHashMap<>();
for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas().values()) {
Swagger swagger = schemaMeta.getSwagger();
String basePath = swagger.getBasePath();
if (StringUtils.isNotEmpty(urlPrefix) && !basePath.startsWith(urlPrefix)) {
basePath = urlPrefix + basePath;
}
if (StringUtils.isNotEmpty(basePath)) {
BasePath basePathObj = new BasePath();
basePathObj.setPath(basePath);
basePaths.put(basePath, basePathObj);
}
}
RegistrationManager.INSTANCE.addBasePath(basePaths.values());
}
use of org.apache.servicecomb.registry.api.registry.BasePath in project java-chassis by ServiceComb.
the class ConfigurePropertyUtils method getMicroservicePaths.
public static List<BasePath> getMicroservicePaths(Configuration configuration) {
List<Object> configPaths = BootStrapProperties.readServicePaths(configuration);
List<BasePath> basePaths = DatabindCodec.mapper().convertValue(configPaths, TypeFactory.defaultInstance().constructCollectionType(List.class, BasePath.class));
for (BasePath basePath : basePaths) {
basePath.setPath(buildPath(basePath.getPath()));
}
return basePaths;
}
use of org.apache.servicecomb.registry.api.registry.BasePath in project java-chassis by ServiceComb.
the class TestMicroService method initMicroservice.
private void initMicroservice() {
oMicroservice.setAppId("testAppID");
oMicroservice.setDescription("This is the test");
oMicroservice.setLevel("INFO");
oMicroservice.setServiceId("testServiceID");
oMicroservice.setServiceName("testServiceName");
oMicroservice.setStatus(MicroserviceInstanceStatus.DOWN.toString());
oMicroservice.setVersion("1.0.0");
oMapProperties.put("proxy", "fakeProxy");
oListSchemas.add("testSchemas");
oMicroservice.setProperties(oMapProperties);
oMicroservice.setSchemas(oListSchemas);
oMicroservice.getPaths().add(new BasePath());
Framework framework = new Framework();
framework.setName("JAVA-CHASSIS");
framework.setVersion("x.x.x");
oMicroservice.setFramework(framework);
oMicroservice.setRegisterBy("SDK");
oMicroservice.setEnvironment("development");
}
use of org.apache.servicecomb.registry.api.registry.BasePath in project java-chassis by ServiceComb.
the class TestConfigurePropertyUtils method testGetPropertiesWithPrefix.
@Test
public void testGetPropertiesWithPrefix() {
ClassLoaderScopeContext.clearClassLoaderScopeProperty();
Configuration configuration = ConfigUtil.createLocalConfig();
String prefix = "service_description.properties";
Map<String, String> expectedMap = new HashMap<>();
expectedMap.put("key1", "value1");
expectedMap.put("key2", "value2");
Assert.assertEquals(expectedMap, ConfigurePropertyUtils.getPropertiesWithPrefix(configuration, prefix));
List<BasePath> paths = ConfigurePropertyUtils.getMicroservicePaths(configuration);
Assert.assertEquals(2, paths.size());
Assert.assertEquals(paths.get(0).getPath(), "/test1/testpath");
Assert.assertEquals(paths.get(0).getProperty().get("checksession"), "false");
ClassLoaderScopeContext.setClassLoaderScopeProperty(DefinitionConst.URL_PREFIX, "/webroot");
paths = ConfigurePropertyUtils.getMicroservicePaths(configuration);
Assert.assertEquals(2, paths.size());
Assert.assertEquals(paths.get(0).getPath(), "/webroot/test1/testpath");
Assert.assertEquals(paths.get(0).getProperty().get("checksession"), "false");
ClassLoaderScopeContext.clearClassLoaderScopeProperty();
}
Aggregations