[英]Accessing ejb-name at run time from inside MDB
Giving this entry from ejb-jar.xml 从ejb-jar.xml提供此条目
<message-driven id="my_test_mdb ">
<description>Some description</description>
<display-name>MyTest</display-name>
<ejb-name>MyTestEJB</ejb-name>
<ejb-class>some.path.to.TestMessageBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>
Is there a way to access at runtime the values defined for my_test_mdb. 有没有一种方法可以在运行时访问为my_test_mdb定义的值。 I am mainly interested in getting the ejb-name value but the same question should be asked for the others like display-name and so.
我主要对获取ejb-name值感兴趣,但其他问题(例如display-name等)也应问相同的问题。
I am aware about the fact that I could add some environment entries like below but this looks to me like a sort of duplication and error prone. 我知道我可以像下面那样添加一些环境条目的事实,但是在我看来,这有点像重复和容易出错。
<message-driven>
...
<ejb-name>MyTestEJB</ejb-name>
...
<env-entry>
<env-entry-name>ejbName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>MyTestEJB</env-entry-value>
</env-entry>
</message-driven>
I tried to put a breakpoint and evaluate new InitialContext().lookup("java:comp/env") then iterate through either list and listBindings but that will only bring me the env-entry section not what I want. 我试图放置一个断点并评估新的InitialContext()。lookup(“ java:comp / env”),然后遍历list和listBindings,但这只会带给我env-entry部分,而不是我想要的。
It is very frustrating as at run time I can inspect some elements and clearly able to see what I am after 这很令人沮丧,因为在运行时我可以检查一些元素并清楚地知道我要做什么。
javaNameSpaceImpl:{appName=someModule,_moduleName=someModuleEJB,_componentName=MyTestEJB,_bootstrapAddress=rir:…etc}
Any idea about how can this be achieved? 关于如何实现的任何想法?
Thank you in advance. 先感谢您。
There is no standard way to retrieve the component name. 没有标准的方法来检索组件名称。 I agree that it's unfortunate that there's no java:comp/CompName (ala java:app/AppName and java:module/ModuleName) or EJBContext.getName().
我同意,不幸的是,没有java:comp / CompName(ala java:app / AppName和java:module / ModuleName)或EJBContext.getName()。 My recommendation in the past has always been the env-entry approach, which I agree is not ideal.
我过去的建议始终是环境管理方法,我认为这并不理想。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.