public Set buildInjectionPoints()

in webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java [66:128]


    public <X> Set<InjectionPoint> buildInjectionPoints(Bean<X> owner, AnnotatedType<X> annotatedType)
    {
        Set<InjectionPoint> injectionPoints = new HashSet<>();
        boolean constructorFound = false;
        for (AnnotatedConstructor<X> constructor: annotatedType.getConstructors())
        {
            if (constructor.isAnnotationPresent(Inject.class))
            {
                if (constructorFound)
                {
                    throw new WebBeansConfigurationException("There are more than one constructor with @Inject annotation in annotation type : "
                            + annotatedType);
                }
                constructorFound = true;
                validateInitializerConstructor(constructor);
                buildInjectionPoints(owner, constructor, injectionPoints);
            }
        }
        if (!constructorFound)
        {
            final AnnotatedConstructor<X>[] cons = annotatedType.getConstructors().stream()
                    .filter(constructor -> constructor.getParameters().stream().anyMatch(service::hasInjection))
                    .toArray(AnnotatedConstructor[]::new);
            switch (cons.length)
            {
                case 0:
                    break;
                case 1:
                {
                    validateInitializerConstructor(cons[0]);
                    buildInjectionPoints(owner, cons[0], injectionPoints);
                    break;
                }
                default:
                    throw new WebBeansConfigurationException(
                            "There are more than one candidate constructor for injection in : " + annotatedType);
            }
        }
        for (AnnotatedField<? super X> field: annotatedType.getFields())
        {
            if (owner != null && Modifier.isPublic(field.getJavaMember().getModifiers()) && !field.isStatic())
            {
                if (webBeansContext.getBeanManagerImpl().isNormalScope(owner.getScope()))
                {
                    throw new WebBeansConfigurationException("If bean has a public field, bean scope must be defined as @Scope. Bean is : "
                            + owner.getBeanClass().getName());
                }
            }                
            if (service.hasInjection(field))
            {
                injectionPoints.add(buildInjectionPoint(owner, field));
            }
        }
        for (AnnotatedMethod<? super X> method: webBeansContext.getAnnotatedElementFactory().getFilteredAnnotatedMethods(annotatedType))
        {
            if (!Modifier.isStatic(method.getJavaMember().getModifiers()) && service.hasInjection(method))
            {
                validateInitializerMethod(method);
                buildInjectionPoints(owner, method, injectionPoints);
            }
        }
        return injectionPoints;
    }