Search in sources :

Example 1 with DisconfUpdateService

use of com.baidu.disconf.client.common.annotations.DisconfUpdateService in project disconf by knightliao.

the class ReflectionScanStatic method scanBasicInfo.

/**
     * 扫描基本信息
     */
private ScanStaticModel scanBasicInfo(List<String> packNameList) {
    ScanStaticModel scanModel = new ScanStaticModel();
    //
    // 扫描对象
    //
    Reflections reflections = getReflection(packNameList);
    scanModel.setReflections(reflections);
    //
    // 获取DisconfFile class
    //
    Set<Class<?>> classdata = reflections.getTypesAnnotatedWith(DisconfFile.class);
    scanModel.setDisconfFileClassSet(classdata);
    //
    // 获取DisconfFileItem method
    //
    Set<Method> af1 = reflections.getMethodsAnnotatedWith(DisconfFileItem.class);
    scanModel.setDisconfFileItemMethodSet(af1);
    //
    // 获取DisconfItem method
    //
    af1 = reflections.getMethodsAnnotatedWith(DisconfItem.class);
    scanModel.setDisconfItemMethodSet(af1);
    //
    // 获取DisconfActiveBackupService
    //
    classdata = reflections.getTypesAnnotatedWith(DisconfActiveBackupService.class);
    scanModel.setDisconfActiveBackupServiceClassSet(classdata);
    //
    // 获取DisconfUpdateService
    //
    classdata = reflections.getTypesAnnotatedWith(DisconfUpdateService.class);
    scanModel.setDisconfUpdateService(classdata);
    // update pipeline
    Set<Class<? extends IDisconfUpdatePipeline>> iDisconfUpdatePipeline = reflections.getSubTypesOf(IDisconfUpdatePipeline.class);
    if (iDisconfUpdatePipeline != null && iDisconfUpdatePipeline.size() != 0) {
        scanModel.setiDisconfUpdatePipeline((Class<IDisconfUpdatePipeline>) iDisconfUpdatePipeline.toArray()[0]);
    }
    return scanModel;
}
Also used : DisconfActiveBackupService(com.baidu.disconf.client.common.annotations.DisconfActiveBackupService) IDisconfUpdatePipeline(com.baidu.disconf.client.common.update.IDisconfUpdatePipeline) ScanStaticModel(com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel) Method(java.lang.reflect.Method) DisconfUpdateService(com.baidu.disconf.client.common.annotations.DisconfUpdateService) Reflections(org.reflections.Reflections) DisconfItem(com.baidu.disconf.client.common.annotations.DisconfItem)

Example 2 with DisconfUpdateService

use of com.baidu.disconf.client.common.annotations.DisconfUpdateService in project disconf by knightliao.

the class ScanDynamicStoreAdapter method analysis4DisconfUpdate.

/**
     * 第二次扫描, 获取更新 回调的实例<br/>
     * <p/>
     * 分析出更新操作的相关配置文件内容
     */
private static ScanDynamicModel analysis4DisconfUpdate(ScanStaticModel scanModel, Registry registry) {
    // 配置项或文件
    Map<DisconfKey, List<IDisconfUpdate>> inverseMap = new HashMap<DisconfKey, List<IDisconfUpdate>>();
    Set<Class<?>> disconfUpdateServiceSet = scanModel.getDisconfUpdateService();
    for (Class<?> disconfUpdateServiceClass : disconfUpdateServiceSet) {
        // 回调对应的参数
        DisconfUpdateService disconfUpdateService = disconfUpdateServiceClass.getAnnotation(DisconfUpdateService.class);
        // 校验是否有继承正确,是否继承IDisconfUpdate
        if (!ScanVerify.hasIDisconfUpdate(disconfUpdateServiceClass)) {
            continue;
        }
        //
        // 获取回调接口实例
        IDisconfUpdate iDisconfUpdate = getIDisconfUpdateInstance(disconfUpdateServiceClass, registry);
        if (iDisconfUpdate == null) {
            continue;
        }
        //
        // 配置项
        processItems(inverseMap, disconfUpdateService, iDisconfUpdate);
        //
        // 配置文件
        processFiles(inverseMap, disconfUpdateService, iDisconfUpdate);
    }
    // set data
    ScanDynamicModel scanDynamicModel = new ScanDynamicModel();
    scanDynamicModel.setDisconfUpdateServiceInverseIndexMap(inverseMap);
    //
    if (scanModel.getiDisconfUpdatePipeline() != null) {
        IDisconfUpdatePipeline iDisconfUpdatePipeline = getIDisconfUpdatePipelineInstance(scanModel.getiDisconfUpdatePipeline(), registry);
        if (iDisconfUpdatePipeline != null) {
            scanDynamicModel.setDisconfUpdatePipeline(iDisconfUpdatePipeline);
        }
    }
    return scanDynamicModel;
}
Also used : IDisconfUpdatePipeline(com.baidu.disconf.client.common.update.IDisconfUpdatePipeline) HashMap(java.util.HashMap) DisconfKey(com.baidu.disconf.client.common.model.DisconfKey) IDisconfUpdate(com.baidu.disconf.client.common.update.IDisconfUpdate) ScanDynamicModel(com.baidu.disconf.client.scan.inner.dynamic.model.ScanDynamicModel) ArrayList(java.util.ArrayList) List(java.util.List) DisconfUpdateService(com.baidu.disconf.client.common.annotations.DisconfUpdateService)

Aggregations

DisconfUpdateService (com.baidu.disconf.client.common.annotations.DisconfUpdateService)2 IDisconfUpdatePipeline (com.baidu.disconf.client.common.update.IDisconfUpdatePipeline)2 DisconfActiveBackupService (com.baidu.disconf.client.common.annotations.DisconfActiveBackupService)1 DisconfItem (com.baidu.disconf.client.common.annotations.DisconfItem)1 DisconfKey (com.baidu.disconf.client.common.model.DisconfKey)1 IDisconfUpdate (com.baidu.disconf.client.common.update.IDisconfUpdate)1 ScanDynamicModel (com.baidu.disconf.client.scan.inner.dynamic.model.ScanDynamicModel)1 ScanStaticModel (com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Reflections (org.reflections.Reflections)1