Can a stateless session bean have protected final method?

佐手、 提交于 2019-12-01 20:52:12

The short answer is "yes", but the long answer is "yes in general, but no when using no-interface view". The restriction for no-interface view comes indirectly from section 3.4.4 of the EJB 3.2 specification:

Only public methods of the bean class and of any superclasses except java.lang.Object may be invoked through the no-interface view. Attempted invocations of methods with any other access modifiers via the no-interface view reference must result in the javax.ejb.EJBException.

When generating a no-interface view proxy, the EJB container must create a subclass of the EJB class and override all public methods to provide proxying behavior. However, the second sentence from the specification quote above implies that all remaining non-private methods must also be overridden in order to throw an unconditional EJBException. That said, the error message from the application server could be better.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!