Java EE EJB 拦截器

发布于 2024-12-15 14:50:25 字数 192 浏览 3 评论 0原文

是否可以为耳朵内的所有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等数载,海棠开 2024-12-22 14:50:25

您无法避免必须在每个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文