Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 39 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. public class GenericBeanDefinitionExample {
  2.  
  3.   public static void main (String[] args) {
  4.       DefaultListableBeanFactory context =
  5.                 new DefaultListableBeanFactory();
  6.  
  7.       GenericBeanDefinition gbd = new GenericBeanDefinition();
  8.       gbd.setBeanClass(MyBean.class);
  9.  
  10.       MutablePropertyValues mpv = new MutablePropertyValues();
  11.       mpv.add("date", new Date());
  12.  
  13.       //alternatively we can use:
  14.       // gbd.getPropertyValues().addPropertyValue("date", new Date());
  15.       gbd.setPropertyValues(mpv);
  16.  
  17.       context.registerBeanDefinition("myBeanName", gbd);
  18.  
  19.       MyBean bean = context.getBean(MyBean.class);
  20.       bean.doSomething();
  21.   }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top