private void scanClasses()

in webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java [227:296]


    private void scanClasses(BeanArchiveService.BeanArchiveInformation info,
                             Map<ArchivePath, Node> classes, String classBasePath)
    {
        Set<Class<?>> bdaClasses = beanClassesPerBda.computeIfAbsent(info, k -> new HashSet<>());
        if (info != null && info.getBeanDiscoveryMode() == BeanArchiveService.BeanDiscoveryMode.NONE)
        {
            // this jar should not get scanned at all.
            return;
        }

        for (Map.Entry<ArchivePath, Node> classEntry : classes.entrySet())
        {
            String className = classEntry.getKey().get();

            if (classBasePath != null && className.startsWith(WEB_INF_CLASS_FOLDER))
            {
                className = className.substring(WEB_INF_CLASS_FOLDER.length());
            }

            // cut off leading slashes
            if (className.startsWith("/"))
            {
                className = className.substring(1);
            }

            // cut off ".class"
            className = className.substring(0, className.length() - ".class".length());

            className = className.replace('/', '.');

            Class<?> beanClass = null;
            try
            {
                beanClass = Class.forName(className);
            }
            catch (ClassNotFoundException cnfe)
            {
                throw new RuntimeException("Could not scan class", cnfe);
            }
            catch (NoClassDefFoundError | UnsatisfiedLinkError ce)
            {
                logger.info("Error while loading class - ignoring class " + className + " " + ce.getMessage());
                continue;
            }

            if (info != null && info.isClassExcluded(className))
            {
                continue;
            }
            if (info != null && info.getBeanDiscoveryMode() == BeanArchiveService.BeanDiscoveryMode.ANNOTATED)
            {
                // only classes with a 'Bean Defining Annotation should get included
                boolean hasBeanDefiningAnnotation = false;
                for (Annotation annotation : beanClass.getAnnotations())
                {
                    if (isBeanDefiningAnnotation(annotation))
                    {
                        hasBeanDefiningAnnotation = true;
                        break;
                    }
                }
                if (!hasBeanDefiningAnnotation)
                {
                    continue;
                }
            }

            bdaClasses.add(beanClass);
        }
    }