Interface BeanDefinitionVisitor

    • Field Detail

      • PROXY_SUFFIX

        static final java.lang.String PROXY_SUFFIX
        The suffix use for generated AOP intercepted types.
        See Also:
        Constant Field Values
    • Method Detail

      • getOriginatingElement

        @Nullable
        Element getOriginatingElement()
        Returns:
        The element where the bean definition originated from.
      • visitBeanFactoryMethod

        void visitBeanFactoryMethod​(ClassElement factoryClass,
                                    MethodElement factoryMethod)

        In the case where the produced class is produced by a factory method annotated with Bean this method should be called.

        Parameters:
        factoryClass - The factory class
        factoryMethod - The factory method
      • visitBeanFactoryMethod

        void visitBeanFactoryMethod​(ClassElement factoryClass,
                                    MethodElement factoryMethod,
                                    ParameterElement[] parameters)

        In the case where the produced class is produced by a factory method annotated with Bean this method should be called.

        Parameters:
        factoryClass - The factory class
        factoryMethod - The factory method
        parameters - The parameters
      • visitBeanFactoryField

        void visitBeanFactoryField​(ClassElement factoryClass,
                                   FieldElement factoryField)

        In the case where the produced class is produced by a factory field annotated with Bean this method should be called.

        Parameters:
        factoryClass - The factory class
        factoryField - The factory field
      • visitBeanDefinitionConstructor

        void visitBeanDefinitionConstructor​(MethodElement constructor,
                                            boolean requiresReflection,
                                            VisitorContext visitorContext)
        Visits the constructor used to create the bean definition.
        Parameters:
        constructor - The method element that represents the constructor
        requiresReflection - Whether invoking the constructor requires reflection
        visitorContext - The visitor context
      • visitDefaultConstructor

        void visitDefaultConstructor​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                     VisitorContext visitorContext)
        Visits the constructor used to create the bean definition in the case where no constructor is present. This method should only be called in the class defines no constructor.
        Parameters:
        annotationMetadata - The annotation metadata for the constructor
        visitorContext - The visitor context
      • getBeanDefinitionReferenceClassName

        @NonNull
        java.lang.String getBeanDefinitionReferenceClassName()
        Returns:
        The name of the bean definition reference class.
      • isInterface

        boolean isInterface()
        Returns:
        Whether the provided type an interface
      • isSingleton

        boolean isSingleton()
        Returns:
        Is the bean singleton
      • visitBeanDefinitionInterface

        void visitBeanDefinitionInterface​(java.lang.Class<? extends BeanDefinition> interfaceType)
        Visit a marker interface on the generated bean definition.
        Parameters:
        interfaceType - The interface type
      • visitSuperBeanDefinition

        void visitSuperBeanDefinition​(java.lang.String name)
        Alter the super class of this bean definition. The passed class should be a subclass of AbstractBeanDefinition.
        Parameters:
        name - The super type
      • visitSuperBeanDefinitionFactory

        void visitSuperBeanDefinitionFactory​(java.lang.String beanName)
        Alter the super class of this bean definition to use another factory bean.
        Parameters:
        beanName - The bean name
      • getBeanTypeName

        java.lang.String getBeanTypeName()
        Returns:
        The full class name of the bean
      • getProvidedType

        org.objectweb.asm.Type getProvidedType()
        The provided type of the bean. Usually this is the same as getBeanTypeName(), except in the case of factory beans which produce a different type.
        Returns:
        The provided type
      • setValidated

        void setValidated​(boolean validated)
        Make the bean definition as validated by javax.validation.
        Parameters:
        validated - Whether the bean definition is validated
      • setInterceptedType

        void setInterceptedType​(java.lang.String typeName)
        Sets the name of the intercepted type.
        Parameters:
        typeName - The type name
      • getInterceptedType

        java.util.Optional<org.objectweb.asm.Type> getInterceptedType()
        Returns:
        The intercepted type
      • isValidated

        boolean isValidated()
        Returns:
        Return whether the bean definition is validated.
      • getBeanDefinitionName

        java.lang.String getBeanDefinitionName()
        Returns:
        The name of the bean definition class
      • visitBeanDefinitionEnd

        void visitBeanDefinitionEnd()
        Finalize the bean definition to the given output stream.
      • writeTo

        void writeTo​(java.io.File compilationDir)
              throws java.io.IOException
        Write the state of the writer to the given compilation directory.
        Parameters:
        compilationDir - The compilation directory
        Throws:
        java.io.IOException - If an I/O error occurs
      • accept

        void accept​(ClassWriterOutputVisitor visitor)
             throws java.io.IOException
        Write the class to output via a visitor that manages output destination.
        Parameters:
        visitor - the writer output visitor
        Throws:
        java.io.IOException - If an error occurs
      • visitSetterValue

        void visitSetterValue​(TypedElement declaringType,
                              MethodElement methodElement,
                              boolean requiresReflection,
                              boolean isOptional)
        Visits an injection point for a setter.
        Parameters:
        declaringType - The declaring type
        methodElement - The method element
        requiresReflection - Whether the setter requires reflection
        isOptional - Whether the setter is optional
      • visitPostConstructMethod

        void visitPostConstructMethod​(TypedElement declaringType,
                                      MethodElement methodElement,
                                      boolean requiresReflection,
                                      VisitorContext visitorContext)
        Visits a method injection point.
        Parameters:
        declaringType - The declaring type of the method. Either a Class or a string representing the name of the type
        methodElement - The method element
        requiresReflection - Whether the method requires reflection
        visitorContext - The visitor context
      • visitPreDestroyMethod

        void visitPreDestroyMethod​(TypedElement beanType,
                                   MethodElement methodElement,
                                   boolean requiresReflection,
                                   VisitorContext visitorContext)
        Visits a method injection point.
        Parameters:
        beanType - The bean type of the method
        methodElement - The method element
        requiresReflection - Whether the method requires reflection
        visitorContext - The visitor context
      • visitMethodInjectionPoint

        void visitMethodInjectionPoint​(TypedElement beanType,
                                       MethodElement methodElement,
                                       boolean requiresReflection,
                                       VisitorContext visitorContext)
        Visits a method injection point.
        Parameters:
        beanType - The bean type of the method
        methodElement - The method element
        requiresReflection - Whether the method requires reflection
        visitorContext - The visitor context
      • visitExecutableMethod

        int visitExecutableMethod​(TypedElement declaringBean,
                                  MethodElement methodElement,
                                  VisitorContext visitorContext)
        Visit a method that is to be made executable allow invocation of said method without reflection.
        Parameters:
        declaringBean - The declaring bean of the method. Note this may differ from MemberElement.getDeclaringType() in the case of the method coming from a super class or interface.
        methodElement - The method element
        visitorContext - The visitor context
        Returns:
        The index of a new method
      • visitFieldInjectionPoint

        void visitFieldInjectionPoint​(TypedElement declaringType,
                                      FieldElement fieldElement,
                                      boolean requiresReflection)
        Visits a field injection point.
        Parameters:
        declaringType - The declaring type. Either a Class or a string representing the name of the type
        fieldElement - The field element
        requiresReflection - Whether accessing the field requires reflection
      • visitAnnotationMemberPropertyInjectionPoint

        void visitAnnotationMemberPropertyInjectionPoint​(TypedElement annotationMemberBeanType,
                                                         java.lang.String annotationMemberProperty,
                                                         @Nullable
                                                         java.lang.String requiredValue,
                                                         @Nullable
                                                         java.lang.String notEqualsValue)
        Visits an annotation injection point.
        Parameters:
        annotationMemberBeanType - The type of the injected bean
        annotationMemberProperty - Required property of the injected bean
        requiredValue - Required value of the bean property for the bean to be loaded
        notEqualsValue - The bean property value which should not be equal to present value for the bean to be loaded
      • visitFieldValue

        void visitFieldValue​(TypedElement declaringType,
                             FieldElement fieldElement,
                             boolean requiresReflection,
                             boolean isOptional)
        Visits a field injection point.
        Parameters:
        declaringType - The declaring type. Either a Class or a string representing the name of the type
        fieldElement - The field element
        requiresReflection - Whether accessing the field requires reflection
        isOptional - Is the value optional
      • getPackageName

        java.lang.String getPackageName()
        Returns:
        The package name of the bean
      • getBeanSimpleName

        java.lang.String getBeanSimpleName()
        Returns:
        The short name of the bean
      • getAnnotationMetadata

        io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata()
        Returns:
        The annotation metadata
      • visitConfigBuilderField

        void visitConfigBuilderField​(ClassElement type,
                                     java.lang.String field,
                                     io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                     ConfigurationMetadataBuilder<?> metadataBuilder,
                                     boolean isInterface)
        Begin defining a configuration builder.
        Parameters:
        type - The type of the builder
        field - The name of the field that represents the builder
        annotationMetadata - The annotation metadata associated with the field
        metadataBuilder - The ConfigurationMetadataBuilder
        isInterface - Whether the builder type is an interface or not
        See Also:
        ConfigurationBuilder
      • visitConfigBuilderMethod

        void visitConfigBuilderMethod​(ClassElement type,
                                      java.lang.String methodName,
                                      io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                      ConfigurationMetadataBuilder<?> metadataBuilder,
                                      boolean isInterface)
        Begin defining a configuration builder.
        Parameters:
        type - The type of the builder
        methodName - The name of the method that returns the builder
        annotationMetadata - The annotation metadata associated with the field
        metadataBuilder - The ConfigurationMetadataBuilder
        isInterface - Whether the builder type is an interface or not
        See Also:
        ConfigurationBuilder
      • visitConfigBuilderMethod

        void visitConfigBuilderMethod​(java.lang.String prefix,
                                      ClassElement returnType,
                                      java.lang.String methodName,
                                      @Nullable
                                      ClassElement paramType,
                                      java.util.Map<java.lang.String,​ClassElement> generics,
                                      java.lang.String path)
        Visit a configuration builder method.
        Parameters:
        prefix - The prefix used for the method
        returnType - The return type
        methodName - The method name
        paramType - The method type
        generics - The generic types of the method
        path - The property path
        See Also:
        ConfigurationBuilder
      • visitConfigBuilderDurationMethod

        void visitConfigBuilderDurationMethod​(java.lang.String prefix,
                                              ClassElement returnType,
                                              java.lang.String methodName,
                                              java.lang.String path)
        Visit a configuration builder method that accepts a long and a TimeUnit.
        Parameters:
        prefix - The prefix used for the method
        returnType - The return type
        methodName - The method name
        path - The property path
        See Also:
        ConfigurationBuilder
      • visitConfigBuilderEnd

        void visitConfigBuilderEnd()
        Finalize a configuration builder field.
        See Also:
        ConfigurationBuilder
      • setRequiresMethodProcessing

        void setRequiresMethodProcessing​(boolean shouldPreProcess)
        Sets whether the BeanType.requiresMethodProcessing() returns true.
        Parameters:
        shouldPreProcess - True if they should be pre-processed
      • visitTypeArguments

        void visitTypeArguments​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​ClassElement>> typeArguments)
        Visits the type arguments for the bean.
        Parameters:
        typeArguments - The type arguments
      • getTypeArguments

        @NonNull
        default ClassElement[] getTypeArguments()
        Returns:
        The generic type arguments for the bean type.
        Since:
        3.0.0