Search in sources :

Example 1 with Element

use of io.micronaut.inject.ast.Element in project micronaut-core by micronaut-projects.

the class TestBeanElementVisitor method visitBeanElement.

@Override
public BeanElement visitBeanElement(BeanElement beanElement, VisitorContext visitorContext) {
    Element producingElement = beanElement.getProducingElement();
    if (producingElement instanceof MemberElement) {
        producingElement = ((MemberElement) producingElement).getDeclaringType();
    }
    final String name = producingElement.getName();
    if (name.startsWith("testbe")) {
        theBeanElement = beanElement;
    }
    if (name.equals("testbe2.Excluded")) {
        // tests bean veto
        return null;
    }
    return beanElement;
}
Also used : Element(io.micronaut.inject.ast.Element) MemberElement(io.micronaut.inject.ast.MemberElement) ConstructorElement(io.micronaut.inject.ast.ConstructorElement) MemberElement(io.micronaut.inject.ast.MemberElement)

Example 2 with Element

use of io.micronaut.inject.ast.Element in project micronaut-core by micronaut-projects.

the class AopProxyWriter method visitAroundMethod.

/**
 * Visit a method that is to be proxied.
 *
 * @param beanType      The bean type.
 * @param methodElement The method element
 */
public void visitAroundMethod(TypedElement beanType, MethodElement methodElement) {
    ClassElement returnType = methodElement.isSuspend() ? ClassElement.of(Object.class) : methodElement.getReturnType();
    Type returnTypeObject = JavaModelUtils.getTypeReference(returnType);
    boolean isPrimitive = returnType.isPrimitive();
    boolean isVoidReturn = isPrimitive && returnTypeObject.equals(Type.VOID_TYPE);
    final Optional<MethodElement> overridden = methodElement.getOwningType().getEnclosedElement(ElementQuery.ALL_METHODS.onlyInstance().named(name -> name.equals(methodElement.getName())).filter(el -> el.overrides(methodElement)));
    if (overridden.isPresent()) {
        MethodElement overriddenBy = overridden.get();
        String methodElementKey = methodElement.getName() + Arrays.stream(methodElement.getSuspendParameters()).map(p -> p.getType().getName()).collect(Collectors.joining(","));
        String overriddenByKey = overriddenBy.getName() + Arrays.stream(methodElement.getSuspendParameters()).map(p -> p.getGenericType().getName()).collect(Collectors.joining(","));
        if (!methodElementKey.equals(overriddenByKey)) {
            buildMethodDelegate(methodElement, overriddenBy, isVoidReturn);
            return;
        }
    }
    String methodName = methodElement.getName();
    List<ParameterElement> argumentTypeList = Arrays.asList(methodElement.getSuspendParameters());
    int argumentCount = argumentTypeList.size();
    final Type declaringTypeReference = JavaModelUtils.getTypeReference(beanType);
    MethodRef methodKey = new MethodRef(methodName, argumentTypeList, returnTypeObject);
    if (!proxiedMethodsRefSet.contains(methodKey)) {
        String interceptedProxyClassName = null;
        String interceptedProxyBridgeMethodName = null;
        if (!isProxyTarget) {
            if (!methodElement.isAbstract() || methodElement.isDefault()) {
                interceptedProxyClassName = proxyFullName;
                interceptedProxyBridgeMethodName = "$$access$$" + methodName;
                String bridgeDesc = getMethodDescriptor(returnType, argumentTypeList);
                // now build a bridge to invoke the original method
                MethodVisitor bridgeWriter = classWriter.visitMethod(ACC_SYNTHETIC, interceptedProxyBridgeMethodName, bridgeDesc, null, null);
                GeneratorAdapter bridgeGenerator = new GeneratorAdapter(bridgeWriter, ACC_SYNTHETIC, interceptedProxyBridgeMethodName, bridgeDesc);
                bridgeGenerator.loadThis();
                for (int i = 0; i < argumentTypeList.size(); i++) {
                    bridgeGenerator.loadArg(i);
                }
                String desc = getMethodDescriptor(returnType, argumentTypeList);
                bridgeWriter.visitMethodInsn(INVOKESPECIAL, declaringTypeReference.getInternalName(), methodName, desc, this.isInterface && methodElement.isDefault());
                pushReturnValue(bridgeWriter, returnType);
                bridgeWriter.visitMaxs(DEFAULT_MAX_STACK, 1);
                bridgeWriter.visitEnd();
            }
        }
        BeanDefinitionWriter beanDefinitionWriter = parentWriter == null ? proxyBeanDefinitionWriter : parentWriter;
        int methodIndex = beanDefinitionWriter.visitExecutableMethod(beanType, methodElement, interceptedProxyClassName, interceptedProxyBridgeMethodName);
        int index = proxyMethodCount++;
        methodKey.methodIndex = methodIndex;
        proxiedMethods.add(methodKey);
        proxiedMethodsRefSet.add(methodKey);
        proxyTargetMethods.add(methodKey);
        buildMethodOverride(returnType, methodName, index, argumentTypeList, argumentCount, isVoidReturn);
    }
}
Also used : ElementQuery(io.micronaut.inject.ast.ElementQuery) Arrays(java.util.Arrays) InterceptedProxy(io.micronaut.aop.InterceptedProxy) MethodVisitor(org.objectweb.asm.MethodVisitor) BeanContext(io.micronaut.context.BeanContext) ArrayUtils(io.micronaut.core.util.ArrayUtils) FieldElement(io.micronaut.inject.ast.FieldElement) DefaultBeanContext(io.micronaut.context.DefaultBeanContext) Type(org.objectweb.asm.Type) ProxyingBeanDefinitionVisitor(io.micronaut.inject.writer.ProxyingBeanDefinitionVisitor) Introduced(io.micronaut.aop.Introduced) MethodInterceptorChain(io.micronaut.aop.chain.MethodInterceptorChain) Map(java.util.Map) BeanResolutionContext(io.micronaut.context.BeanResolutionContext) AbstractClassFileWriter(io.micronaut.inject.writer.AbstractClassFileWriter) HotSwappableInterceptedProxy(io.micronaut.aop.HotSwappableInterceptedProxy) BeanLocator(io.micronaut.context.BeanLocator) ClassVisitor(org.objectweb.asm.ClassVisitor) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) StringUtils(io.micronaut.core.util.StringUtils) List(java.util.List) Interceptor(io.micronaut.aop.Interceptor) AnnotationUtil(io.micronaut.core.annotation.AnnotationUtil) AnnotationValue(io.micronaut.core.annotation.AnnotationValue) ProxyBeanDefinition(io.micronaut.inject.ProxyBeanDefinition) MethodElement(io.micronaut.inject.ast.MethodElement) Optional(java.util.Optional) InterceptorChain(io.micronaut.aop.chain.InterceptorChain) BeanDefinitionWriter(io.micronaut.inject.writer.BeanDefinitionWriter) ConfigurationMetadata(io.micronaut.inject.configuration.ConfigurationMetadata) JavaModelUtils(io.micronaut.inject.processing.JavaModelUtils) ClassWriter(org.objectweb.asm.ClassWriter) BeanRegistration(io.micronaut.context.BeanRegistration) OriginatingElements(io.micronaut.inject.writer.OriginatingElements) Qualifier(io.micronaut.context.Qualifier) Label(org.objectweb.asm.Label) ClassElement(io.micronaut.inject.ast.ClassElement) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Toggleable(io.micronaut.core.util.Toggleable) DefaultAnnotationMetadata(io.micronaut.inject.annotation.DefaultAnnotationMetadata) Constructor(java.lang.reflect.Constructor) ExecutableMethod(io.micronaut.inject.ExecutableMethod) ParameterElement(io.micronaut.inject.ast.ParameterElement) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Method(org.objectweb.asm.commons.Method) GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) TypedElement(io.micronaut.inject.ast.TypedElement) AnnotationMetadataReference(io.micronaut.inject.annotation.AnnotationMetadataReference) ConfigurationReader(io.micronaut.context.annotation.ConfigurationReader) Argument(io.micronaut.core.type.Argument) ClassWriterOutputVisitor(io.micronaut.inject.writer.ClassWriterOutputVisitor) LinkedHashSet(java.util.LinkedHashSet) ExecutableMethodsDefinitionWriter(io.micronaut.inject.writer.ExecutableMethodsDefinitionWriter) OutputStream(java.io.OutputStream) Opcodes(org.objectweb.asm.Opcodes) Element(io.micronaut.inject.ast.Element) Iterator(java.util.Iterator) InterceptedMethodUtil(io.micronaut.aop.internal.intercepted.InterceptedMethodUtil) IOException(java.io.IOException) OptionalValues(io.micronaut.core.value.OptionalValues) ReflectionUtils(io.micronaut.core.reflect.ReflectionUtils) File(java.io.File) InterceptorKind(io.micronaut.aop.InterceptorKind) NonNull(io.micronaut.core.annotation.NonNull) ExecutionHandleLocator(io.micronaut.context.ExecutionHandleLocator) VisitorContext(io.micronaut.inject.visitor.VisitorContext) Lock(java.util.concurrent.locks.Lock) ConfigurationMetadataBuilder(io.micronaut.inject.configuration.ConfigurationMetadataBuilder) BeanDefinitionVisitor(io.micronaut.inject.writer.BeanDefinitionVisitor) AnnotationMetadata(io.micronaut.core.annotation.AnnotationMetadata) BeanDefinition(io.micronaut.inject.BeanDefinition) Collections(java.util.Collections) Intercepted(io.micronaut.aop.Intercepted) MethodElement(io.micronaut.inject.ast.MethodElement) ClassElement(io.micronaut.inject.ast.ClassElement) BeanDefinitionWriter(io.micronaut.inject.writer.BeanDefinitionWriter) MethodVisitor(org.objectweb.asm.MethodVisitor) Type(org.objectweb.asm.Type) GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) ParameterElement(io.micronaut.inject.ast.ParameterElement)

