简体   繁体   English

获取EJB调用模块

[英]Get EJB calling module

In my application I need to obtain the module name who called an EJB. 在我的应用程序中,我需要获取称为EJB的模块名称。 For example I have Ejb_A that calls Ejb_B, EJB_A belongs to module A and EJB_B to module B. I would like to obtain in someway in Ejb_B that the caller is A. I googled but I didn't find much more usefull information. 例如,我有Ejb_A调用Ejb_B,EJB_A属于模块A,而EJB_B属于模块B。我想在Ejb_B中以某种方式获得调用者为A。我用谷歌搜索,但没有找到更多有用的信息。

I'm using Jboss eap 7, j2ee7. 我正在使用Jboss eap 7,j2ee7。

If the caller is remote, that might be hard to do. 如果呼叫者是远程的,那可能很难做到。 Even if the two are deployed on the same app server if you look at the StackTrace for the current thread you'll only be able to step back as far as when the current worker thread received the incoming call, and you probably won't be able to step back any further than that to see who the caller was. 即使将两者部署在同一应用程序服务器上,如果您查看当前线程的StackTrace,您也只能退后至当前工作线程收到传入呼叫的​​时间,而您可能不会可以进一步退一步,以查看呼叫者是谁。

You could make it easier for yourself and pass a parameter that's some unique identifier String that identifies who the caller is. 您可以使自己更轻松,并传递一个参数,该参数是一些唯一的标识符String,用于标识调用方是谁。 If it's critical for your app to know this info, I would look at something like this and build it into your API. 如果让您的应用知道此信息很关键,我将看一下类似的内容并将其构建到您的API中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM