com.baidu.disconf.client.common.annotations.DisconfFile Java Examples
The following examples show how to use
com.baidu.disconf.client.common.annotations.DisconfFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScanPrinterUtils.java From disconf with Apache License 2.0 | 5 votes |
/** * */ public static void printFile(Set<Class<?>> classdata) { for (Class<?> item : classdata) { LOGGER.info(item.toString()); DisconfFile disconfFile = item.getAnnotation(DisconfFile.class); LOGGER.info("\tfile name: " + disconfFile.filename()); LOGGER.info("\tenv: " + disconfFile.env()); LOGGER.info("\tversion: " + disconfFile.env()); } }
Example #2
Source File: ScanPrinterUtils.java From disconf with Apache License 2.0 | 5 votes |
/** * */ public static void printFile(Set<Class<?>> classdata) { for (Class<?> item : classdata) { LOGGER.info(item.toString()); DisconfFile disconfFile = item.getAnnotation(DisconfFile.class); LOGGER.info("\tfile name: " + disconfFile.filename()); LOGGER.info("\tenv: " + disconfFile.env()); LOGGER.info("\tversion: " + disconfFile.env()); } }
Example #3
Source File: ReflectionScanStatic.java From disconf with Apache License 2.0 | 4 votes |
/** * 扫描基本信息 */ 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; }
Example #4
Source File: DisconfAspectJ.java From disconf with Apache License 2.0 | 4 votes |
/** * 获取配置文件数据, 只有开启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; }
Example #5
Source File: ReflectionScanStatic.java From disconf with Apache License 2.0 | 4 votes |
/** * 扫描基本信息 */ 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; }
Example #6
Source File: DisconfAspectJ.java From disconf with Apache License 2.0 | 4 votes |
/** * 获取配置文件数据, 只有开启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; }
Example #7
Source File: ScanVerify.java From disconf with Apache License 2.0 | 3 votes |
/** * 判断配置文件的类型是否正确 */ public static boolean isDisconfFileTypeRight(DisconfFile disconfFile) { String fileName = disconfFile.filename(); SupportFileTypeEnum supportFileTypeEnum = SupportFileTypeEnum.getByFileName(fileName); if (supportFileTypeEnum == null) { LOGGER.error("now we only support this type of conf: " + disconfFile.toString()); return false; } return true; }
Example #8
Source File: ScanVerify.java From disconf with Apache License 2.0 | 3 votes |
/** * 判断配置文件的类型是否正确 */ public static boolean isDisconfFileTypeRight(DisconfFile disconfFile) { String fileName = disconfFile.filename(); SupportFileTypeEnum supportFileTypeEnum = SupportFileTypeEnum.getByFileName(fileName); if (supportFileTypeEnum == null) { LOGGER.error("now we only support this type of conf: " + disconfFile.toString()); return false; } return true; }