Interface BeanDefinitionVisitor

All Superinterfaces:
OriginatingElements, Toggleable
All Known Subinterfaces:
ProxyingBeanDefinitionVisitor
All Known Implementing Classes:
AopProxyWriter, BeanDefinitionWriter

public interface BeanDefinitionVisitor extends OriginatingElements, Toggleable
Interface for BeanDefinitionVisitor implementations such as BeanDefinitionWriter.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

  • Method Details

    • 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(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
    • getTypeArgumentMap

      @NonNull Map<String,ClassElement> getTypeArgumentMap()
      Returns:
      A map of the type arguments for the bean.
    • getBeanDefinitionReferenceClassName

      @NonNull 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(Class<? extends BeanDefinition> interfaceType)
      Visit a marker interface on the generated bean definition.
      Parameters:
      interfaceType - The interface type
    • visitSuperBeanDefinition

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

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

      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(String typeName)
      Sets the name of the intercepted type.
      Parameters:
      typeName - The type name
    • getInterceptedType

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

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

      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(File compilationDir) throws IOException
      Write the state of the writer to the given compilation directory.
      Parameters:
      compilationDir - The compilation directory
      Throws:
      IOException - If an I/O error occurs
    • accept

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

      void visitSetterValue(TypedElement declaringType, MethodElement methodElement, AnnotationMetadata annotationMetadata, boolean requiresReflection, boolean isOptional)
      Visits an injection point for a setter.
      Parameters:
      declaringType - The declaring type
      methodElement - The method element
      annotationMetadata - The annotationMetadata
      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, VisitorContext visitorContext)
      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
      visitorContext - The visitor context
    • visitAnnotationMemberPropertyInjectionPoint

      void visitAnnotationMemberPropertyInjectionPoint(TypedElement annotationMemberBeanType, String annotationMemberProperty, @Nullable String requiredValue, @Nullable 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

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

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

      AnnotationMetadata getAnnotationMetadata()
      Returns:
      The annotation metadata
    • visitConfigBuilderField

      void visitConfigBuilderField(ClassElement type, String field, 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:
    • visitConfigBuilderMethod

      void visitConfigBuilderMethod(ClassElement type, String methodName, 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:
    • visitConfigBuilderMethod

      void visitConfigBuilderMethod(String propertyName, ClassElement returnType, String methodName, @Nullable ClassElement paramType, Map<String,ClassElement> generics, String path)
      Visit a configuration builder method.
      Parameters:
      propertyName - The property name
      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:
    • visitConfigBuilderDurationMethod

      void visitConfigBuilderDurationMethod(String propertyName, ClassElement returnType, String methodName, String path)
      Visit a configuration builder method that accepts a long and a TimeUnit.
      Parameters:
      propertyName - The property name
      returnType - The return type
      methodName - The method name
      path - The property path
      See Also:
    • visitConfigBuilderEnd

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

      default boolean requiresMethodProcessing()
      By default, when the BeanContext is started, the BeanDefinition.getExecutableMethods() are not processed by registered ExecutableMethodProcessor instances unless this method returns true.
      Returns:
      Whether the bean definition requires method processing
      See Also:
    • setRequiresMethodProcessing

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

      void visitTypeArguments(Map<String,Map<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
    • isProxiedBean

      default boolean isProxiedBean()
      Returns whether another bean exists that proxies this bean. In other words this bean is the target of a proxy.
      Returns:
      Is the reference a proxy target.
      Since:
      4.0.0
    • isProxyTarget

      boolean isProxyTarget()
      Returns whether another bean is a proxy target that needs to be retained.
      Returns:
      Is the reference a proxy target.
      Since:
      4.0.0