本文介绍了EJB,JNDI和ENC-现实生活场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在准备EJB认证,并且正准备阅读EJB 3.1(O'Reilly)一书

I am preparing for the EJB certification and I am going thro the EJB 3.1 book (O'Reilly)

其中一章讨论了有关JNDI,ENC和EJB连接

One of the chapters discusses about JNDI, ENC and the EJB connections

你们中的某些人能给我一个现实的生活场景吗,以便我能更好地理解

Can some of you give me a real life scenario of these so that I can get a better understandin

推荐答案

在此方案中,JNDI用作中心位置,通过该中心位置,名称(一种URL)被路由到EJB bean。想一想Servlet是如何映射到URL的。

JNDI in this scenario is used as a central location through which 'names' (a kind of URL) are routed to an EJB bean. Think of it how a Servlet is mapped to a URL.

如果EJB bean对应用程序是本地的(例如,它们位于Web模块的Web模块中或EJB模块中) EAR),那么您不必一定要与JNDI联系。也就是说,您可能会使用注入来获取bean的实例,然后就不需要JNDI。

If EJB beans are local to an application (e.g. they reside within the web module or within the EJB module of the same EAR), then you don't necessarily need to come into contact with JNDI. Namely, you'd probably use injection to get instances of your bean and no JNDI is needed then.

但是,如果您需要在远程服务器中处理EJB bean,或者,如果您想以编程方式查找bean(作为代理),则可以使用其JNDI名称和JNDI来获取它。

However, if you need to address an EJB bean in a remote server or if you want to lookup (a proxy to) a bean programmatically, you'd use its JNDI name and JNDI to get hold of it.

更多信息,请参见信息,包括ENC:

See this for some more info, including ENC: Declaring @Resource and @EJB at the class level in Java EE6

这篇关于EJB,JNDI和ENC-现实生活场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 23:41