Search in sources :

Example 1 with AppMetadata

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;
}
Also used : AppMetadata(com.mendmix.springweb.model.AppMetadata)

Example 2 with AppMetadata

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);
        }
    }
}
Also used : JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException) HashMap(java.util.HashMap) ApiInfo(com.mendmix.common.model.ApiInfo) AppMetadata(com.mendmix.springweb.model.AppMetadata) JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException)

Aggregations

AppMetadata (com.mendmix.springweb.model.AppMetadata)2 JeesuiteBaseException (com.mendmix.common.JeesuiteBaseException)1 ApiInfo (com.mendmix.common.model.ApiInfo)1 HashMap (java.util.HashMap)1