WAR模块中的包装企业Bean

时间:2013-11-01 09:36:35

标签: java-ee jar ejb war packaging

JavaEE 7 tutorial

提到以下内容

Enterprise beans often provide the business logic of a web application. In these cases,
packaging the enterprise bean within the web application's WAR module simplifies
deployment and application organization. Enterprise beans may be packaged within a
WAR module as Java programming language class files or within a JAR file that is
bundled within the WAR module.

然后过了一会儿

JAR files that contain enterprise bean classes packaged within a WAR module are not
considered EJB JAR files, even if the bundled JAR file conforms to the format of an EJB
JAR file. The enterprise beans contained within the JAR file are semantically
equivalent to enterprise beans located in the WAR module's WEB-INF/classes directory,
and the environment namespace of all the enterprise beans are scoped to the WAR module.

我无法通过这一部分来理解这个例子。

怎么可能

企业bean可以作为Java编程语言类文件打包在WAR模块中,也可以打包在WAR模块中捆绑的JAR文件中

包含在WAR模块中打包的企业bean类的JAR文件不被视为EJB JAR文件,即使捆绑的JAR文件符合EJB JAR文件的格式。

1 个答案:

答案 0 :(得分:3)

规范试图说明在WEB-INF/classes/中的类或WEB-INF/lib/中的JAR中可以识别EJB注释,但是如果您决定将预先存在的EJB模块JAR移动到{{1}它将被解释为常规JAR,而不是独立的EJB模块,这意味着将忽略该JAR中特定于模块的部署描述符(例如,WEB-INF/lib/META-INF/ejb-jar.xml,{{1等等)。相反,这些描述符需要合并在一起并放入包含WAR的META-INF/validation.xml(例如,META-INF/beans.xml等)。