For example, the following are the generated sources:
private static BeanDefinition getDemoServiceBeanDefinition() {
RootBeanDefinition beanDefinition = new RootBeanDefinition(DemoServiceBean.class);
beanDefinition.setTargetType(ResolvableType.forClass(ReferenceBean.class));
beanDefinition.getPropertyValues().addPropertyValue("id", "demoService");
beanDefinition.getPropertyValues().addPropertyValue("interfaceClass", DemoService.class);
beanDefinition.setInstanceSupplier(DemoServiceBean::new);
return beanDefinition;
}
What can be done to achieve the following effect:
beanDefinition.setAttribute(“xxx”);
Comment From: sdeleuze
Could you please share the annotation-based construct you would like see translated to the code generated by Spring AOT engine?
Comment From: snicoll
@CrazyHZM we believe that attributes are transient artifact for the configuration processing of the bean definition. As @sdeleuze said, rather than asking that question, can you please explain what attribute that is and why you need it to be carried over.
Comment From: CrazyHZM
Thank you for getting back to me. I have been solving it by reading the spring source code. I can implement BeanRegistrationCodeFragmentsDecorator to custom my BeanDefinition. @sdeleuze @snicoll
Comment From: snicoll
@CrazyHZM can you clarify why you need this? You shouldn’t do custom code generation unless absolutely necessary so it would be nice to avoid it if we can.