Last active
October 17, 2025 16:51
-
-
Save thomasfenaroli-wf/29edf35fa1826ca6865498ece3f8f528 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class WReflectionsModule extends AbstractModule { | |
| @Override | |
| public void configure() { | |
| bind(Reflections.class).toProvider(WReflectionsProvider.class).in(ImmutableSingleton.class); | |
| } | |
| public static class WReflectionsProvider implements Provider<Reflections> { | |
| private static final Log LOG = getLog(WReflectionsProvider.class); | |
| private static final List<String> PACKAGES_TO_SCAN = List.of("com.kaching", "com.wealthfront"); | |
| @VisibleForTesting | |
| public static final Thunk<Reflections> REFLECTIONS_THUNK = thunk(() -> { | |
| StopWatch stopWatch = LOG.getStopWatch("WReflections construction", Log.Level.INFO); | |
| LOG.info("Pre-instantiation: %s", stopWatch.getElapsedTime()); | |
| FilterBuilder filterBuilder = new FilterBuilder(); | |
| for (String packageToScan : PACKAGES_TO_SCAN) { | |
| filterBuilder.includePackage(packageToScan); | |
| } | |
| Reflections reflections = new Reflections(new ConfigurationBuilder() | |
| .forPackages(PACKAGES_TO_SCAN.toArray(new String[0])) | |
| .setScanners(new MethodAnnotationsScanner(), new FieldAnnotationsScanner(), new SubTypesScanner()) | |
| .filterInputsBy(filterBuilder)); | |
| LOG.info("Post-instantiation: %s", stopWatch.getElapsedTime()); | |
| return reflections; | |
| }); | |
| @Override | |
| public Reflections get() { | |
| return REFLECTIONS_THUNK.get(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment