It's not a secret anymore!
The moose likes Spring and the fly likes Spring application context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Reply locked New topic

Spring application context

Lisa Bass

Joined: Jan 29, 2009
Posts: 6
being new to spring...
I have been asked a question in interview

What is spring ApplicationContext??

How you load it?

can someone provide me with the answers of these two???

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Check the online manual : 3.1 Introduction to the Spring IoC container and beans

[My Blog]
All roads lead to JavaRanch
Craig Walls
Ranch Hand

Joined: Sep 19, 2003
Posts: 335
Put simply: The "Application Context" is another name for the Spring container. Spring's primary job is to manage the lifecycle and relationships between a lot of objects. It does that by loading them in its container.

To load the container..well there are several answers to that, depending on how you build your application. Typically, there's one or more XML files that contains one or more <bean> declarations (although these XML files keep getting smaller thanks to some special namespaces, annotations and autowiring).

If it's a web application then those XML files are loaded by either DispatcherServlet and/or ContextLoaderListener. If it's an OSGi bundle, then they're loaded by the Spring-DM extender. If it's a standalone (e.g., has a main() method) application, then you might load them a little something like this:

And there are other ways to load it...kinda depends on the circumstance, though.

Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Nitin Gaur,
Your post was moved to a new topic.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Spring application context
It's not a secret anymore!