• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dependency Injection in Java

 
Ranch Hand
Posts: 48
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked the Table of Contents for "The Well Grounded Java Developer".

Chapter 3 is on Dependency Injection.

Some basic questions:

1. Is the DI in Java similar to what Spring framework offers? Is it a remake?
2. Does Java just provide the Spec for DI and we need some vendor implementation for this spec to utilize DI?
3. How can I make my current Java code to utilize Java DI?
4. Do I necessarily need to use Guice API's to achieve Java DI?
5. Do we have any other implementation available for Java DI other than Guice?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) It is a standard inspired by Spring (and more)
2) I believe you need some sort of DI container.
3) Look for things you'd like to decouple. For example, when writing test code, it is common to inject an implementation of an interface.
4) No
5) Spring and PicoContainer.
 
Shiv Swaminathan
Ranch Hand
Posts: 48
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring framework on DI was there before Java came up with any DI specs.
How can it be that Spring is implementing java DI?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a very common pattern is software. Good ideas become design patterns, design patterns are bult into frameworks (like Spring) and then into a language itself (the JSR-330 std for Java). Spring 3.x simply implements the common JSR-330 std + some extras.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shiv,
That's how JPA came about too.

1) Hibernate started.
2) JPA spec came out
3) Hibernate provided set of APIs to be compliant with JPA spec
reply
    Bookmark Topic Watch Topic
  • New Topic