Aop

IoC

What are the different types of dependency injections? FAQ

There are three types of dependency injections.

  • Constructor Injection (e.g. Pico container, Spring etc): Injection is done through constructors.
  • Setter Injection (e.g. Spring): Injection is done through setter methods.
  • Interface Injection (e.g. Avalon): Injection is done through an interface.
//lookup “car” in your caller where “carDao” is dependency injected using the setter method.
CarBO bo = (CarBO)ctx.getBean("car"); 
//Spring creates an instance of the CarBO object with an instance of CarDAO object and 
//then invokes the setter method setDao(CarDAO carDao) on CarBO.  or Spring creates 
//an instance of the CarBO object with an instance of CarDAO object as the constructor arg.

Spring

Unlike EJB, Spring does not have a default support for distributed transactions (i.e. XA transactions - ) but can plug-in a JTA transaction manager.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License