• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring MVC ApplicationContext vs Root WebApplicationContext

 
Ranch Hand
Posts: 52
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reference: http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-servlet

I was going through Spring's official documentation on ApplicationContext and WebApplication Context. However I am getting confused with the use of similar terminologies. e.g. In the diagram - "Context hierarchy in Spring Web MVC" from the official documentation link above it is mentioned that

ApplicationContext instances in Spring can be scoped. In the Web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. These inherited beans can be overridden in the servlet-specific scope, and you can define new scope-specific beans local to a given servlet instance.
My understanding is that both ApplicationContext and WebApplication context are the spring containers where WebApplicationContext is child of the ApplicationContext interface.



Question 1 So in the diagram "Context hierarchy in Spring Web MVC" what is the use of root WebApplicationContext? Is this same as ApplicationContext which is defined from applicationContext.xml file?

Question 2 Why can there be multiple WebApplicationContext (s) e.g. services, datasources etc.if ApplicationContext is considered to be the root context for every web application.
mvc-contexts.gif
[Thumbnail for mvc-contexts.gif]
Spring MVC Context
 
Mainak Goswami
Ranch Hand
Posts: 52
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any response will be appreciated.
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This illustration is a general one. It does not say that it involves the root context.

Maybe you can ignore this illustration for now, or take it as a very general illustration.

I opened a task in Spring io jira to clarify with Spring. They might improve this on the 4.2 release.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic