コード例 #1
0
ファイル: SettingsHandler.java プロジェクト: Saucistophe/libs
  /** @return A list of the settings callbacks. */
  public static Set<Method> getSettingsCallbacks() {
    // Init the search in the root package.
    Reflections reflections = new Reflections("org.saucistophe", new MethodAnnotationsScanner());
    Set<Method> annotatedMethods = reflections.getMethodsAnnotatedWith(SettingsCallback.class);

    return annotatedMethods;
  }
コード例 #2
0
  /** 扫描基本信息 */
  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);

    return scanModel;
  }
コード例 #3
0
 public Loader() {
   Set<Class<?>> classes = getAnnotatedClasses();
   Reflections reflections;
   instances = new HashMap<>(classes.size());
   methods = new HashMap<>();
   for (Class<?> clazz : classes) {
     putInstance(clazz);
     reflections = new Reflections(clazz.getPackage().getName(), new MethodAnnotationsScanner());
     Set<Method> allMethods = reflections.getMethodsAnnotatedWith(Operation.class);
     for (Method method : allMethods) {
       methods.put(getOperationMask(method), method);
     }
   }
   LOGGER.debug("All operations successfully loaded");
 }