Constructor OverLoading in Spring

24 views
Skip to first unread message

Hari Mohan

unread,
Jun 14, 2011, 5:41:00 AM6/14/11
to Technical Discussion
Hi All .,

A trivial problem in Spring.

Scenario :
1. define overloaded constructors for a Class.
2.Define a bean (id = bean1) with arguments for the 1st construtor
3.Define another bean (id = bean2) with arguments for 2nd Constructor.

Now .,in the main .,
get the bean1 from ApplicationContext.getBean() .
Hence .,The Spring Container has to create the bean by calling the 1st
construtor.


--> But .,it calls all the constructors in the order we defined in the
class <--


How to rectify it and define constructor overloading in Spring IOC ???


-HariMohan

Shailendra shail

unread,
Jul 1, 2011, 9:05:12 AM7/1/11
to newidea_or...@googlegroups.com
Can you put Spring XML configuration here.. along with code.. how did you write those things so that I can find what is wrong there. 

I guess, you might have wired all the class in the configuration file. Spring is having feature to load all object using Inversion of control but those class must be wired in caller bean. One feature of spring is it will treat all class as singleton class and will be loaded when loading the application..


I can't visualize the problem until or unless you are putting exact information with java example.
Reply all
Reply to author
Forward
0 new messages