use of com.jeesuite.springweb.model.AppMetadata in project jeesuite-libs by vakinge.
the class AppMetadataHolder method getMetadata.
public static AppMetadata getMetadata() {
if (metadata != null)
return metadata;
synchronized (AppMetadataHolder.class) {
//
metadata = new AppMetadata();
metadata.setServiceId(GlobalRuntimeContext.APPID);
String basePackage = ResourceUtils.getProperty("jeesuite.application.base-package");
if (basePackage == null)
return metadata;
List<String> classNameList = scanControllerClassNames(basePackage);
//
scanApiInfos(metadata, classNameList);
if (ResourceUtils.containsProperty("dependency.services")) {
metadata.setDependencyServices(ResourceUtils.getList("dependency.services"));
}
}
return metadata;
}
use of com.jeesuite.springweb.model.AppMetadata in project jeesuite-libs by vakinge.
the class CurrentSystemHolder method initModuleApiInfos.
private static void initModuleApiInfos(BizSystemModule module) {
try {
String url;
if (module.getServiceId().startsWith("http")) {
url = String.format("%s/metadata", module.getServiceId());
} else {
url = String.format("http://%s/metadata", module.getServiceId());
}
AppMetadata appMetadata;
if (GlobalRuntimeContext.APPID.equals(module.getRouteName())) {
appMetadata = AppMetadataHolder.getMetadata();
} else {
appMetadata = new GenericApiRequest.Builder().requestUrl(url).responseClass(AppMetadata.class).backendInternalCall().build().waitResponse();
}
Map<String, ApiInfo> apiInfos = new HashMap<>(appMetadata.getApis().size());
String uri;
for (ApiInfo api : appMetadata.getApis()) {
if (GlobalRuntimeContext.APPID.equals(module.getRouteName())) {
uri = String.format("%s/%s", GlobalRuntimeContext.getContextPath(), api.getUrl());
} else {
uri = String.format("%s/%s/%s", GlobalRuntimeContext.getContextPath(), module.getRouteName(), api.getUrl());
}
uri = uri.replace("//", "/");
apiInfos.put(uri, api);
}
module.setApiInfos(apiInfos);
moduleApiInfos.put(module.getServiceId(), apiInfos);
} catch (Exception e) {
if (e instanceof JeesuiteBaseException && ((JeesuiteBaseException) e).getCode() == 404) {
module.setApiInfos(new HashMap<>(0));
moduleApiInfos.put(module.getServiceId(), module.getApiInfos());
} else {
log.warn(">> initModuleApiInfos error -> serviceId:{},error:{}", module.getServiceId(), e.getMessage());
}
}
}
Aggregations