// Path: disconf-client/src/main/java/com/baidu/disconf/client/store/aspect/DisconfAspectJ.java
// @Aspect
// public class DisconfAspectJ {
// 
//     protected static final Logger LOGGER = LoggerFactory.getLogger(DisconfAspectJ.class);
// 
//     @Pointcut(value = "execution(public * *(..))")
//     public void anyPublicMethod() {
//     }
// 
//     /**
//      * 获取配置文件数据, 只有开启disconf远程才会进行切面
//      *
//      * @throws Throwable
//      */
//     @Around("anyPublicMethod() && @annotation(disconfFileItem)")
//     public Object decideAccess(ProceedingJoinPoint pjp, DisconfFileItem disconfFileItem) throws Throwable {
// 
//         if (DisClientConfig.getInstance().ENABLE_DISCONF) {
// 
//             MethodSignature ms = (MethodSignature) pjp.getSignature();
//             Method method = ms.getMethod();
// 
//             //
//             // 文件名
//             //
//             Class<?> cls = method.getDeclaringClass();
//             DisconfFile disconfFile = cls.getAnnotation(DisconfFile.class);
// 
//             //
//             // Field名
//             //
//             Field field = MethodUtils.getFieldFromMethod(method, cls.getDeclaredFields(), DisConfigTypeEnum.FILE);
//             if (field != null) {
// 
//                 //
//                 // 请求仓库配置数据
//                 //
//                 DisconfStoreProcessor disconfStoreProcessor =
//                         DisconfStoreProcessorFactory.getDisconfStoreFileProcessor();
//                 Object ret = disconfStoreProcessor.getConfig(disconfFile.filename(), disconfFileItem.name());
//                 if (ret != null) {
//                     LOGGER.debug("using disconf store value: " + disconfFile.filename() + " ("
//                             + disconfFileItem.name() +
//                             " , " + ret + ")");
//                     return ret;
//                 }
//             }
//         }
// 
//         Object rtnOb;
// 
//         try {
//             // 返回原值
//             rtnOb = pjp.proceed();
//         } catch (Throwable t) {
//             LOGGER.info(t.getMessage());
//             throw t;
//         }
// 
//         return rtnOb;
//     }
// 
//     /**
//      * 获取配置项数据, 只有开启disconf远程才会进行切面
//      *
//      * @throws Throwable
//      */
//     @Around("anyPublicMethod() && @annotation(disconfItem)")
//     public Object decideAccess(ProceedingJoinPoint pjp, DisconfItem disconfItem) throws Throwable {
// 
//         if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//             //
//             // 请求仓库配置数据
//             //
//             DisconfStoreProcessor disconfStoreProcessor = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();
//             Object ret = disconfStoreProcessor.getConfig(null, disconfItem.key());
//             if (ret != null) {
//                 LOGGER.debug("using disconf store value: (" + disconfItem.key() + " , " + ret + ")");
//                 return ret;
//             }
//         }
// 
//         Object rtnOb;
// 
//         try {
//             // 返回原值
//             rtnOb = pjp.proceed();
//         } catch (Throwable t) {
//             LOGGER.info(t.getMessage());
//             throw t;
//         }
// 
//         return rtnOb;
//     }
// }


