11package it .aboutbits .springboot .toolbox .boot .type ;
22
3+ import it .aboutbits .springboot .toolbox .reflection .util .ClassScannerUtil ;
34import it .aboutbits .springboot .toolbox .type .CustomType ;
45import it .aboutbits .springboot .toolbox .type .jackson .CustomTypeDeserializer ;
56import it .aboutbits .springboot .toolbox .type .jackson .CustomTypeSerializer ;
67import it .aboutbits .springboot .toolbox .type .mvc .CustomTypePropertyEditor ;
78import jakarta .annotation .PostConstruct ;
89import lombok .extern .slf4j .Slf4j ;
9- import org .reflections .Reflections ;
10- import org .reflections .util .ConfigurationBuilder ;
1110import org .springframework .boot .autoconfigure .jackson .Jackson2ObjectMapperBuilderCustomizer ;
1211import org .springframework .context .annotation .Bean ;
1312import org .springframework .context .annotation .Configuration ;
@@ -26,7 +25,7 @@ public class CustomTypeConfiguration {
2625 public static final String LIBRARY_BASE_PACKAGE_NAME = "it.aboutbits.springboot.toolbox" ;
2726
2827 private String [] packageNamesToScan ;
29- private Reflections reflections ;
28+ private ClassScannerUtil . ClassScanner classScanner ;
3029
3130 public void setAdditionalTypePackages (String [] additionalTypePackages ) {
3231 var tmp = new ArrayList <String >();
@@ -35,8 +34,7 @@ public void setAdditionalTypePackages(String[] additionalTypePackages) {
3534
3635 this .packageNamesToScan = tmp .toArray (new String [0 ]);
3736
38- var packageToScan = new ConfigurationBuilder ().forPackages (packageNamesToScan );
39- reflections = new Reflections (packageToScan );
37+ classScanner = ClassScannerUtil .getScannerForPackages (packageNamesToScan );
4038 }
4139
4240 @ PostConstruct
@@ -64,6 +62,7 @@ public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
6462 .toList ()
6563 .toArray (new CustomTypeDeserializer [types .size ()]);
6664
65+ classScanner .close ();
6766
6867 return builder -> builder
6968 .serializers (new CustomTypeSerializer ())
@@ -72,7 +71,7 @@ public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
7271
7372 @ SuppressWarnings ("rawtypes" )
7473 private Set <Class <? extends CustomType >> findAllCustomTypeRecords () {
75- return reflections .getSubTypesOf (CustomType .class ).stream ()
74+ return classScanner .getSubTypesOf (CustomType .class ).stream ()
7675 .filter (Record .class ::isAssignableFrom )
7776 .collect (Collectors .toSet ());
7877 }
0 commit comments