use of io.micronaut.inject.writer.BeanDefinitionWriter in project micronaut-core by micronaut-projects.
the class GroovyBeanDefinitionBuilder method createChildBean.
@Override
protected AbstractBeanDefinitionBuilder createChildBean(MethodElement producerMethod) {
final ClassElement parentType = getBeanType();
return new GroovyBeanDefinitionBuilder(GroovyBeanDefinitionBuilder.this.getOriginatingElement(), producerMethod.getGenericReturnType().getType(), GroovyBeanDefinitionBuilder.this.metadataBuilder, GroovyBeanDefinitionBuilder.this.visitorContext) {
@Override
public Element getProducingElement() {
return producerMethod;
}
@Override
public ClassElement getDeclaringElement() {
return producerMethod.getDeclaringType();
}
@Override
protected BeanDefinitionWriter createBeanDefinitionWriter() {
final BeanDefinitionWriter writer = super.createBeanDefinitionWriter();
final GroovyElementFactory elementFactory = ((GroovyVisitorContext) visitorContext).getElementFactory();
final MethodNode methodNode = (MethodNode) producerMethod.getNativeType();
writer.visitBeanFactoryMethod(parentType, elementFactory.newMethodElement(parentType, methodNode, new AnnotationMetadataHierarchy(parentType.getDeclaredMetadata(), producerMethod.getDeclaredMetadata())));
return writer;
}
};
}
Aggregations