use of com.mendmix.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.setModule(GlobalRuntimeContext.MODULE_NAME);
metadata.setServiceId(GlobalRuntimeContext.APPID);
String basePackage = AppConfigs.basePackage;
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.mendmix.springweb.model.AppMetadata in project jeesuite-libs by vakinge.
the class CurrentSystemHolder method initModuleApiInfos.
private static void initModuleApiInfos(BizSystemModule module) {
try {
String url;
AppMetadata appMetadata;
if (GlobalRuntimeContext.APPID.equals(module.getRouteName())) {
appMetadata = AppMetadataHolder.getMetadata();
} else {
url = module.getMetadataUri();
appMetadata = HttpRequestEntity.get(url).backendInternalCall().execute().toObject(AppMetadata.class);
}
for (ApiInfo api : appMetadata.getApis()) {
module.addApiInfo(api);
}
moduleApiInfos.put(module.getServiceId(), module.getApiInfos());
log.info(">>initModuleApiInfos success -> serviceId:{},nums:{}", module.getServiceId(), module.getApiInfos().size());
} catch (Exception e) {
boolean ignore = e instanceof ClassCastException;
if (!ignore && e instanceof JeesuiteBaseException) {
JeesuiteBaseException ex = (JeesuiteBaseException) e;
ignore = ex.getCode() == 404 || ex.getCode() == 401 || ex.getCode() == 403;
}
if (ignore) {
module.setApiInfos(new HashMap<>(0));
moduleApiInfos.put(module.getServiceId(), module.getApiInfos());
} else if (fetchApiMetaRound <= 1) {
log.error(">>initModuleApiInfos error -> serviceId:[" + module.getServiceId() + "]", e);
}
}
}
Aggregations