What is the difference between mappedName and lookup attributes of @Resource annotation in EJB?

蹲街弑〆低调 提交于 2019-12-22 05:23:36

问题


I'm confused between two attributes of @Resource annotation.

Java Documentations says :
mappedName : A product specific name that this resource should be mapped to. The name of this resource, as defined by the name element or defaulted, is a name that is local to the application component using the resource. (It's a name in the JNDI java:comp/env namespace.) Many application servers provide a way to map these local names to names of resources known to the application server. This mapped name is often a global JNDI name, but may be a name of any form.
lookup : The name of the resource that the reference points to. It can link to any compatible resource using the global JNDI names.

My Question is how to choose between mappedName and lookup, based on what criteria?


回答1:


Just as it says mappedName is product specific and is not supported by many application servers. So for now you should use lookup as it should be portable and cross platform. You specify global JNDI of the given resource.



来源:https://stackoverflow.com/questions/25033088/what-is-the-difference-between-mappedname-and-lookup-attributes-of-resource-ann

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