Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Nikhilesh Reddy Chaduvula
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic