Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Spring IOC Container

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can any one tell me if it is possible if an application can have two Spring containers ?? if yes [i belive so] , how JVM going to handle this.

also, like to know , when we define ContextLoaderListener into web.xml, how that going to load applicationcontext.xml file.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bhupesh Maduskar wrote:Hi All,

Can any one tell me if it is possible if an application can have two Spring containers ?? if yes [i belive so] , how JVM going to handle this.

also, like to know , when we define ContextLoaderListener into web.xml, how that going to load applicationcontext.xml file.



First question yet. As many ApplicationContext instances that you want. ApplicationContext is just a pojo, so how does any class work if they are instantiated twice. I create two Person objects, how is the JVM going to handle this.

So from the JVM perspective there is nothing special to handle.

Now there is a concept of parent-child application contexts where the child context can see all the beans in the parent context, but not the other way around.

Second question applicationContext.xml in the WEB-INF directory is just the default file location and name that the ContextLoaderListener is looking for. You can always call it something else, put it somewhere else, then you have to include a <context-param> tag in your web.xml to point to it. That is why I like the default file name and location.

The listener gets called right after the Web Container create a ServletContext for the web app. When it gets called it creates an XmlWebApplicationContext and loads in your config file.

Hope that helps.

Mark
 
A teeny tiny vulgar attempt to get you to buy our stuff
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic