EJB中@Resource注释的mappedName和lookup属性有什么区别? [英] What is the difference between mappedName and lookup attributes of @Resource annotation in EJB?

查看:1597
本文介绍了EJB中@Resource注释的mappedName和lookup属性有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Java文档说:

mappedName:此资源应映射到的特定于产品的名称。此资源的名称,由name元素或默认值定义,是使用该资源的应用程序组件本地的名称。 (它是JNDI java:comp / env命名空间中的一个名称)许多应用程序服务器提供了一种将这些本地名称映射到应用程序服务器已知的资源名称的方法。此映射名称通常是全局JNDI名称,但可以是任何形式的名称。

查找:引用指向的资源的名称。它可以使用全局JNDI名称链接到任何兼容的资源。


我的问题是如何在 mappedName



解决方案

p>正如它所说的 mappedName 是具体的产品,许多应用服务器不支持。所以现在你应该使用 lookup ,因为它应该是便携式和跨平台的。您指定给定资源的全局JNDI。


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?

解决方案

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.

这篇关于EJB中@Resource注释的mappedName和lookup属性有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