本文介绍了MessageDrivenBean中的finalize方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
It must not define the finalize method.
上述要求的原因是什么?
推荐答案
如果查看EJB规范,您会发现它是所有类型EJB的必需品。
If you look in the EJB spec, you will see that it is a requirement for all types of EJB.
我找不到一个明确的答案,但在过去13年中查看各种Java论坛,你可以看到答案一致地说,因为容器将决定EJB的生命周期,可能永远不会调用finalize(或者当你不期望时调用)使用它会有危险。
I can't find a definitive answer but looking on various Java forums over the last 13 years, you can see answers consistently saying that, because the container will decide the life-cycle of the EJB, the finalize may never be called (or called when you don't expect) and it would there be dangerous to use it.
这篇关于MessageDrivenBean中的finalize方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!