简体   繁体   English

我们在EJB 3.0中提供JNDI名称的位置?

[英]where do we provide the JNDI name in EJB 3.0?

I am going through the example doc for EJB on below URL 我将通过以下URL浏览EJB的示例文档

http://docs.oracle.com/cd/E11035_01/wls100/ejb30/examples.html#wp1200600 http://docs.oracle.com/cd/E11035_01/wls100/ejb30/examples.html#wp1200600

As far as I know in EJB 2.0 we give JNDI name in deployment descriptor in ejb-jar.xml or weblogic-ejb-jar.xml file but in EJB 3.0, I can not find such descriptor where it contains JNDI name. 据我所知,在EJB 2.0中,我们在ejb-jar.xml或weblogic-ejb-jar.xml文件中的部署描述符中给出了JNDI名称,但在EJB 3.0中,我找不到包含JNDI名称的描述符。

Can you please suggest where do we provide the JNDI & EJB names so that client can invoke the EJB? 您能否建议我们在哪里提供JNDI和EJB名称,以便客户端可以调用EJB?

Bindings support in the EJB container has been expanded. 扩展了EJB容器中的绑定支持。 The EJB container assigns default JNDI bindings for EJB 3.x business interfaces based on application name, module name, and component name. EJB容器根据应用程序名称,模块名称和组件名称为EJB 3.x业务接口分配缺省JNDI绑定。 You do not have to explicitly define JNDI binding names for each of the interfaces or EJB homes within an EJB 3.x module or no-interface views within an EJB 3.1 module. 您不必为EJB 3.x模块中的每个接口或EJB主目录或EJB 3.1模块中的无接口视图显式定义JNDI绑定名称。

When defining bindings, you specify Java Naming and Directory Interface (JNDI) names for the referenceable and referenced artifacts in an application. 定义绑定时,可以为应用程序中的可引用和引用工件指定Java命名和目录接口(JNDI)名称。 The jndiName values specified for artifacts must be qualified lookup names. 为工件指定的jndiName值必须是限定的查找名称。

You do not need to manually assign JNDI bindings names for each of the interfaces, EJB homes, or no-interface views on your enterprise beans in EJB 3.x modules . 您无需为EJB 3.x模块中的企业bean上的每个接口,EJB主目录或无接口视图手动分配JNDI绑定名称 If you do not explicitly assign bindings, the EJB container assigns default bindings. 如果未显式分配绑定,EJB容器将分配默认绑定。

So, it seems to change the name you will have to configure the specific deployment descriptor for your container. 因此,它似乎更改了为容器配置特定部署描述符所需的名称。


How to specify a different jndi-name than the default for an EJB in JBoss 4.2.2.GA? 如何在JBoss 4.2.2.GA中为EJB指定一个不同于jdei-name的jndi-name?


EDITED: 编辑:

Here more information for weblogic : 这里有关于weblogic的更多信息:

In the book "Oracle WebLogic Server" (written by Robert Patrick, Gregory Nyberg, and Philip Aston, with Josh Bregman and Paul Done) Chapter 6: Building Enterprise JavaBeans in WebLogic Server Page 194 " WebLogic Server provides two options for mapping a session bean's remote business interfaces into the global JNDI tree. The mapping can be specified in the weblogic-ejb-jar.xml deployment descriptor or the mappedName element of the @ Stateless or @ Stateful annotations can be used." 在“Oracle WebLogic Server”一书中(由Robert Patrick,Gregory Nyberg和Philip Aston编写,与Josh Bregman和Paul Done一起编写)第6章:在WebLogic Server中构建Enterprise JavaBeans Page 194“WebLogic Server提供了两种映射会话bean的选项远程业务接口到全局JNDI树。映射可以在weblogic-ejb-jar.xml部署描述符中指定,或者可以使用@Stateless或@Stateful注释的mappedName元素。 So there is no default jndi name if you do not use mappedName or weblogic-ejb-jar.xml 因此,如果不使用mappedName或weblogic-ejb-jar.xml,则没有默认的jndi名称

Weblogic 10.3.5 & EJB 3 JNDI names Weblogic 10.3.5和EJB 3 JNDI名称

WebLogic 12 (other servers may act differently) WebLogic 12 (其他服务器可能采取不同的行为)

when using the @EJB annotation, container by default assigns the name to the bean 使用@EJB注释时,默认情况下容器会将名称分配给bean

@Singleton
@Startup
public class PoolOracleBean {
/** some code **/
}

and it can be access by the code: 它可以通过代码访问:

InitialContext initialContext = new InitialContext();
Context context = (Context)initialContext.lookup("java:global/web");
PoolOracleBean pool = (PoolOracleBean)context.lookup("PoolOracleBean");
Connection connection = pool.getConnection();
...

to get a list of all annotated @EJB, in the console: 在控制台中获取所有带注释的@EJB的列表:

Environement --> Servers --> "server name" --> View JNDI Tree

there is java:global node with web sub-node 有一个带有web子节点的java:global节点

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

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