Package io.micronaut.inject.writer
Interface BeanDefinitionVisitor
- All Superinterfaces:
OriginatingElements,Toggleable
- All Known Subinterfaces:
ProxyingBeanDefinitionVisitor
- All Known Implementing Classes:
AopProxyWriter,BeanDefinitionWriter
Interface for
BeanDefinitionVisitor implementations such as BeanDefinitionWriter.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe suffix use for generated AOP intercepted types. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(ClassWriterOutputVisitor visitor) Write the class to output via a visitor that manages output destination.default @NonNull ClassElement[]booleandefault booleanReturns whether another bean exists that proxies this bean.booleanReturns whether another bean is a proxy target that needs to be retained.booleanbooleandefault booleanBy default, when theBeanContextis started, theBeanDefinition.getExecutableMethods()are not processed by registeredExecutableMethodProcessorinstances unless this method returns true.voidsetInterceptedType(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 jakarta.validation.voidvisitAnnotationMemberPropertyInjectionPoint(TypedElement annotationMemberBeanType, String annotationMemberProperty, @Nullable String requiredValue, @Nullable String notEqualsValue) Visits an annotation injection point.voidvisitBeanDefinitionConstructor(MethodElement constructor, boolean requiresReflection, VisitorContext visitorContext) Visits the constructor used to create the bean definition.voidFinalize the bean definition to the given output stream.voidvisitBeanDefinitionInterface(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(String propertyName, ClassElement returnType, String methodName, String path) Visit a configuration builder method that accepts a long and a TimeUnit.voidFinalize a configuration builder field.voidvisitConfigBuilderField(ClassElement type, String field, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface) Begin defining a configuration builder.voidvisitConfigBuilderMethod(ClassElement type, String methodName, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface) Begin defining a configuration builder.voidvisitConfigBuilderMethod(String propertyName, ClassElement returnType, String methodName, @Nullable ClassElement paramType, Map<String, ClassElement> generics, String path) Visit a configuration builder method.voidvisitDefaultConstructor(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, VisitorContext visitorContext) 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, AnnotationMetadata annotationMetadata, boolean requiresReflection, boolean isOptional) Visits an injection point for a setter.voidAlter the super class of this bean definition.voidvisitSuperBeanDefinitionFactory(String beanName) Alter the super class of this bean definition to use another factory bean.voidvisitTypeArguments(Map<String, Map<String, ClassElement>> typeArguments) Visits the type arguments for the bean.default voidWrite the state of the writer to the given compilation directory.Methods inherited from interface io.micronaut.inject.writer.OriginatingElements
addOriginatingElement, getOriginatingElementsMethods inherited from interface io.micronaut.core.util.Toggleable
isEnabled
-
Field Details
-
PROXY_SUFFIX
The suffix use for generated AOP intercepted types.- See Also:
-
-
Method Details
-
getOriginatingElement
- Returns:
- The element where the bean definition originated from.
-
visitBeanFactoryMethod
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
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
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
-
getTypeArgumentMap
- Returns:
- A map of the type arguments for the bean.
-
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
Visit a marker interface on the generated bean definition.- Parameters:
interfaceType- The interface type
-
visitSuperBeanDefinition
Alter the super class of this bean definition. The passed class should be a subclass ofAbstractInitializableBeanDefinition.- Parameters:
name- The super type
-
visitSuperBeanDefinitionFactory
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
-
setValidated
void setValidated(boolean validated) Make the bean definition as validated by jakarta.validation.- Parameters:
validated- Whether the bean definition is validated
-
setInterceptedType
Sets the name of the intercepted type.- Parameters:
typeName- The type name
-
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
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
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 typemethodElement- The method elementannotationMetadata- The annotationMetadatarequiresReflection- 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, VisitorContext visitorContext) 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 reflectionvisitorContext- The visitor context
-
visitAnnotationMemberPropertyInjectionPoint
void visitAnnotationMemberPropertyInjectionPoint(TypedElement annotationMemberBeanType, String annotationMemberProperty, @Nullable @Nullable String requiredValue, @Nullable @Nullable 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
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 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:
-
visitConfigBuilderMethod
void visitConfigBuilderMethod(ClassElement type, String methodName, 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:
-
visitConfigBuilderMethod
void visitConfigBuilderMethod(String propertyName, ClassElement returnType, String methodName, @Nullable @Nullable ClassElement paramType, Map<String, ClassElement> generics, String path) Visit a configuration builder method.- Parameters:
propertyName- The property namereturnType- The return typemethodName- The method nameparamType- The method typegenerics- The generic types of the methodpath- 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 namereturnType- The return typemethodName- The method namepath- The property path- See Also:
-
visitConfigBuilderEnd
void visitConfigBuilderEnd()Finalize a configuration builder field.- See Also:
-
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:
-
setRequiresMethodProcessing
void setRequiresMethodProcessing(boolean shouldPreProcess) Sets whether theBeanType.requiresMethodProcessing()returns true.- Parameters:
shouldPreProcess- True if they should be pre-processed
-
visitTypeArguments
Visits the type arguments for the bean.- Parameters:
typeArguments- The type arguments
-
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
-