I have a method with return type 'AbstractBeanDefinition', this method is supposed to set all the necessary properties and return it.
public AbstractBeanDefinition constructJMSMessage() {
BeanDefinitionBuilder theMessagingService = BeanDefinitionBuilder.rootBeanDefinition(MessagingService.class);
theMessagingService.addPropertyValue(..);
theMessagingService.addPropertyValue(..);
theMessagingService.addPropertyValue(..);
return theMessagingService.getBeanDefinition()
}
In the caller place, i want to create a object based on the bean defintion returned by this method. How can i do that ?
public void ConstructIt()
{
MessagingService obj = constructJMSMessage();
}
You need to register
BeanDefinition
with theBeanDefinitionRegistry
(with is usually aDefaultListableBeanFactory
instance) first and then use it as a regular bean.