Package io.micronaut.inject.writer
Interface BeanDefinitionVisitor
-
- All Superinterfaces:
OriginatingElements,io.micronaut.core.util.Toggleable
- All Known Subinterfaces:
ProxyingBeanDefinitionVisitor
- All Known Implementing Classes:
BeanDefinitionWriter
public interface BeanDefinitionVisitor extends OriginatingElements, io.micronaut.core.util.Toggleable
Interface forBeanDefinitionVisitorimplementations such asBeanDefinitionWriter.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROXY_SUFFIXThe suffix use for generated AOP intercepted types.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaccept(ClassWriterOutputVisitor visitor)Write the class to output via a visitor that manages output destination.io.micronaut.core.annotation.AnnotationMetadatagetAnnotationMetadata()java.lang.StringgetBeanDefinitionName()java.lang.StringgetBeanDefinitionReferenceClassName()java.lang.StringgetBeanSimpleName()java.lang.StringgetBeanTypeName()java.util.Optional<org.objectweb.asm.Type>getInterceptedType()ElementgetOriginatingElement()java.lang.StringgetPackageName()org.objectweb.asm.TypegetProvidedType()The provided type of the bean.default ClassElement[]getTypeArguments()booleanisInterface()booleanisSingleton()booleanisValidated()default booleanrequiresMethodProcessing()By default, when theBeanContextis started, theBeanDefinition.getExecutableMethods()are not processed by registeredExecutableMethodProcessorinstances unless this method returns true.voidsetInterceptedType(java.lang.String typeName)Sets the name of the intercepted type.voidsetRequiresMethodProcessing(boolean shouldPreProcess)Sets whether theBeanType.requiresMethodProcessing()returns true.voidsetValidated(boolean validated)Make the bean definition as validated by javax.validation.voidvisitAnnotationMemberPropertyInjectionPoint(TypedElement annotationMemberBeanType, java.lang.String annotationMemberProperty, java.lang.String requiredValue, java.lang.String notEqualsValue)Visits an annotation injection point.voidvisitBeanDefinitionConstructor(MethodElement constructor, boolean requiresReflection, VisitorContext visitorContext)Visits the constructor used to create the bean definition.voidvisitBeanDefinitionEnd()Finalize the bean definition to the given output stream.voidvisitBeanDefinitionInterface(java.lang.Class<? extends BeanDefinition> interfaceType)Visit a marker interface on the generated bean definition.voidvisitBeanFactoryField(ClassElement factoryClass, FieldElement factoryField)In the case where the produced class is produced by a factory field annotated withBeanthis method should be called.voidvisitBeanFactoryMethod(ClassElement factoryClass, MethodElement factoryMethod)In the case where the produced class is produced by a factory method annotated withBeanthis method should be called.voidvisitBeanFactoryMethod(ClassElement factoryClass, MethodElement factoryMethod, ParameterElement[] parameters)In the case where the produced class is produced by a factory method annotated withBeanthis method should be called.voidvisitConfigBuilderDurationMethod(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.voidvisitConfigBuilderEnd()Finalize a configuration builder field.voidvisitConfigBuilderField(ClassElement type, java.lang.String field, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder<?> metadataBuilder, boolean isInterface)Begin defining a configuration builder.voidvisitConfigBuilderMethod(ClassElement type, java.lang.String methodName, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder<?> metadataBuilder, boolean isInterface)Begin defining a configuration builder.voidvisitConfigBuilderMethod(java.lang.String prefix, ClassElement returnType, java.lang.String methodName, ClassElement paramType, java.util.Map<java.lang.String,ClassElement> generics, java.lang.String path)Visit a configuration builder method.voidvisitDefaultConstructor(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.intvisitExecutableMethod(TypedElement declaringBean, MethodElement methodElement, VisitorContext visitorContext)Visit a method that is to be made executable allow invocation of said method without reflection.voidvisitFieldInjectionPoint(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection)Visits a field injection point.voidvisitFieldValue(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection, boolean isOptional)Visits a field injection point.voidvisitMethodInjectionPoint(TypedElement beanType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext)Visits a method injection point.voidvisitPostConstructMethod(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext)Visits a method injection point.voidvisitPreDestroyMethod(TypedElement beanType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext)Visits a method injection point.voidvisitSetterValue(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, boolean isOptional)Visits an injection point for a setter.voidvisitSuperBeanDefinition(java.lang.String name)Alter the super class of this bean definition.voidvisitSuperBeanDefinitionFactory(java.lang.String beanName)Alter the super class of this bean definition to use another factory bean.voidvisitTypeArguments(java.util.Map<java.lang.String,java.util.Map<java.lang.String,ClassElement>> typeArguments)Visits the type arguments for the bean.voidwriteTo(java.io.File compilationDir)Write the state of the writer to the given compilation directory.-
Methods inherited from interface io.micronaut.inject.writer.OriginatingElements
addOriginatingElement, getOriginatingElements
-
-
-
-
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
Beanthis method should be called.- Parameters:
factoryClass- The factory classfactoryMethod- 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
Beanthis method should be called.- Parameters:
factoryClass- The factory classfactoryMethod- The factory methodparameters- The parameters
-
visitBeanFactoryField
void visitBeanFactoryField(ClassElement factoryClass, FieldElement factoryField)
In the case where the produced class is produced by a factory field annotated with
Beanthis method should be called.- Parameters:
factoryClass- The factory classfactoryField- 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 constructorrequiresReflection- Whether invoking the constructor requires reflectionvisitorContext- 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 constructorvisitorContext- 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 ofAbstractBeanDefinition.- 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 asgetBeanTypeName(), 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.IOExceptionWrite 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 typemethodElement- The method elementrequiresReflection- Whether the setter requires reflectionisOptional- 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 typemethodElement- The method elementrequiresReflection- Whether the method requires reflectionvisitorContext- 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 methodmethodElement- The method elementrequiresReflection- Whether the method requires reflectionvisitorContext- 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 methodmethodElement- The method elementrequiresReflection- Whether the method requires reflectionvisitorContext- 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 fromMemberElement.getDeclaringType()in the case of the method coming from a super class or interface.methodElement- The method elementvisitorContext- 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 typefieldElement- The field elementrequiresReflection- 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 beanannotationMemberProperty- Required property of the injected beanrequiredValue- Required value of the bean property for the bean to be loadednotEqualsValue- 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 typefieldElement- The field elementrequiresReflection- Whether accessing the field requires reflectionisOptional- 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 builderfield- The name of the field that represents the builderannotationMetadata- The annotation metadata associated with the fieldmetadataBuilder- TheConfigurationMetadataBuilderisInterface- 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 buildermethodName- The name of the method that returns the builderannotationMetadata- The annotation metadata associated with the fieldmetadataBuilder- TheConfigurationMetadataBuilderisInterface- 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 methodreturnType- The return typemethodName- The method nameparamType- The method typegenerics- The generic types of the methodpath- 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 methodreturnType- The return typemethodName- The method namepath- The property path- See Also:
ConfigurationBuilder
-
visitConfigBuilderEnd
void visitConfigBuilderEnd()
Finalize a configuration builder field.- See Also:
ConfigurationBuilder
-
requiresMethodProcessing
default boolean requiresMethodProcessing()
By default, when theBeanContextis started, theBeanDefinition.getExecutableMethods()are not processed by registeredExecutableMethodProcessorinstances unless this method returns true.- Returns:
- Whether the bean definition requires method processing
- See Also:
Executable.processOnStartup()
-
setRequiresMethodProcessing
void setRequiresMethodProcessing(boolean shouldPreProcess)
Sets whether theBeanType.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
-
-