AbstractApplicationContext

AbstractApplicationContext

本文介绍了AbstractApplicationContext vs ApplicationContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AbstractApplicationContext ApplicationContext 之间有什么区别?
我们可以打电话

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

context.registerShutdownHook()

使用 ApplicationContext

我看到了这一点浏览示例代码 -

I saw this while going through a sample code -

public static void main(String[] args) {
    AbstractApplicationContext context =new ClassPathXmlApplicationContext("Beans.xml");
    context.registerShutdownHook();
}


推荐答案

与摘要之间的差异相同class(AbstractApplicationContext)和接口(ApplicationContext)。

Same as the diff between abstract class (AbstractApplicationContext ) and an interface (ApplicationContext).

我们可以使用ApplicationContext调用context.registerShutdownHook()吗?

不,因为 registerShutdownHook() ConfigurableApplicationContext 接口的一部分,该接口未扩展通过 ApplicationContext

No, because registerShutdownHook() is part of ConfigurableApplicationContext interface which is not extended by ApplicationContext

这篇关于AbstractApplicationContext vs ApplicationContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 14:30