All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.zhengframework.mybatis.PackageScanMapperClassProvider Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.github.zhengframework.mybatis;

import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfoList;
import io.github.classgraph.ScanResult;
import java.util.Collection;
import java.util.List;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class PackageScanMapperClassProvider implements MapperClassProvider {

  private final String[] packages;

  public PackageScanMapperClassProvider(String... packages) {
    this.packages = packages;
  }

  @Override
  public Collection> get() {
    ScanResult scanResult = new ClassGraph()
        .whitelistPackages(packages)
        .enableClassInfo()
        .scan();
    ClassInfoList allClasses = scanResult.getAllClasses();

    List> loadClasses = allClasses.loadClasses();
    log.info("managedClasses={}", loadClasses);
    return loadClasses;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy