• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

How to pass a collection as argument to a constructor using Spring based dependency injection

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am using Mongodb

How to pass a collection as constructor argument to the above constructor using spring.
I don't want to use string as argument but i want to pass a collection from spring (Anything is fine but xml is preferred)
My xml goes something like this

Let me know if anyone has already done it.

Thanks,
Nikhil
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You would need to then create a bean with id = myMongoCollection and of class = com.mongodb.DBCollection of course the that bean would have yet another constructor-arg ref of a bean of type com.mongodb.DB and a string. You would continue this pattern until you just had simple types. Something like this is much easier to do with Java Config but you said you prefer XML.
 
Nikhilesh Reddy Chaduvula
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill Gorder,

Can you please cite an example of java Config based approach which would really help me.

Thanks,
Nkhil
reply
    Bookmark Topic Watch Topic
  • New Topic