By default nothing uses a classpath scanner, and everything relies on SPI.
In certain instances you may want to turn that on (like testing or for jax-rs), to search and find items, and files, referenced in different places across modules.
Classpath scanning takes a large toll on a startup sequence. At times it may happen very frequently for different libraries like jandex, ClassGraph, Faces 2.2 and down, and many others.
This library grants you the ability to filter and configure any classpath (and resource path scanning) items that may want to be excluded.

Configuring the scanner

The scanner is configured through the IGuiceConfigurator Service provider.
module my.new.rest.program {
	provides IGuiceConfigurator with NewStartupConfigurator;
}
Specific settings can be accessed through the configurator during startup sequence.
First IGuiceConfigurator, the IGuicePreStartup
public class NewStartupConfigurator implements IGuiceConfigurator {
public GuiceConfig configure(GuiceConfig config) {
    config.setClasspathScanning(true)
    .setPathScanning(true)
    .setFieldScanning(true)
    .setAnnotationScanning(true)
    .setFieldInfo(true)
    .setMethodInfo(true)
    .setIgnoreFieldVisibility(true)
    .setIgnoreMethodVisibility(true)
    .setVerbose(true);
return config;
    }
}
You can also specify modules, jars (not applicable), paths, and packages to be scanned. This is where the performance and optimization comes in.
By default all the modules included in the library will be scanned.You can configure the modules to be automatically excluded with their dependencies that aren't used using the below.
Either reject or accept list, not both.
setExcludeModulesAndJars(true); //You can enable auto-exclusion with just this
setExcludePackages(false);
setExcludeParentModules(false);
setExcludePaths(true);

setWhiteListPackages(false);
setWhitelistJarsAndModules(false);
setWhitelistPaths(false);
The service providers that build the list that are sent to ClassGraph are as follows.
  • IGuiceScanModuleExclusions
  • IPackageRejectListScanner
  • IPackageContentsScanner
  • IPackageContentsRejectListScanner
  • IPathContentsScanner
  • IGuiceScanModuleInclusions