AbstractApplicationContext vs ApplicationContext

后端 未结 3 1627
悲哀的现实
悲哀的现实 2021-02-19 15:06

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

context.registerShutdownHook()  
         


        
3条回答
  •  灰色年华
    2021-02-19 16:01

    registerShutdownHook() is not part of ApplicationContext. So, we can not use Application context.

    This method can be invoked using references using with either ConfigurableApplicationContext or AbstractApplicationContext.

    As methods can be called either from interface or class having the implementation. Because, we actually create object for ClassPathXmlApplicationContext using the reference of AbstractApplicationContext.

    Difference: ConfigurableApplicationContext is an interface where the methods are implemented in AbstractApplicationContext class.

提交回复
热议问题