Example #1
0
  public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("com.vamsi");
    ctx.refresh();

    for (String beanname : ctx.getBeanDefinitionNames()) {

      System.out.println(beanname);
    }

    HollywoodServiceJSR330 hollywoodservice =
        ctx.getBean("hollywoodServiceJSR330", HollywoodServiceJSR330.class);

    hollywoodservice.getFriendlyAgents();

    Box<Integer> abox = ctx.getBean("intBox", Box.class);

    abox.setA(100);

    System.out.println("first bean " + abox.getA());

    Box<Integer> bbox = ctx.getBean("intBox", Box.class);

    System.out.println("second bean " + abox.getA());

    ctx.close();
  }