Class BeanDefinitionWriter
- All Implemented Interfaces:
AnnotatedElement,AnnotationMetadata,AnnotationMetadataDelegate,AnnotationMetadataProvider,AnnotationSource,Described,Named,Toggleable,MutableAnnotationMetadataDelegate<Element>,BeanElement,Element,BeanDefinitionVisitor,ClassOutputWriter,OriginatingElements
Responsible for building BeanDefinition instances at compile time. Uses ASM build the class definition.
Should be used from AST frameworks to build bean definitions from source code data.
For example:
BeanDefinitionWriter writer = new BeanDefinitionWriter("my.package", "MyClass", "jakarta.inject.Singleton", true)
writer.visitBeanDefinitionConstructor()
writer.visitFieldInjectionPoint("my.Qualifier", false, "my.package.MyDependency", "myfield" )
writer.visitBeanDefinitionEnd()
writer.writeTo(new File(..))
- Since:
- 1.0
- Author:
- Graeme Rocher, Denis Stepanov
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classData used when visiting method. -
Field Summary
FieldsFields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTYFields inherited from interface io.micronaut.inject.writer.BeanDefinitionVisitor
PROXY_SUFFIXFields inherited from interface io.micronaut.inject.ast.Element
EMPTY_ELEMENT_ARRAYFields inherited from interface io.micronaut.inject.ast.annotation.MutableAnnotationMetadataDelegate
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionBeanDefinitionWriter(ClassElement classElement, VisitorContext visitorContext) Creates a bean definition writer.BeanDefinitionWriter(ClassElement classElement, OriginatingElements originatingElements, VisitorContext visitorContext) Creates a bean definition writer.BeanDefinitionWriter(Element beanProducingElement, OriginatingElements originatingElements, VisitorContext visitorContext, @Nullable Integer uniqueIdentifier) Creates a bean definition writer. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(ClassWriterOutputVisitor visitor) Accept a ClassWriterOutputVisitor to write this writer to disk.addAssociatedBean(ClassElement type, VisitorContext visitorContext) This method adds an associated bean using this class element as the originating element.voidaddOriginatingElement(Element element) Add another element that should be included in the originating elements.<T extends Annotation>
Elementannotate(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Annotate this element with the given annotation type.static voidfinish()Finish any work writing beans.voidgenerateProxyReference(String proxyBeanDefinitionName, String proxyBeanTypeName) Mark to generate proxy methods.Supplies the metadata.The type names produced by the bean.Returns the declaringClassElementwhich may differ from theBeanElement.getBeanTypes()in the case of factory beans.ReturnsExecutableMethodsDefinitionWriterof one exists.Returns all injection points for the bean.getName()Returns the native underlying type.Element[]The element that produces the bean, this could be aClassElementfor regular beans, or either aMethodElementorFieldElementfor factory beans.getScope()The scope of the bean.booleanbooleanbooleanbooleanbooleanReturns whether another bean exists that proxies this bean.booleanReturns whether another bean is a proxy target that needs to be retained.booleanisPublic()booleanbooleanremoveAnnotation(String annotationType) Removes an annotation of the given type from the element.<T extends Annotation>
ElementremoveAnnotationIf(Predicate<AnnotationValue<T>> predicate) Removes all annotations that pass the given predicate.removeStereotype(String annotationType) Removes a stereotype of the given name from the element.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.voidsetProxiedBean(boolean proxiedBean, boolean isProxyTarget) Sets whether this bean is a proxied type.voidsetRequiresMethodProcessing(boolean shouldPreProcess) Sets whether theBeanType.requiresMethodProcessing()returns true.voidsetValidated(boolean validated) Make the bean definition as validated by jakarta.validation.byte[]toString()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, 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.intvisitExecutableMethod(TypedElement declaringType, MethodElement methodElement, io.micronaut.sourcegen.model.ClassTypeDef interceptedProxyType, io.micronaut.sourcegen.model.MethodDef interceptedProxyBridgeMethod) 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 declaringType, 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 declaringType, 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullableMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, copyAnnotationMetadata, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getTargetAnnotationMetadata, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface io.micronaut.inject.writer.BeanDefinitionVisitor
writeToMethods inherited from interface io.micronaut.inject.ast.Element
annotate, annotate, annotate, annotate, getDescription, getDescription, getDocumentation, getModifiers, getSimpleName, isFinal, isPackagePrivate, isPrivate, isStatic, isSynthetic, removeAnnotation, removeStereotype, withAnnotationMetadata
-
Field Details
-
OMIT_CONFPROP_INJECTION_POINTS
- See Also:
-
CLASS_SUFFIX
- See Also:
-
-
Constructor Details
-
BeanDefinitionWriter
Creates a bean definition writer.- Parameters:
classElement- The class elementvisitorContext- The visitor context
-
BeanDefinitionWriter
public BeanDefinitionWriter(ClassElement classElement, OriginatingElements originatingElements, VisitorContext visitorContext) Creates a bean definition writer.- Parameters:
classElement- The class elementoriginatingElements- The originating elementsvisitorContext- The visitor context
-
BeanDefinitionWriter
public BeanDefinitionWriter(Element beanProducingElement, OriginatingElements originatingElements, VisitorContext visitorContext, @Nullable @Nullable Integer uniqueIdentifier) Creates a bean definition writer.- Parameters:
beanProducingElement- The bean producing elementoriginatingElements- The originating elementsvisitorContext- The visitor contextuniqueIdentifier- An optional unique identifier to include in the bean name
-
-
Method Details
-
generateProxyReference
Mark to generate proxy methods.- Parameters:
proxyBeanDefinitionName- The definition nameproxyBeanTypeName- The proxy bean name
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabledin interfaceToggleable- Returns:
- Whether the component is enabled
-
getExecutableMethodsWriter
ReturnsExecutableMethodsDefinitionWriterof one exists.- Returns:
- An instance of
ExecutableMethodsDefinitionWriter
-
getTypeArguments
- Specified by:
getTypeArgumentsin interfaceBeanDefinitionVisitor- Returns:
- The generic type arguments for the bean type.
-
getTypeArgumentMap
- Specified by:
getTypeArgumentMapin interfaceBeanDefinitionVisitor- Returns:
- A map of the type arguments for the bean.
-
getBeanDefinitionReferenceClassName
- Specified by:
getBeanDefinitionReferenceClassNamein interfaceBeanDefinitionVisitor- Returns:
- The name of the bean definition reference class.
-
getPostConstructMethodVisits
- Returns:
- The data for any post construct methods that were visited
-
isInterface
public boolean isInterface()- Specified by:
isInterfacein interfaceBeanDefinitionVisitor- Returns:
- Whether the provided type an interface
-
isSingleton
public boolean isSingleton()- Specified by:
isSingletonin interfaceBeanDefinitionVisitor- Returns:
- Is the bean singleton
-
visitBeanDefinitionInterface
Description copied from interface:BeanDefinitionVisitorVisit a marker interface on the generated bean definition.- Specified by:
visitBeanDefinitionInterfacein interfaceBeanDefinitionVisitor- Parameters:
interfaceType- The interface type
-
visitSuperBeanDefinition
Description copied from interface:BeanDefinitionVisitorAlter the super class of this bean definition. The passed class should be a subclass ofAbstractInitializableBeanDefinition.- Specified by:
visitSuperBeanDefinitionin interfaceBeanDefinitionVisitor- Parameters:
name- The super type
-
visitSuperBeanDefinitionFactory
Description copied from interface:BeanDefinitionVisitorAlter the super class of this bean definition to use another factory bean.- Specified by:
visitSuperBeanDefinitionFactoryin interfaceBeanDefinitionVisitor- Parameters:
beanName- The bean name
-
getBeanTypeName
- Specified by:
getBeanTypeNamein interfaceBeanDefinitionVisitor- Returns:
- The full class name of the bean
-
setValidated
public void setValidated(boolean validated) Description copied from interface:BeanDefinitionVisitorMake the bean definition as validated by jakarta.validation.- Specified by:
setValidatedin interfaceBeanDefinitionVisitor- Parameters:
validated- Whether the bean definition is validated
-
setInterceptedType
Description copied from interface:BeanDefinitionVisitorSets the name of the intercepted type.- Specified by:
setInterceptedTypein interfaceBeanDefinitionVisitor- Parameters:
typeName- The type name
-
getInterceptedType
- Specified by:
getInterceptedTypein interfaceBeanDefinitionVisitor- Returns:
- The intercepted type
-
isValidated
public boolean isValidated()- Specified by:
isValidatedin interfaceBeanDefinitionVisitor- Returns:
- Return whether the bean definition is validated.
-
getBeanDefinitionName
- Specified by:
getBeanDefinitionNamein interfaceBeanDefinitionVisitor- Returns:
- The name of the bean definition class
-
getOriginatingElement
- Specified by:
getOriginatingElementin interfaceBeanDefinitionVisitor- Specified by:
getOriginatingElementin interfaceBeanElement- 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.- Specified by:
visitBeanFactoryMethodin interfaceBeanDefinitionVisitor- Parameters:
factoryClass- The factory classfactoryMethod- The factory method
-
visitBeanFactoryMethod
public 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.- Specified by:
visitBeanFactoryMethodin interfaceBeanDefinitionVisitor- 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.- Specified by:
visitBeanFactoryFieldin interfaceBeanDefinitionVisitor- Parameters:
factoryClass- The factory classfactoryField- The factory field
-
visitBeanDefinitionConstructor
public void visitBeanDefinitionConstructor(MethodElement constructor, boolean requiresReflection, VisitorContext visitorContext) Visits the constructor used to create the bean definition.- Specified by:
visitBeanDefinitionConstructorin interfaceBeanDefinitionVisitor- Parameters:
constructor- The constructorrequiresReflection- Whether invoking the constructor requires reflectionvisitorContext- The visitor context
-
visitDefaultConstructor
public void visitDefaultConstructor(AnnotationMetadata annotationMetadata, VisitorContext visitorContext) Description copied from interface:BeanDefinitionVisitorVisits 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.- Specified by:
visitDefaultConstructorin interfaceBeanDefinitionVisitor- Parameters:
annotationMetadata- The annotation metadata for the constructorvisitorContext- The visitor context
-
visitBeanDefinitionEnd
public void visitBeanDefinitionEnd()Finalize the bean definition to the given output stream.- Specified by:
visitBeanDefinitionEndin interfaceBeanDefinitionVisitor
-
toByteArray
public byte[] toByteArray()- Returns:
- The bytes of the class
-
accept
Description copied from interface:ClassOutputWriterAccept a ClassWriterOutputVisitor to write this writer to disk.- Specified by:
acceptin interfaceBeanDefinitionVisitor- Specified by:
acceptin interfaceClassOutputWriter- Parameters:
visitor- TheClassWriterOutputVisitor- Throws:
IOException- if there is an error writing to disk
-
visitSetterValue
public void visitSetterValue(TypedElement declaringType, MethodElement methodElement, AnnotationMetadata annotationMetadata, boolean requiresReflection, boolean isOptional) Description copied from interface:BeanDefinitionVisitorVisits an injection point for a setter.- Specified by:
visitSetterValuein interfaceBeanDefinitionVisitor- Parameters:
declaringType- The declaring typemethodElement- The method elementannotationMetadata- The annotationMetadatarequiresReflection- Whether the setter requires reflectionisOptional- Whether the setter is optional
-
visitPostConstructMethod
public void visitPostConstructMethod(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext) Description copied from interface:BeanDefinitionVisitorVisits a method injection point.- Specified by:
visitPostConstructMethodin interfaceBeanDefinitionVisitor- 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
public void visitPreDestroyMethod(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext) Description copied from interface:BeanDefinitionVisitorVisits a method injection point.- Specified by:
visitPreDestroyMethodin interfaceBeanDefinitionVisitor- Parameters:
declaringType- The bean type of the methodmethodElement- The method elementrequiresReflection- Whether the method requires reflectionvisitorContext- The visitor context
-
visitMethodInjectionPoint
public void visitMethodInjectionPoint(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext) Description copied from interface:BeanDefinitionVisitorVisits a method injection point.- Specified by:
visitMethodInjectionPointin interfaceBeanDefinitionVisitor- Parameters:
declaringType- The bean type of the methodmethodElement- The method elementrequiresReflection- Whether the method requires reflectionvisitorContext- The visitor context
-
visitExecutableMethod
public int visitExecutableMethod(TypedElement declaringBean, MethodElement methodElement, VisitorContext visitorContext) Description copied from interface:BeanDefinitionVisitorVisit a method that is to be made executable allow invocation of said method without reflection.- Specified by:
visitExecutableMethodin interfaceBeanDefinitionVisitor- 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
-
visitExecutableMethod
public int visitExecutableMethod(TypedElement declaringType, MethodElement methodElement, io.micronaut.sourcegen.model.ClassTypeDef interceptedProxyType, io.micronaut.sourcegen.model.MethodDef interceptedProxyBridgeMethod) Visit a method that is to be made executable allow invocation of said method without reflection.- Parameters:
declaringType- The declaring type of the method. Either a Class or a string representing the name of the typemethodElement- The method elementinterceptedProxyType- The intercepted proxy typeinterceptedProxyBridgeMethod- The intercepted proxy bridge method name- Returns:
- The index of a new method.
-
toString
-
getPackageName
- Specified by:
getPackageNamein interfaceBeanDefinitionVisitor- Returns:
- The package name of the bean
-
getBeanSimpleName
- Specified by:
getBeanSimpleNamein interfaceBeanDefinitionVisitor- Returns:
- The short name of the bean
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProviderSupplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA.- Specified by:
getAnnotationMetadatain interfaceAnnotationMetadataProvider- Specified by:
getAnnotationMetadatain interfaceBeanDefinitionVisitor- Returns:
- The annotation metadata
-
visitConfigBuilderField
public void visitConfigBuilderField(ClassElement type, String field, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface) Description copied from interface:BeanDefinitionVisitorBegin defining a configuration builder.- Specified by:
visitConfigBuilderFieldin interfaceBeanDefinitionVisitor- 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
public void visitConfigBuilderMethod(ClassElement type, String methodName, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface) Description copied from interface:BeanDefinitionVisitorBegin defining a configuration builder.- Specified by:
visitConfigBuilderMethodin interfaceBeanDefinitionVisitor- 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:
-
visitConfigBuilderDurationMethod
public void visitConfigBuilderDurationMethod(String propertyName, ClassElement returnType, String methodName, String path) Description copied from interface:BeanDefinitionVisitorVisit a configuration builder method that accepts a long and a TimeUnit.- Specified by:
visitConfigBuilderDurationMethodin interfaceBeanDefinitionVisitor- Parameters:
propertyName- The property namereturnType- The return typemethodName- The method namepath- The property path- See Also:
-
visitConfigBuilderMethod
public void visitConfigBuilderMethod(String propertyName, ClassElement returnType, String methodName, ClassElement paramType, Map<String, ClassElement> generics, String path) Description copied from interface:BeanDefinitionVisitorVisit a configuration builder method.- Specified by:
visitConfigBuilderMethodin interfaceBeanDefinitionVisitor- 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:
-
visitConfigBuilderEnd
public void visitConfigBuilderEnd()Description copied from interface:BeanDefinitionVisitorFinalize a configuration builder field.- Specified by:
visitConfigBuilderEndin interfaceBeanDefinitionVisitor- See Also:
-
setRequiresMethodProcessing
public void setRequiresMethodProcessing(boolean shouldPreProcess) Description copied from interface:BeanDefinitionVisitorSets whether theBeanType.requiresMethodProcessing()returns true.- Specified by:
setRequiresMethodProcessingin interfaceBeanDefinitionVisitor- Parameters:
shouldPreProcess- True if they should be pre-processed
-
visitTypeArguments
Description copied from interface:BeanDefinitionVisitorVisits the type arguments for the bean.- Specified by:
visitTypeArgumentsin interfaceBeanDefinitionVisitor- Parameters:
typeArguments- The type arguments
-
requiresMethodProcessing
public boolean requiresMethodProcessing()Description copied from interface:BeanDefinitionVisitorBy default, when theBeanContextis started, theBeanDefinition.getExecutableMethods()are not processed by registeredExecutableMethodProcessorinstances unless this method returns true.- Specified by:
requiresMethodProcessingin interfaceBeanDefinitionVisitor- Returns:
- Whether the bean definition requires method processing
- See Also:
-
visitFieldInjectionPoint
public void visitFieldInjectionPoint(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection, VisitorContext visitorContext) Description copied from interface:BeanDefinitionVisitorVisits a field injection point.- Specified by:
visitFieldInjectionPointin interfaceBeanDefinitionVisitor- 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
public void visitAnnotationMemberPropertyInjectionPoint(TypedElement annotationMemberBeanType, String annotationMemberProperty, @Nullable @Nullable String requiredValue, @Nullable @Nullable String notEqualsValue) Description copied from interface:BeanDefinitionVisitorVisits an annotation injection point.- Specified by:
visitAnnotationMemberPropertyInjectionPointin interfaceBeanDefinitionVisitor- 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
public void visitFieldValue(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection, boolean isOptional) Description copied from interface:BeanDefinitionVisitorVisits a field injection point.- Specified by:
visitFieldValuein interfaceBeanDefinitionVisitor- 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
-
getName
-
isProtected
public boolean isProtected()- Specified by:
isProtectedin interfaceElement- Returns:
- True if the element is protected.
-
isPublic
public boolean isPublic() -
getNativeType
Description copied from interface:ElementReturns the native underlying type. This API is extended by all inject language implementations. The object returned by this method will be the language native type the information is being retrieved from.- Specified by:
getNativeTypein interfaceElement- Returns:
- The native type
-
getInjectionPoints
Description copied from interface:BeanElementReturns all injection points for the bean. These will be a combination ofFieldElementandMethodElementinstances.- Specified by:
getInjectionPointsin interfaceBeanElement- Returns:
- The injection points for the bean.
-
isAbstract
public boolean isAbstract()- Specified by:
isAbstractin interfaceElement- Returns:
- True if the element is abstract.
-
annotate
public <T extends Annotation> Element annotate(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Description copied from interface:MutableAnnotationMetadataDelegateAnnotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotatein interfaceElement- Specified by:
annotatein interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
annotationType- The annotation typeconsumer- A function that receives theAnnotationValueBuilder- Returns:
- This element
-
removeAnnotation
Description copied from interface:MutableAnnotationMetadataDelegateRemoves an annotation of the given type from the element.If the annotation features any stereotypes these will also be removed unless there are other annotations that reference the stereotype to be removed.
In the case of repeatable annotations this method will remove all repeated annotations, effectively clearing out all declared repeated annotations of the given type.
- Specified by:
removeAnnotationin interfaceElement- Specified by:
removeAnnotationin interfaceMutableAnnotationMetadataDelegate<Element>- Parameters:
annotationType- The annotation type- Returns:
- This element
-
removeAnnotationIf
Description copied from interface:MutableAnnotationMetadataDelegateRemoves all annotations that pass the given predicate.- Specified by:
removeAnnotationIfin interfaceElement- Specified by:
removeAnnotationIfin interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
predicate- The predicate- Returns:
- This element
-
removeStereotype
Description copied from interface:MutableAnnotationMetadataDelegateRemoves a stereotype of the given name from the element.- Specified by:
removeStereotypein interfaceElement- Specified by:
removeStereotypein interfaceMutableAnnotationMetadataDelegate<Element>- Parameters:
annotationType- The annotation type- Returns:
- This element
-
getDeclaringClass
Description copied from interface:BeanElementReturns the declaringClassElementwhich may differ from theBeanElement.getBeanTypes()in the case of factory beans.- Specified by:
getDeclaringClassin interfaceBeanElement- Returns:
- The declaring class of the bean.
-
getProducingElement
Description copied from interface:BeanElementThe element that produces the bean, this could be aClassElementfor regular beans, or either aMethodElementorFieldElementfor factory beans.- Specified by:
getProducingElementin interfaceBeanElement- Returns:
- The producing element
-
getBeanTypes
Description copied from interface:BeanElementThe type names produced by the bean.- Specified by:
getBeanTypesin interfaceBeanElement- Returns:
- A set of types
-
getScope
Description copied from interface:BeanElementThe scope of the bean.- Specified by:
getScopein interfaceBeanElement- Returns:
- The fully qualified name of the scope or empty if no scope is defined.
-
getQualifiers
- Specified by:
getQualifiersin interfaceBeanElement- Returns:
- One or more fully qualified qualifier types defined by the bean.
-
addAssociatedBean
Description copied from interface:BeanElementThis method adds an associated bean using this class element as the originating element.Note that this method can only be called on classes being directly compiled by Micronaut. If the ClassElement is loaded from pre-compiled code an
UnsupportedOperationExceptionwill be thrown.- Specified by:
addAssociatedBeanin interfaceBeanElement- Parameters:
type- The type of the beanvisitorContext- The visitor context- Returns:
- A bean builder
-
getOriginatingElements
- Specified by:
getOriginatingElementsin interfaceOriginatingElements- Returns:
- The elements where the bean definition originated from as an array.
-
addOriginatingElement
Description copied from interface:OriginatingElementsAdd another element that should be included in the originating elements.- Specified by:
addOriginatingElementin interfaceOriginatingElements- Parameters:
element- The element to add
-
setProxiedBean
public void setProxiedBean(boolean proxiedBean, boolean isProxyTarget) Sets whether this bean is a proxied type.- Parameters:
proxiedBean- True if it proxiedisProxyTarget- True if the proxied bean is a retained target
-
isProxyTarget
public boolean isProxyTarget()Description copied from interface:BeanDefinitionVisitorReturns whether another bean is a proxy target that needs to be retained.- Specified by:
isProxyTargetin interfaceBeanDefinitionVisitor- Returns:
- Is the reference a proxy target.
-
isProxiedBean
public boolean isProxiedBean()Description copied from interface:BeanDefinitionVisitorReturns whether another bean exists that proxies this bean. In other words this bean is the target of a proxy.- Specified by:
isProxiedBeanin interfaceBeanDefinitionVisitor- Returns:
- Is the reference a proxy target.
-
finish
Finish any work writing beans.
-