Java EE EJB 拦截器
是否可以为耳朵内的所有 EJB 配置默认拦截器?
可以在 ejb-jar.xml 的模块内提及 EJB 的默认拦截器。如果应用程序中有多个模块,则所有模块都需要具有此配置。
我正在考虑在全球范围内对应用程序强制执行某些拦截器。因此,如果可以在应用程序级别或服务器级别设置它将会很有帮助,这样就不会由各个模块的开发人员自行决定是否包含它们。
Is it possible to have the default interceptor configured for all EJBs within an ear?
Default interceptors can be mentioned for EJBs within a module in the ejb-jar.xml. If there are multiple modules within an application, all modules need to have this configuration.
I am looking at enforcing certain interceptors on the application globally. So it would be helpful if it can be set at an application level or at a server level so that it is not left to the discretion of developers of the individual modules to include them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法避免必须在每个 ejb-jar 文件中指定拦截器,不可能在 EAR 级别上定义它。拦截器类需要与使用它的所有 bean 打包在同一个 ejb-jar 文件中。
您仍然可以将拦截器的代码提取到所有 ejb 模块使用的公共库中,但是,在每个 ejb-jar 文件中,您仍然必须定义并激活调用公共实现的单独拦截器。
You can't avoid having to specify the interceptor in each ejb-jar file, there is no possibility to define it on EAR level. Interceptor class needs to be packed in the same ejb-jar file as all beans that use it.
You can still extract interceptor's code into a common library used by all ejb modules, but still, in each ejb-jar file you have to define and activate a separate interceptor calling the common implementation.