Java Spring 2.5.x
I Have ApplicationContext and i want to register bean with params
"beanName", beandefination
GenericBeanDefinition myBeanDef = new GenericBeanDefinition();
To register bean i need BeanDefinitionReader but don't know how to get any help appriciated
getRegistry().registerBeanDefinition
Are you sure you need a bean definition? If you have a ConfigurableApplicationContext you can use the exposed bean factory:
ConfigurableApplicationContext context = ...;
ConfigurableListableBeanFactory beans = context.getBeanFactory();
Object bean = new ...; // create and initialize bean
beans.registerSingleton(beanName, bean);
Instead of Object use the appropriate bean type and fill in the desired properties before registering. If you want to use autowire you can use
Object bean = beans.createBean(Object.class);
beans.registerSingleton(beanName, bean);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With