Search in sources :

Example 6 with BeanDefinitionWriter

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;
        }
    };
}
Also used : MethodNode(org.codehaus.groovy.ast.MethodNode) ClassElement(io.micronaut.inject.ast.ClassElement) BeanDefinitionWriter(io.micronaut.inject.writer.BeanDefinitionWriter) AnnotationMetadataHierarchy(io.micronaut.inject.annotation.AnnotationMetadataHierarchy)

Aggregations

BeanDefinitionWriter (io.micronaut.inject.writer.BeanDefinitionWriter)6 ClassElement (io.micronaut.inject.ast.ClassElement)5 AnnotationMetadataHierarchy (io.micronaut.inject.annotation.AnnotationMetadataHierarchy)4 HotSwappableInterceptedProxy (io.micronaut.aop.HotSwappableInterceptedProxy)2 InterceptedProxy (io.micronaut.aop.InterceptedProxy)2 BeanResolutionContext (io.micronaut.context.BeanResolutionContext)2 ExecutionHandleLocator (io.micronaut.context.ExecutionHandleLocator)2 Qualifier (io.micronaut.context.Qualifier)2 AnnotationValue (io.micronaut.core.annotation.AnnotationValue)2 ExecutableMethod (io.micronaut.inject.ExecutableMethod)2 ParameterElement (io.micronaut.inject.ast.ParameterElement)2 Intercepted (io.micronaut.aop.Intercepted)1 Interceptor (io.micronaut.aop.Interceptor)1 InterceptorKind (io.micronaut.aop.InterceptorKind)1 Introduced (io.micronaut.aop.Introduced)1 InterceptorChain (io.micronaut.aop.chain.InterceptorChain)1 MethodInterceptorChain (io.micronaut.aop.chain.MethodInterceptorChain)1 InterceptedMethodUtil (io.micronaut.aop.internal.intercepted.InterceptedMethodUtil)1 BeanContext (io.micronaut.context.BeanContext)1 BeanLocator (io.micronaut.context.BeanLocator)1