我如何为 JNDI 查找配置模块和应用程序名称 [英] How can i config module and application name for JNDI Lookups

查看:21
本文介绍了我如何为 JNDI 查找配置模块和应用程序名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 EJB 3.1 中,可以使用不同的查找名称进行 JNDI 查找:

In EJB 3.1 JNDI Lookups can be made with different Lookup-Names:

java:global[/<app-name>]/<module-name>/<bean-name>!<fully-qualifiedbean interface-name>           
java:global[/<app-name>]/<module-name>/<bean-name> 
java:app/<module-name>/<bean-name>!<fully-qualified-bean-interface-name> 
java:app/<module-name>/<bean-name> 
java:module/<bean-name>!<fully-qualified-bean-interface-name> 
java:module/<bean-name>

在我的 JavaEE 6 项目(使用 Maven 2、Netbeans 6 和 Glassfish v3)中,应用程序名称是 X-Snapshot.ear,EJB-Module 是 Y-Snapshot.jar.我如何配置这个 maven 项目以使用另一个应用程序和模块名称?当这个名字改变时,我不想改变所有的 JNDI 查找!!那么是否可以为 JNDI 查找配置应用程序和模块名称?

In my JavaEE 6 Project (with Maven 2, Netbeans 6 and Glassfish v3) the Application name is X-Snapshot.ear and the EJB-Module is Y-Snapshot.jar. How can i config this maven project to use another application and module name? I don't wnat to change all JNDI Lookups when this names change!! So is it possible to config application and module names for JNDI LookUps?

推荐答案

Naive approach

Maven EAR 插件允许 自定义模块文件名,您可以使用 project.build.finalName 设置最终名称或 EAR.

Naive approach

The Maven EAR Plugin allows to Customize A Module Filename and you can set the final name or the EAR using project.build.finalName.

覆盖application.xml中的ejb-jar.xml 分别.引用 EJB 3.1 中的可移植全局 JNDI 名称:

Override the <application-name> and the <module-name> in the application.xml and the ejb-jar.xml respectively. Quoting Portable Global JNDI name in EJB 3.1:

除了上面的名字,如果EJB 只公开一个客户端视图(也就是说它只实现了一个界面或无界面视图),容器也被要求映射把豆子

In addition to the above name, if the EJB exposes just a single client view (that is it implements just one interface or the no interface view), the container is also mandated to map the bean to

java:global/[<application-name>]/<module-name>/<bean-name>

哪里

  1. 默认为包名(.ear 文件名),没有捆绑扩展.这可以在 application.xml 中被覆盖.还, 适用只有当 bean 被包装在一个.ear 文件.
  2. 默认为包名(.war.jar),没有捆绑扩展.再次,这可以是在 ejb-jar.xml 中被覆盖.
  3. 默认为 bean 的非限定类名.但是,如果 @Stateful@Stateless@Singleton 使用name 属性,然后是值指定将用作豆名.
  1. <aplication-name> defaults to the bundle name (.ear file name) without the bundle extension. This can be overridden in application.xml. Also, <application-name> is applicable only if the bean is packaged inside a .ear file.
  2. <module-name> defaults to bundle name (.war or .jar) without the bundle extension. Again, this can be overridden in ejb-jar.xml.
  3. <bean-name> defaults to the unqualified class name of the bean. However, if @Stateful or @Stateless or @Singleton uses the name attribute, then the value specified there will be used as the bean name.

这篇关于我如何为 JNDI 查找配置模块和应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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