Example 3 with Element

use of io.micronaut.inject.ast.Element in project micronaut-core by micronaut-projects.

the class BeanDefinitionWriter method isInterceptedLifeCycleByType.

private boolean isInterceptedLifeCycleByType(AnnotationMetadata annotationMetadata, String interceptType) {
    return isLifeCycleCache.computeIfAbsent(interceptType, s -> {
        if (this.beanTypeElement.isAssignable("io.micronaut.aop.Interceptor")) {
            // interceptor beans cannot have lifecycle methods intercepted
            return false;
        }
        final Element originatingElement = getOriginatingElements()[0];
        final boolean isFactoryMethod = (originatingElement instanceof MethodElement && !(originatingElement instanceof ConstructorElement));
        final boolean isProxyTarget = annotationMetadata.booleanValue(AnnotationUtil.ANN_AROUND, "proxyTarget").orElse(false) || isFactoryMethod;
        // for beans that are @Around(proxyTarget=false) only the generated AOP impl should be intercepted
        final boolean isAopType = StringUtils.isNotEmpty(interceptedType);
        final boolean isConstructorInterceptionCandidate = (isProxyTarget && !isAopType) || (isAopType && !isProxyTarget);
        final boolean hasAroundConstruct;
        final AnnotationValue<Annotation> interceptorBindings = annotationMetadata.getAnnotation(AnnotationUtil.ANN_INTERCEPTOR_BINDINGS);
        List<AnnotationValue<Annotation>> interceptorBindingAnnotations;
        if (interceptorBindings != null) {
            interceptorBindingAnnotations = interceptorBindings.getAnnotations(AnnotationMetadata.VALUE_MEMBER);
            hasAroundConstruct = interceptorBindingAnnotations.stream().anyMatch(av -> av.stringValue("kind").map(k -> k.equals(interceptType)).orElse(false));
        } else {
            interceptorBindingAnnotations = Collections.emptyList();
            hasAroundConstruct = false;
        }
        if (isConstructorInterceptionCandidate) {
            return hasAroundConstruct;
        } else if (hasAroundConstruct) {
            AnnotationMetadata typeMetadata = annotationMetadata;
            if (!isSuperFactory && typeMetadata instanceof AnnotationMetadataHierarchy) {
                typeMetadata = ((AnnotationMetadataHierarchy) typeMetadata).getRootMetadata();
                final AnnotationValue<Annotation> av = typeMetadata.getAnnotation(AnnotationUtil.ANN_INTERCEPTOR_BINDINGS);
                if (av != null) {
                    interceptorBindingAnnotations = av.getAnnotations(AnnotationMetadata.VALUE_MEMBER);
                } else {
                    interceptorBindingAnnotations = Collections.emptyList();
                }
            }
            // if no other AOP advice is applied
            return interceptorBindingAnnotations.stream().noneMatch(av -> av.stringValue("kind").map(k -> k.equals("AROUND")).orElse(false));
        } else {
            return false;
        }
    });
}
Also used : ConstructorElement(io.micronaut.inject.ast.ConstructorElement) Bindable(io.micronaut.core.bind.annotation.Bindable) Arrays(java.util.Arrays) DefaultBeanContext(io.micronaut.context.DefaultBeanContext) Internal(io.micronaut.core.annotation.Internal) VISITORS(io.micronaut.inject.visitor.BeanElementVisitor.VISITORS) InstantiationUtils(io.micronaut.core.reflect.InstantiationUtils) Duration(java.time.Duration) Map(java.util.Map) PropertyMetadata(io.micronaut.inject.configuration.PropertyMetadata) Property(io.micronaut.context.annotation.Property) AnnotationMetadataWriter(io.micronaut.inject.annotation.AnnotationMetadataWriter) AnnotationMetadataHierarchy(io.micronaut.inject.annotation.AnnotationMetadataHierarchy) Provided(io.micronaut.context.annotation.Provided) Singleton(jakarta.inject.Singleton) Set(java.util.Set) Bean(io.micronaut.context.annotation.Bean) Stream(java.util.stream.Stream) AnnotationValue(io.micronaut.core.annotation.AnnotationValue) ProxyBeanDefinition(io.micronaut.inject.ProxyBeanDefinition) MethodElement(io.micronaut.inject.ast.MethodElement) SignatureVisitor(org.objectweb.asm.signature.SignatureVisitor) EachProperty(io.micronaut.context.annotation.EachProperty) BeanFactory(io.micronaut.inject.BeanFactory) MutableAnnotationMetadata(io.micronaut.inject.annotation.MutableAnnotationMetadata) JavaModelUtils(io.micronaut.inject.processing.JavaModelUtils) ClassWriter(org.objectweb.asm.ClassWriter) BeanRegistration(io.micronaut.context.BeanRegistration) Parameter(io.micronaut.context.annotation.Parameter) AnnotationMetadataProvider(io.micronaut.core.annotation.AnnotationMetadataProvider) AbstractExecutableMethod(io.micronaut.context.AbstractExecutableMethod) Qualifier(io.micronaut.context.Qualifier) Toggleable(io.micronaut.core.util.Toggleable) DefaultAnnotationMetadata(io.micronaut.inject.annotation.DefaultAnnotationMetadata) ConstructorElement(io.micronaut.inject.ast.ConstructorElement) Constructor(java.lang.reflect.Constructor) TreeSet(java.util.TreeSet) ParameterElement(io.micronaut.inject.ast.ParameterElement) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) TypedElement(io.micronaut.inject.ast.TypedElement) ConfigurationProperties(io.micronaut.context.annotation.ConfigurationProperties) AbstractConstructorInjectionPoint(io.micronaut.context.AbstractConstructorInjectionPoint) Nullable(io.micronaut.core.annotation.Nullable) BeanElement(io.micronaut.inject.ast.beans.BeanElement) Argument(io.micronaut.core.type.Argument) IOException(java.io.IOException) VisitorContext(io.micronaut.inject.visitor.VisitorContext) AnnotationValueBuilder(io.micronaut.core.annotation.AnnotationValueBuilder) BeanDefinition(io.micronaut.inject.BeanDefinition) ValidatedBeanDefinition(io.micronaut.inject.ValidatedBeanDefinition) ElementQuery(io.micronaut.inject.ast.ElementQuery) BeanElementVisitor(io.micronaut.inject.visitor.BeanElementVisitor) MethodVisitor(org.objectweb.asm.MethodVisitor) BeanElementVisitorContext(io.micronaut.inject.visitor.BeanElementVisitorContext) BeanContext(io.micronaut.context.BeanContext) ArrayUtils(io.micronaut.core.util.ArrayUtils) FieldElement(io.micronaut.inject.ast.FieldElement) ConfigurationInject(io.micronaut.context.annotation.ConfigurationInject) Type(org.objectweb.asm.Type) ExecutableMethodsDefinition(io.micronaut.inject.ExecutableMethodsDefinition) DefaultScope(io.micronaut.context.annotation.DefaultScope) EachBean(io.micronaut.context.annotation.EachBean) ConfigurationBuilder(io.micronaut.context.annotation.ConfigurationBuilder) Locale(java.util.Locale) BeanResolutionContext(io.micronaut.context.BeanResolutionContext) NameUtils(io.micronaut.core.naming.NameUtils) AbstractInitializableBeanDefinition(io.micronaut.context.AbstractInitializableBeanDefinition) ClassVisitor(org.objectweb.asm.ClassVisitor) Method(java.lang.reflect.Method) AnyQualifier(io.micronaut.inject.qualifiers.AnyQualifier) ClassUtils(io.micronaut.core.reflect.ClassUtils) ConstructorInjectionPoint(io.micronaut.inject.ConstructorInjectionPoint) DefaultArgument(io.micronaut.core.type.DefaultArgument) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Qualifiers(io.micronaut.inject.qualifiers.Qualifiers) Collectors(java.util.stream.Collectors) DisposableBeanDefinition(io.micronaut.inject.DisposableBeanDefinition) StringUtils(io.micronaut.core.util.StringUtils) List(java.util.List) AnnotationUtil(io.micronaut.core.annotation.AnnotationUtil) BeanElementBuilder(io.micronaut.inject.ast.beans.BeanElementBuilder) Annotation(java.lang.annotation.Annotation) Optional(java.util.Optional) NotNull(org.jetbrains.annotations.NotNull) BeanConstructor(io.micronaut.core.beans.BeanConstructor) Label(org.objectweb.asm.Label) ClassElement(io.micronaut.inject.ast.ClassElement) HashMap(java.util.HashMap) PrimitiveElement(io.micronaut.inject.ast.PrimitiveElement) ExecutableMethod(io.micronaut.inject.ExecutableMethod) HashSet(java.util.HashSet) Primary(io.micronaut.context.annotation.Primary) PropertyElement(io.micronaut.inject.ast.PropertyElement) Repeatable(java.lang.annotation.Repeatable) InitializingBeanDefinition(io.micronaut.inject.InitializingBeanDefinition) Any(io.micronaut.context.annotation.Any) ConfigurationReader(io.micronaut.context.annotation.ConfigurationReader) OutputStream(java.io.OutputStream) TypeVariableResolver(io.micronaut.core.type.TypeVariableResolver) Element(io.micronaut.inject.ast.Element) Iterator(java.util.Iterator) AdvisedBeanType(io.micronaut.inject.AdvisedBeanType) Value(io.micronaut.context.annotation.Value) MemberElement(io.micronaut.inject.ast.MemberElement) ReflectionUtils(io.micronaut.core.reflect.ReflectionUtils) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NonNull(io.micronaut.core.annotation.NonNull) ParametrizedBeanFactory(io.micronaut.inject.ParametrizedBeanFactory) PropertySource(io.micronaut.context.annotation.PropertySource) CollectionUtils(io.micronaut.core.util.CollectionUtils) ConfigurationMetadataBuilder(io.micronaut.inject.configuration.ConfigurationMetadataBuilder) InjectScope(io.micronaut.context.annotation.InjectScope) AnnotationMetadata(io.micronaut.core.annotation.AnnotationMetadata) Comparator(java.util.Comparator) Collections(java.util.Collections) MethodElement(io.micronaut.inject.ast.MethodElement) ConstructorElement(io.micronaut.inject.ast.ConstructorElement) ParameterElement(io.micronaut.inject.ast.ParameterElement) TypedElement(io.micronaut.inject.ast.TypedElement) BeanElement(io.micronaut.inject.ast.beans.BeanElement) FieldElement(io.micronaut.inject.ast.FieldElement) ClassElement(io.micronaut.inject.ast.ClassElement) PrimitiveElement(io.micronaut.inject.ast.PrimitiveElement) PropertyElement(io.micronaut.inject.ast.PropertyElement) Element(io.micronaut.inject.ast.Element) MemberElement(io.micronaut.inject.ast.MemberElement) MethodElement(io.micronaut.inject.ast.MethodElement) AnnotationValue(io.micronaut.core.annotation.AnnotationValue) AnnotationMetadataHierarchy(io.micronaut.inject.annotation.AnnotationMetadataHierarchy) Annotation(java.lang.annotation.Annotation) MutableAnnotationMetadata(io.micronaut.inject.annotation.MutableAnnotationMetadata) DefaultAnnotationMetadata(io.micronaut.inject.annotation.DefaultAnnotationMetadata) AnnotationMetadata(io.micronaut.core.annotation.AnnotationMetadata)

