Enterprise JavaBean 项目(EJB 2.0 至 EJB 2.1)

J2EE 迁移向导支持将企业 Bean 部署描述符从 J2EE 1.3 规范级别 EJB 资源迁移至 J2EE 1.4。无状态会话 Bean 和消息驱动的 Bean 会被迁移至 J2EE 1.4。

迁移会话 Bean

J2EE 迁移向导通过设置无状态会话 Bean 上的服务端点接口,将 J2EE 1.3 中定义为 EJB 项目的 webservices.xml 描述符中的服务端点接口 (SEI) 的无状态会话 Bean 迁移至 J2EE 1.4 规范级别。

如果要将无状态会话 Bean 用作 Web Service 端点,那么 J2EE 1.4 规范在该会话 Bean 上定义一个 SEI。在 EJB JAR 文件的迁移期间,EJB 项目中的所有会话 Bean 都会获得已设置到 EJB 项目的 webservices.xml 描述符中所使用的名称的服务端点。以下是 EJB 项目的元数据在迁移至 J2EE 1.4 规范级别前后的外观示例。

J2EE 1.3 中的 EJB 项目:带有已在迁移之前将无状态会话 Bean 用作 Web Service 端点的 webservices.xml 描述符:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE webservices PUBLIC "-//IBM Corporation, Inc.//DTD J2EE Web services 1.0//EN" 
"http://www.ibm.com/webservices/dtd/j2ee_web_services_1_0.dtd">
   <webservices id="WebServices_1084831328093">
      <webservice-description id="WebServiceDescription_1084831328093">
         <webservice-description-name>EchoEJBService</webservice-description-name>
         <wsdl-file>META-INF/wsdl/EchoEJB.wsdl</wsdl-file>
         <jaxrpc-mapping-file>META-INF/EchoEJB_mapping.xml</jaxrpc-mapping-file>
         <port-component id="PortComponent_1084831328103">
            <port-component-name>EchoEJB</port-component-name>
            <wsdl-port id="WSDLPort_1084831328103">
               <namespaceURI>http://test</namespaceURI>
               <localpart>EchoEJB</localpart>
            </wsdl-port>
            <service-endpoint-interface>test.EchoEJB</service-endpoint-interface>
            <service-impl-bean id="ServiceImplBean_1084831328103">
               <ejb-link>EchoEJB</ejb-link>
            </service-impl-bean>
         </port-component>
      </webservice-description>
   </webservices>
上述示例中的 <service-endpoint-interface><service-impl-bean> 标记将无状态会话 Bean“EchoEJB”定义为迁移之前 J2EE 1.3 规范级别的 webservices 描述符中的服务端点。
J2EE 1.4 中的 EJB 项目:带有由迁移过程创建的服务端点接口的相同无状态会话 Bean“EchoEJB”的 EJB 部署描述符:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
      	<display-name>
	EchoEJBProject</display-name>
	<enterprise-beans>
		<session id="EchoEJB">
			<ejb-name>EchoEJB</ejb-name>
			<home>test.EchoEJBHome</home>
			<remote>test.EchoEJB</remote>
			<service-endpoint>test.EchoEJB</service-endpoint>
			<ejb-class>test.EchoEJBBean</ejb-class>
			<session-type>Stateless</session-type>
			<transaction-type>Container</transaction-type>
		</session>
	</enterprise-beans>
</ejb-jar>
上述示例中的 <service-endpoint> 标记将“EchoEJB”定义为迁移之后 J2EE 1.4 规范级别中的服务端点。

迁移消息驱动的 Bean

J2EE 迁移向导支持 EJB 2.0 至 EJB 2.1 消息驱动的 Bean 的迁移。

EJB 2.0 中引入了消息驱动的 Bean 以支持处理来自 Java™ 消息服务 (JMS) 的异步消息。EJB 2.1 规范扩展了消息驱动的 Bean 的定义,以便它可以支持任何消息传递系统,而不仅限于支持 JMS。

注: 已从 EJB 2.0 规范级别迁移至 EJB 2.1 且已部署至 WebSphere® Application Server V6 的消息驱动的 Bean,必须针对 Java 连接器体系结构 (JCA) 1.5 资源适配器进行部署,而不是针对侦听器端口进行部署(如 WebSphere Application Server V5 中)。您必须使用部署描述符编辑器来更改 EJB 2.1 消息驱动的 Bean 的 WebSphere 绑定设置以使用 JCA 适配器。 请参阅配置 EJB 2.1 消息驱动的 Bean 以使用 JCA 适配器
所迁移的 EJB 2.0 消息驱动的 Bean 工件为:
  • 应答方式
  • messageSelector
  • destinationType
  • subscriptionDurablity
某些 EJB 2.0 消息驱动的 Bean 元素将替换为 activation-config 属性。 activation-config 属性中用于描述消息传递服务的属性名称和值将根据所使用的消息服务的类型而变化。但是,EJB 2.1 为基于 JMS 的消息驱动的 Bean 定义一组固定属性。

以下示例将样本 Bean 的元素在 EJB 2.0 中以及在 EJB 2.1 中的外观进行了比较。

EJB 2.0 中消息驱动的 Bean 元素的示例:
<message-driven id="Mdb20">
	  <ejb-name>Mdb</ejb-name>
	  <ejb-class>ejbs.MdbBean</ejb-class>
<transaction-type>Bean</transaction-type>
	  <message-selector>mdbMessage</message-selector>
	  <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
	  <message-driven-destination>
		<destination-type>javax.jms.Topic</destination-type>
		<subscription-durability>Durable</subscription-durability>
	   </message-driven-destination>
</message-driven>
EJB 2.1 中消息驱动的 Bean 元素的示例:
    <message-driven id="Mdb21">
  <ejb-name>Foo/ejb-name>
  <ejb-class>ejbs.FooBean</ejb-class>
   <messaging-type>javax.jms.MessageListener</messaging-type>
   <transaction-type>Bean/transaction-type>
   <message-destination-type>javax.jms.Topic</message-destination-type>
    <activation-config>
	 <activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
	   <activation-config-property-value>javax.jms.Topic</activation-config-property-value>
	 </activation-config-property>
	 <activation-config-property>
	   <activation-config-property-name>subscriptionDurability</activation-config-property-name>
	     <activation-config-property-value>Durable</activation-config-property-value>
	 </activation-config-property>
	 <activation-config-property>
	     <activation-config-property-name>acknowledgeMode</activation-config-property-name>
	     <activation-config-property-value>AutoAcknowledge</activation-config-property-value>
	  </activation-config-property>
	  <activation-config-property>
		<activation-config-property-name>messageSelector</activation-config-property-name>
		<activation-config-property-value>fooSelector</activation-config-property-value>
	  </activation-config-property>
</activation-config>
</message-driven>
指示主题类型的图标 参考主题
信息中心的条款和条件 | 反馈

时间戳记图标 最近一次更新时间: 2014 年 4 月 17 日

文件名:rv6ejbprojects.html