/** * Lazy initializer for scanSpec. (This is lazy so that you have a chance to call verbose() before the ScanSpec * constructor tries to log something.) */ private synchronized ScanSpec getScanSpec() { if (scanSpec == null) { scanSpec = new ScanSpec(scanSpecArgs, log == null ? null : log.log("Parsing scan spec")); } return scanSpec; }
@Override public void processScanResult(final ScanResult scanResult) { // Call MatchProcessors after scan has completed getScanSpec().callMatchProcessors(scanResult); // Free temporary files if necessary if (scanSpec.removeTemporaryFilesAfterScan) { scanResult.freeTempFiles(log); } } } : null, /* failureHandler = */ null);
addClassMatcher(new ClassMatchProcessorWrapper() { @Override public void lookForMatches(final ScanResult scanResult, final LogNode log) {
/** * Calls the provided ClassAnnotationMatchProcessor if classes are found on the classpath that have the * specified annotation. * * @param annotation * The class annotation to match. * @param classAnnotationMatchProcessor * the ClassAnnotationMatchProcessor to call when a match is found. * @return this (for method chaining). */ public FastClasspathScanner matchClassesWithAnnotation(final Class<?> annotation, final ClassAnnotationMatchProcessor classAnnotationMatchProcessor) { getScanSpec().matchClassesWithAnnotation(annotation, classAnnotationMatchProcessor); return this; }
/** * Calls the provided MethodAnnotationMatchProcessor if classes are found on the classpath that have one or more * methods with the specified annotation. * * <p> * Calls enableMethodAnnotationIndexing() for you. * * @param annotation * The method annotation to match. * @param methodAnnotationMatchProcessor * the MethodAnnotationMatchProcessor to call when a match is found. * @return this (for method chaining). */ public FastClasspathScanner matchClassesWithMethodAnnotation(final Class<? extends Annotation> annotation, final MethodAnnotationMatchProcessor methodAnnotationMatchProcessor) { enableMethodAnnotationIndexing(); getScanSpec().matchClassesWithMethodAnnotation(annotation, methodAnnotationMatchProcessor); return this; }
if (!scanSpec.blacklistSystemJars() || !scanSpec.whitelistedLibOrExtJarPaths.isEmpty()) { final List<String> jreJarPaths = JarUtils.getJreJarPaths(); if (log != null) { .getAllClassLoaderHandlerRegistryEntries(); if (classpathFinderLog != null) { final LogNode classLoaderHandlerLog = classpathFinderLog.log("ClassLoaderHandlers:"); new ArrayList<>(); for (final ClassLoader envClassLoader : classLoaders) { if (!scanSpec.blacklistSystemJars() || !envClassLoader.getClass().getName().startsWith("sun.misc.Launcher$ExtClassLoader")) { findClassLoaderHandlerForClassLoaderAndParents(scanSpec, envClassLoader,
/** Returns true if a jarfile is whitelisted and not blacklisted. */ boolean jarIsWhitelisted(final String jarName) { final String jarLeafName = JarUtils.leafName(jarName); return ((whitelistedJars.isEmpty() && whitelistedJarPatterns.isEmpty()) || containsJarName(whitelistedJars, whitelistedJarPatterns, jarLeafName)) && !containsJarName(blacklistedJars, blacklistedJarPatterns, jarLeafName); }
final String className = fullyQualifiedFieldName.substring(0, lastDotIdx); final String fieldName = fullyQualifiedFieldName.substring(lastDotIdx + 1); addStaticFinalFieldProcessor(className, fieldName, staticFinalFieldMatchProcessor);
/** * Add a ClassLoader to the list of ClassLoaders to scan. * * <p> * This call is ignored if overrideClasspath() is also called, or if this method is called before * overrideClassLoaders(). * * <p> * This call is ignored if overrideClasspath() is called. * * @param classLoader * The additional ClassLoader to scan. * @return this (for method chaining). */ public FastClasspathScanner addClassLoader(final ClassLoader classLoader) { getScanSpec().addClassLoader(classLoader); return this; }
|| includeAnnotations && classInfo.isAnnotation()) { final boolean isBlacklisted = scanSpec.classIsBlacklisted(classInfo.className); final boolean isSystemClass = JarUtils.isInSystemPackageOrModule(classInfo.className); final boolean includeExternalClasses = scanSpec.enableExternalClasses
if (scanSpec.blacklistSystemJars() && JarUtils.isJREJar(canonicalPath, scanSpec.whitelistedLibOrExtJarPaths, scanSpec.blacklistedLibOrExtJarPaths, log)) {
@Override public void process(ScanSpec spec, AutumnContext context) { spec.matchClassesWithAnnotation(Component.class, cls -> { Component anno = cls.getAnnotation(Component.class); String name = anno.value(); if (name.isEmpty()) { name = cls.getSimpleName().toLowerCase(); } context.addBeanInfo(BeanInfo.builder() .name(name) .type(cls) .singleton(anno.singleton()) .creator(new NormalBeanCreator(cls)) .build()); }); } }
@Override public void process(ScanSpec spec, AutumnContext context) { spec.matchClassesWithMethodAnnotation(BeanFactory.class, (cls, executable) -> { if (executable instanceof Method && executable.getParameterCount() == 0) { Method method = ((Method) executable); BeanFactory anno = method.getAnnotation(BeanFactory.class); String name = anno.value(); if (name.isEmpty()) { name = method.getName().toLowerCase(); } context.addBeanInfo(BeanInfo.builder() .name(name) .type(method.getReturnType()) .singleton(anno.singleton()) .creator(new BeanFactoryCreator(context, method)) .build()); } }); } }
public static void processSpec(ScanSpec spec) { spec.callMatchProcessors(getScanResult()); } }
addClassMatcher(new ClassMatchProcessorWrapper() { @Override public void lookForMatches(final ScanResult scanResult, final LogNode log) {
public synchronized void scanComponents(String... specArgs) { if (scanned) { return; } ScanSpec spec = new ScanSpec(specArgs, null); BeanScanners.processAll(spec, this); log.info(formatLog("scanning components with spec {}"), Arrays.toString(specArgs)); AutumnClasspathScan.processSpec(spec); scanned = true; }
@Override public void processScanResult(final ScanResult scanResult) { // Call any MatchProcessors after scan has completed getScanSpec().callMatchProcessors(scanResult); // Call the provided ScanResultProcessor scanResultProcessor.processScanResult(scanResult); // Free temporary files if necessary if (scanSpec.removeTemporaryFilesAfterScan) { scanResult.freeTempFiles(log); } } }, failureHandler);
addClassMatcher(new ClassMatchProcessorWrapper() { @Override public void lookForMatches(final ScanResult scanResult, final LogNode log) {
getScanSpec().callMatchProcessors(scanResult);
addClassMatcher(new ClassMatchProcessorWrapper() { @Override public void lookForMatches(final ScanResult scanResult, final LogNode log) {