• 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

Is there be any perfomace or other difference in declaring bean in these forms?

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I am using Spring to develop a web application.I have one question that

I have declare a bean something like this


and then I am referncing this bean like this



everything is working fine till so far

in myDaoClassName I am implementing 6 different object class
1)One approach is declare these all beans into seprate bean and refernce them according to requirement

2)second is declare all of them inside a single bean and annotated that class and declare all bean inside that and refernce only that one particular bean

which approach is good?

(If my question is not clear please ask)

 
author & internet detective
Posts: 41878
909
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
Kishor,
It's not a performance difference. In some scenarios, one approach might be clearer than the other. If your embedded bean is used multiple times, you should definitely define it as a top level bean. If it is only used in one place, it is sometimes clearer to declare it embedded to keep everything together.

While it is a judgment call, this is also important to be a team convention. Different people deciding different things on the same team makes it harder to find the beans than it needs to be!
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok Suppose I am deaclaring a bean where I have annotated 5 class

and In another bean I have annotated only 3 class.

I am refernce first bean from many place sometimes all 5 class requires and sometimes only 2
so If I annotated a bean with 5 class will there extra objects are created by bean factory?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic