Skip to content

Commit

Permalink
feat: include load custom repositories
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed May 28, 2024
1 parent 0b34905 commit 5bead43
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ enum ClassGraphClassScanner implements ClassScanner {
logger.fine("Starting scan class to find entities, embeddable and repositories.");
try (ScanResult result = new ClassGraph().enableAllInfo().scan()) {
var notSupportedRepositories = loadNotSupportedRepositories(result);
logger.info("The following repositories are not supported: " + notSupportedRepositories);
this.entities.addAll(loadEntities(result));
this.embeddables.addAll(loadEmbeddable(result));
this.repositories.addAll(loadRepositories(result));
this.customRepositories.addAll(loadCustomRepositories(result));
notSupportedRepositories.forEach(this.repositories::remove);
}
logger.fine(String.format("Finished the class scan with entities %d, embeddables %d and repositories: %d"
Expand Down Expand Up @@ -125,6 +127,13 @@ private static List<Class<DataRepository>> loadRepositories(ScanResult scan) {
.toList();
}

private static List<Class<?>> loadCustomRepositories(ScanResult scan) {
return scan.getClassesWithAnnotation(Repository.class)
.getInterfaces()
.filter(c -> !c.implementsInterface(DataRepository.class))
.loadClasses().stream().toList();
}

@SuppressWarnings("rawtypes")
private static List<Class<DataRepository>> loadNotSupportedRepositories(ScanResult scan) {
return scan.getClassesWithAnnotation(Repository.class)
Expand Down

0 comments on commit 5bead43

Please sign in to comment.