Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GenericBeanDefinitionExample {
- public static void main (String[] args) {
- DefaultListableBeanFactory context =
- new DefaultListableBeanFactory();
- GenericBeanDefinition gbd = new GenericBeanDefinition();
- gbd.setBeanClass(MyBean.class);
- MutablePropertyValues mpv = new MutablePropertyValues();
- mpv.add("date", new Date());
- //alternatively we can use:
- // gbd.getPropertyValues().addPropertyValue("date", new Date());
- gbd.setPropertyValues(mpv);
- context.registerBeanDefinition("myBeanName", gbd);
- MyBean bean = context.getBean(MyBean.class);
- bean.doSomething();
- }
- }
Add Comment
Please, Sign In to add comment