It's not a secret anymore!*
The moose likes Spring and the fly likes Can we pass a dynamic list of ref-beans to a bean in spring application context file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Can we pass a dynamic list of ref-beans to a bean in spring application context file?" Watch "Can we pass a dynamic list of ref-beans to a bean in spring application context file?" New topic
Author

Can we pass a dynamic list of ref-beans to a bean in spring application context file?

Santosh Kavadimatti
Greenhorn

Joined: Oct 23, 2011
Posts: 4
Hi All,

I am new to spring. I am facing a problem and don't know how to tackle it.
Here is the issue:

I have a spring application context file - spring-application-context-XXX.xml
And i have a bean named,say "aBean" defined like dis :
<bean id="aBean" class="com.some.package.SomeClass" >
Now, I need to pass a list of ref-beans to this bean via setter injection.
The ref-beans have to be presented in some other spring application context file (say, spring-application-context-YYY.xml, which will be included in spring-application-context-XXX.xml via <import resource=""/>.
The number of beans should be dynamic (i.e they can be 3 or 4 or any in number).

Is there any way we can achieve this?

Thanks in advance for suggestions!
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Try @Autowired(required=false)


===Vyas Sanzgiri===
My Blog
 
 
subject: Can we pass a dynamic list of ref-beans to a bean in spring application context file?
 
Similar Threads
Looking for advice on configuring a new project using Spring and Hibernate.
The prefix "oxm" for element "oxm:jaxb2-marshaller" is not bound
GWT spring integration
HibernateDaoSupport and Transaction
Spring config files inside jar