Example 4 with Element

use of io.micronaut.inject.ast.Element in project micronaut-core by micronaut-projects.

the class AbstractBeanDefinitionBuilder method build.

/**
 * Build the bean definition writer.
 * @return The writer, possibly null if it wasn't possible to build it
 */
@Nullable
public BeanDefinitionWriter build() {
    if (exposedTypes != null) {
        final AnnotationClassValue[] annotationClassValues = Arrays.stream(exposedTypes).map(ce -> new AnnotationClassValue<>(ce.getName())).toArray(AnnotationClassValue[]::new);
        annotate(Bean.class, (builder) -> builder.member("typed", annotationClassValues));
    }
    final BeanDefinitionWriter beanDefinitionWriter = createBeanDefinitionWriter();
    if (typeArguments != null) {
        beanDefinitionWriter.visitTypeArguments(this.typeArguments);
    }
    if (constructorElement == null) {
        constructorElement = initConstructor(beanType);
    }
    if (constructorElement == null) {
        visitorContext.fail("Cannot create associated bean with no accessible primary constructor. Consider supply the constructor with createWith(..)", originatingElement);
        return null;
    } else {
        beanDefinitionWriter.visitBeanDefinitionConstructor(constructorElement, !constructorElement.isPublic(), visitorContext);
    }
    Map<ClassElement, List<MemberElement>> sortedInjections = new LinkedHashMap<>();
    List<MemberElement> allInjected = new ArrayList<>();
    allInjected.addAll(injectedFields);
    allInjected.addAll(injectedMethods);
    allInjected.sort(SORTER);
    for (MemberElement memberElement : allInjected) {
        final List<MemberElement> list = sortedInjections.computeIfAbsent(memberElement.getDeclaringType(), classElement -> new ArrayList<>());
        list.add(memberElement);
    }
    for (List<MemberElement> members : sortedInjections.values()) {
        members.sort((o1, o2) -> {
            if (o1 instanceof FieldElement && o2 instanceof MethodElement) {
                return 1;
            } else if (o1 instanceof MethodElement && o1 instanceof FieldElement) {
                return -1;
            }
            return 0;
        });
    }
    for (List<MemberElement> list : sortedInjections.values()) {
        for (MemberElement memberElement : list) {
            if (memberElement instanceof FieldElement) {
                InternalBeanElementField ibf = (InternalBeanElementField) memberElement;
                ibf.<InternalBeanElementField>with((element) -> visitField(beanDefinitionWriter, element, element));
            } else {
                InternalBeanElementMethod ibm = (InternalBeanElementMethod) memberElement;
                ibm.<InternalBeanElementMethod>with((element) -> beanDefinitionWriter.visitMethodInjectionPoint(ibm.getDeclaringType(), ibm, ibm.isRequiresReflection(), visitorContext));
            }
        }
    }
    for (BeanMethodElement executableMethod : executableMethods) {
        beanDefinitionWriter.visitExecutableMethod(beanType, executableMethod, visitorContext);
    }
    for (BeanMethodElement postConstructMethod : postConstructMethods) {
        if (postConstructMethod.getDeclaringType().equals(beanType)) {
            beanDefinitionWriter.visitPostConstructMethod(beanType, postConstructMethod, ((InternalBeanElementMethod) postConstructMethod).isRequiresReflection(), visitorContext);
        }
    }
    for (BeanMethodElement preDestroyMethod : preDestroyMethods) {
        if (preDestroyMethod.getDeclaringType().equals(beanType)) {
            beanDefinitionWriter.visitPreDestroyMethod(beanType, preDestroyMethod, ((InternalBeanElementMethod) preDestroyMethod).isRequiresReflection(), visitorContext);
        }
    }
    beanDefinitionWriter.visitBeanDefinitionEnd();
    return beanDefinitionWriter;
}
Also used : ElementQuery(io.micronaut.inject.ast.ElementQuery) Arrays(java.util.Arrays) ArrayUtils(io.micronaut.core.util.ArrayUtils) FieldElement(io.micronaut.inject.ast.FieldElement) BeanFieldElement(io.micronaut.inject.ast.beans.BeanFieldElement) ClassElement(io.micronaut.inject.ast.ClassElement) HashMap(java.util.HashMap) Internal(io.micronaut.core.annotation.Internal) ConstructorElement(io.micronaut.inject.ast.ConstructorElement) BeanMethodElement(io.micronaut.inject.ast.beans.BeanMethodElement) ParameterElement(io.micronaut.inject.ast.ParameterElement) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) PreDestroy(javax.annotation.PreDestroy) ElementFactory(io.micronaut.inject.ast.ElementFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Nullable(io.micronaut.core.annotation.Nullable) Map(java.util.Map) ElementModifier(io.micronaut.inject.ast.ElementModifier) AnnotationClassValue(io.micronaut.core.annotation.AnnotationClassValue) Property(io.micronaut.context.annotation.Property) Element(io.micronaut.inject.ast.Element) Iterator(java.util.Iterator) Predicate(java.util.function.Predicate) Set(java.util.Set) IOException(java.io.IOException) Value(io.micronaut.context.annotation.Value) BeanParameterElement(io.micronaut.inject.ast.beans.BeanParameterElement) MemberElement(io.micronaut.inject.ast.MemberElement) Bean(io.micronaut.context.annotation.Bean) Consumer(java.util.function.Consumer) NonNull(io.micronaut.core.annotation.NonNull) VisitorContext(io.micronaut.inject.visitor.VisitorContext) List(java.util.List) BeanConstructorElement(io.micronaut.inject.ast.beans.BeanConstructorElement) AnnotationValueBuilder(io.micronaut.core.annotation.AnnotationValueBuilder) BeanElementBuilder(io.micronaut.inject.ast.beans.BeanElementBuilder) AnnotationValue(io.micronaut.core.annotation.AnnotationValue) MethodElement(io.micronaut.inject.ast.MethodElement) ConfigurationMetadataBuilder(io.micronaut.inject.configuration.ConfigurationMetadataBuilder) Annotation(java.lang.annotation.Annotation) PostConstruct(javax.annotation.PostConstruct) AnnotationMetadata(io.micronaut.core.annotation.AnnotationMetadata) Comparator(java.util.Comparator) Collections(java.util.Collections) MutableAnnotationMetadata(io.micronaut.inject.annotation.MutableAnnotationMetadata) ArrayList(java.util.ArrayList) FieldElement(io.micronaut.inject.ast.FieldElement) BeanFieldElement(io.micronaut.inject.ast.beans.BeanFieldElement) BeanMethodElement(io.micronaut.inject.ast.beans.BeanMethodElement) MethodElement(io.micronaut.inject.ast.MethodElement) ClassElement(io.micronaut.inject.ast.ClassElement) AnnotationClassValue(io.micronaut.core.annotation.AnnotationClassValue) LinkedHashMap(java.util.LinkedHashMap) BeanMethodElement(io.micronaut.inject.ast.beans.BeanMethodElement) ArrayList(java.util.ArrayList) List(java.util.List) MemberElement(io.micronaut.inject.ast.MemberElement) Nullable(io.micronaut.core.annotation.Nullable)

Aggregations

Element (io.micronaut.inject.ast.Element)4 AnnotationMetadata (io.micronaut.core.annotation.AnnotationMetadata)3 AnnotationValue (io.micronaut.core.annotation.AnnotationValue)3 NonNull (io.micronaut.core.annotation.NonNull)3 ArrayUtils (io.micronaut.core.util.ArrayUtils)3 ClassElement (io.micronaut.inject.ast.ClassElement)3 ElementQuery (io.micronaut.inject.ast.ElementQuery)3 FieldElement (io.micronaut.inject.ast.FieldElement)3 MethodElement (io.micronaut.inject.ast.MethodElement)3 ParameterElement (io.micronaut.inject.ast.ParameterElement)3 ConfigurationMetadataBuilder (io.micronaut.inject.configuration.ConfigurationMetadataBuilder)3 VisitorContext (io.micronaut.inject.visitor.VisitorContext)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Map (java.util.Map)3