Implementations of Application Context

Implementations of Application Context :

There are three common implementations of the Application Context is available.

ClassPathXmlApplicationContext : This loads context definition from XML file present in the classpath. Below example shows relative path of bean.xml file loading from classpath:

ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");

 

FileSystemXmlApplicationContext : This loads context definition from XML file present in the filesystem. This should be absolute path of the file as example below:

ApplicationContext appContext = new FileSystemXmlApplicationContext("C:/Spring/Context/bean.xml”);

 

XmlWebApplicationContext : This loads context definition from XML file present within a web application

Leave a Reply

Your email address will not be published. Required fields are marked *