import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import com.baidu.disconf.client.store.aspect.DisconfAspectJ;
import com.baidu.disconf.client.store.inner.DisconfCenterHostFilesStore;
import com.baidu.disconf.client.support.utils.StringUtil;
        DisconfCenterHostFilesStore.getInstance().addJustHostFileSet(fileList);

        List<String> scanPackList = StringUtil.parseStringToStringList(scanPackage, SCAN_SPLIT_TOKEN);
        // unique
        Set<String> hs = new HashSet<String>();
        hs.addAll(scanPackList);
        scanPackList.clear();
        scanPackList.addAll(hs);

        // 进行扫描
        DisconfMgr.getInstance().setApplicationContext(applicationContext);
        DisconfMgr.getInstance().firstScan(scanPackList);

        // register java bean
        registerAspect(registry);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    /**
     * register aspectJ for disconf get request
     *
     * @param registry
     */
    private void registerAspect(BeanDefinitionRegistry registry) {

        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
// Path: disconf-client/src/main/java/com/baidu/disconf/client/store/aspect/DisconfAspectJ.java
// @Aspect
// public class DisconfAspectJ {
// 
//     protected static final Logger LOGGER = LoggerFactory.getLogger(DisconfAspectJ.class);
// 
//     @Pointcut(value = "execution(public * *(..))")
//     public void anyPublicMethod() {
//     }
// 
//     /**
//      * 获取配置文件数据, 只有开启disconf远程才会进行切面
//      *
//      * @throws Throwable
//      */
//     @Around("anyPublicMethod() && @annotation(disconfFileItem)")
//     public Object decideAccess(ProceedingJoinPoint pjp, DisconfFileItem disconfFileItem) throws Throwable {
// 
//         if (DisClientConfig.getInstance().ENABLE_DISCONF) {
// 
//             MethodSignature ms = (MethodSignature) pjp.getSignature();
//             Method method = ms.getMethod();
// 
//             //
//             // 文件名
//             //
//             Class<?> cls = method.getDeclaringClass();
//             DisconfFile disconfFile = cls.getAnnotation(DisconfFile.class);
// 
//             //
//             // Field名
//             //
//             Field field = MethodUtils.getFieldFromMethod(method, cls.getDeclaredFields(), DisConfigTypeEnum.FILE);
//             if (field != null) {
// 
//                 //
//                 // 请求仓库配置数据
//                 //
//                 DisconfStoreProcessor disconfStoreProcessor =
//                         DisconfStoreProcessorFactory.getDisconfStoreFileProcessor();
//                 Object ret = disconfStoreProcessor.getConfig(disconfFile.filename(), disconfFileItem.name());
//                 if (ret != null) {
//                     LOGGER.debug("using disconf store value: " + disconfFile.filename() + " ("
//                             + disconfFileItem.name() +
//                             " , " + ret + ")");
//                     return ret;
//                 }
//             }
//         }
// 
//         Object rtnOb;
// 
//         try {
//             // 返回原值
//             rtnOb = pjp.proceed();
//         } catch (Throwable t) {
//             LOGGER.info(t.getMessage());
//             throw t;
//         }
// 
//         return rtnOb;
//     }
// 
//     /**
//      * 获取配置项数据, 只有开启disconf远程才会进行切面
//      *
//      * @throws Throwable
//      */
//     @Around("anyPublicMethod() && @annotation(disconfItem)")
//     public Object decideAccess(ProceedingJoinPoint pjp, DisconfItem disconfItem) throws Throwable {
// 
//         if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//             //
//             // 请求仓库配置数据
//             //
//             DisconfStoreProcessor disconfStoreProcessor = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();
//             Object ret = disconfStoreProcessor.getConfig(null, disconfItem.key());
//             if (ret != null) {
//                 LOGGER.debug("using disconf store value: (" + disconfItem.key() + " , " + ret + ")");
//                 return ret;
//             }
//         }
// 
//         Object rtnOb;
// 
//         try {
//             // 返回原值
//             rtnOb = pjp.proceed();
//         } catch (Throwable t) {
//             LOGGER.info(t.getMessage());
//             throw t;
//         }
// 
//         return rtnOb;
//     }
// }


// Path: disconf-client/src/main/java/com/baidu/disconf/client/DisconfMgrBean.java
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import com.baidu.disconf.client.store.aspect.DisconfAspectJ;
import com.baidu.disconf.client.store.inner.DisconfCenterHostFilesStore;
import com.baidu.disconf.client.support.utils.StringUtil;

        DisconfCenterHostFilesStore.getInstance().addJustHostFileSet(fileList);

        List<String> scanPackList = StringUtil.parseStringToStringList(scanPackage, SCAN_SPLIT_TOKEN);
        // unique
        Set<String> hs = new HashSet<String>();
        hs.addAll(scanPackList);
        scanPackList.clear();
        scanPackList.addAll(hs);

        // 进行扫描
        DisconfMgr.getInstance().setApplicationContext(applicationContext);
        DisconfMgr.getInstance().firstScan(scanPackList);

        // register java bean
        registerAspect(registry);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    /**
     * register aspectJ for disconf get request
     *
     * @param registry
     */
    private void registerAspect(BeanDefinitionRegistry registry) {

        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
        beanDefinition.setBeanClass(DisconfAspectJ.class);