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
Modifier and TypeFieldDescriptionstatic final String
The suffix use for generated AOP intercepted types. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ClassWriterOutputVisitor visitor) Write the class to output via a visitor that manages output destination.Optional<org.objectweb.asm.Type>
org.objectweb.asm.Type
The provided type of the bean.default @NonNull ClassElement[]
boolean
default boolean
Returns whether another bean exists that proxies this bean.boolean
Returns whether another bean is a proxy target that needs to be retained.boolean
boolean
default boolean
By default, when theBeanContext
is started, theBeanDefinition.getExecutableMethods()
are not processed by registeredExecutableMethodProcessor
instances unless this method returns true.void
setInterceptedType
(String typeName) Sets the name of the intercepted type.void
setRequiresMethodProcessing
(boolean shouldPreProcess) Sets whether theBeanType.requiresMethodProcessing()
returns true.void
setValidated
(boolean validated) Make the bean definition as validated by jakarta.validation.void
visitAnnotationMemberPropertyInjectionPoint
(TypedElement annotationMemberBeanType, String annotationMemberProperty, @Nullable String requiredValue, @Nullable String notEqualsValue) Visits an annotation injection point.void
visitBeanDefinitionConstructor
(MethodElement constructor, boolean requiresReflection, VisitorContext visitorContext) Visits the constructor used to create the bean definition.void
Finalize the bean definition to the given output stream.void
visitBeanDefinitionInterface
(Class<? extends BeanDefinition> interfaceType) Visit a marker interface on the generated bean definition.void
visitBeanFactoryField
(ClassElement factoryClass, FieldElement factoryField) In the case where the produced class is produced by a factory field annotated withBean
this method should be called.void
visitBeanFactoryMethod
(ClassElement factoryClass, MethodElement factoryMethod) In the case where the produced class is produced by a factory method annotated withBean
this method should be called.void
visitBeanFactoryMethod
(ClassElement factoryClass, MethodElement factoryMethod, ParameterElement[] parameters) In the case where the produced class is produced by a factory method annotated withBean
this method should be called.void
visitConfigBuilderDurationMethod
(String propertyName, ClassElement returnType, String methodName, String path) Visit a configuration builder method that accepts a long and a TimeUnit.void
Finalize a configuration builder field.void
visitConfigBuilderField
(ClassElement type, String field, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface) Begin defining a configuration builder.void
visitConfigBuilderMethod
(ClassElement type, String methodName, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface) Begin defining a configuration builder.void
visitConfigBuilderMethod
(String propertyName, ClassElement returnType, String methodName, @Nullable ClassElement paramType, Map<String, ClassElement> generics, String path) Visit a configuration builder method.void
visitDefaultConstructor
(AnnotationMetadata annotationMetadata, VisitorContext visitorContext) Visits the constructor used to create the bean definition in the case where no constructor is present.int
visitExecutableMethod
(TypedElement declaringBean, MethodElement methodElement, VisitorContext visitorContext) Visit a method that is to be made executable allow invocation of said method without reflection.void
visitFieldInjectionPoint
(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection, VisitorContext visitorContext) Visits a field injection point.void
visitFieldValue
(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection, boolean isOptional) Visits a field injection point.void
visitMethodInjectionPoint
(TypedElement beanType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext) Visits a method injection point.void
visitPostConstructMethod
(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext) Visits a method injection point.void
visitPreDestroyMethod
(TypedElement beanType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext) Visits a method injection point.void
visitSetterValue
(TypedElement declaringType, MethodElement methodElement, AnnotationMetadata annotationMetadata, boolean requiresReflection, boolean isOptional) Visits an injection point for a setter.void
Alter the super class of this bean definition.void
visitSuperBeanDefinitionFactory
(String beanName) Alter the super class of this bean definition to use another factory bean.void
visitTypeArguments
(Map<String, Map<String, ClassElement>> typeArguments) Visits the type arguments for the bean.void
Write the state of the writer to the given compilation directory.Methods inherited from interface io.micronaut.inject.writer.OriginatingElements
addOriginatingElement, getOriginatingElements
Methods 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
Bean
this 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
Bean
this 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
Bean
this 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
-
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 jakarta.validation.- Parameters:
validated
- Whether the bean definition is validated
-
setInterceptedType
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
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
- TheConfigurationMetadataBuilder
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 buildermethodName
- The name of the method that returns the builderannotationMetadata
- The annotation metadata associated with the fieldmetadataBuilder
- TheConfigurationMetadataBuilder
isInterface
- 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 theBeanContext
is started, theBeanDefinition.getExecutableMethods()
are not processed by registeredExecutableMethodProcessor
instances 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
-