• 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

dependencies in Spring

 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When should we be specifying dependencies between objects in external configurations files ? Should all dependencies go into the XML file .If we put all dependencies for e.g. Person and Address , then we will end up a huge XML file ? :roll: Maintaining the XML file will be a big nightmare. I am feeling that DI is hyped too much.

Thanks
Pradeep
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, we don't want to put all dependencies to external configuration files. We only put those dependencies into external configuration files that we want to decouple from a given class.

For example, it makes little sense specifying dependencies in a Spring context file between "Person" and "Address" but it makes a lot of sense to inject an implementation of "IPersonDao" into "HumanResourcesService" instead of having "HumanResourcesService" do a "new PersonDaoImpl()"...

In short, don't externalize dependencies unless you have a need for doing so.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Lasse. Couple of questions

1. How does separate intf and impl class in spring

<bean id="myEntityManager"
class="com.acme.MyEntityManager">
<property name="dataSource">
<ref bean="myDataSource"/>
</property>
</bean>

Here id myEntityManager tied to class com.acme.MyEntityManager. Where is the interface specified?


2. Is it possible to specify JNDI dependency for EJBHome in Spring?
 
this is supposed to be a surprise, but it smells like a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic