Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AbstractApplicationContext vs ApplicationContext

Tags:

java

spring

what is the difference between AbstractApplicationContext and ApplicationContext ? can we call

context.registerShutdownHook()  

using ApplicationContext?

I saw this while going through a sample code -

public static void main(String[] args) {
    AbstractApplicationContext context =new ClassPathXmlApplicationContext("Beans.xml");
    context.registerShutdownHook();
}
like image 658
shadowfox Avatar asked Aug 07 '12 18:08

shadowfox


1 Answers

registerShutdownHook() gracefully shutdowns bean and preform finalization like calling the destroy methods. This is the method declared in the interface ConfigurableApplicationContext which is implemented by AbstractApplicationContext,and it is not implemented by ApplicationContext.So the invokation of registerShutdownHook() only possible from the AbstractApplicationContext's object

like image 175
Arun Kumar Mudraboyina Avatar answered Sep 19 '22 03:09

Arun Kumar Mudraboyina