3

I asked a question yesterday ( Using Spring in standalone apps ) on how you would use Spring in a standalone application. From that I learned that you only create the application context object once. So now the question is (even though it was partially answered in a comment) what happens when you create the application context?

Does Spring create the beans and wire them together when you say
new ClassPathXmlApplicationContext("some.xml") ?

I am not sure if I understand the boot strapping, and why it is like that.

Community
  • 1
  • 1
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434

2 Answers2

4

The idea behind the ApplicationContext in Spring is that in order to properly inject objects where they are needed, some thing needs to be aware of the configuration the user specifies and inject dependencies based on this configuration.

The ApplicationContext is the thing that understands the user's wishes in terms of where and what should be injected (as well as other things such as AOP pointcuts and such) based on the configuration a user provides, either through an xml file or annotations.

gorjusborg
  • 656
  • 4
  • 18
  • 1
    How about some references for more information: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans. – madth3 Mar 13 '12 at 17:51
0

Yes it will parse the bean definition file , it will create the beans , give them the dependencies,

The easiest way to debug is to go with the output print statements,

Put the statements in constructor & setter methods and try different possibilities to track the flow

jmj
  • 237,923
  • 42
  • 401
  • 438