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();
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With