Enterprise JavaBean 專案(EJB 2.0 至 EJB 2.1)

「J2EE 移轉精靈」支援將 Enterprise Bean 部署描述子從 J2EE 1.3 規格層次 EJB 資源移轉至 J2EE 1.4。Stateless Session Bean 和訊息驅動 Bean 會移轉至 J2EE 1.4。

移轉 Session Bean

「J2EE 移轉精靈」會在 Stateless Session Bean 上設定服務端點介面,以將 J2EE 1.3 中,在 EJB 專案的 webservices.xml 描述子中定義為服務端點介面 (SEI) 的 Stateless Session Bean 移轉至 J2EE 1.4 規格層次。

如果要將 Session Bean 用作 Web 服務端點,則 J2EE 1.4 規格需要在 Stateless Session Bean 上定義 SEI。在 EJB JAR 檔的移轉期間,EJB 專案中所有的 Session Bean 都會讓服務端點設定成 EJB 專案的 webservices.xml 描述子中所使用的名稱。下列範例顯示移轉至 J2EE 1.4 規格層次之前和之後,EJB 專案的 meta 資料看起來的樣子。

J2EE 1.3 中的 EJB 專案:在移轉之前的 webservices.xml 描述子,其中以 Stateless Session Bean 用作 Web 服務端點介面:

<?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> 標籤,在 J2EE 1.3 規格層次將 Stateless Session Bean "EchoEJB" 定義成 webservices 描述子中的服務端點。

J2EE 1.4 中的 EJB 專案:相同 Stateless Session 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。

訊息驅動 Bean 在 EJB 2.0 中導入,可支援處理來自 Java™ 訊息服務 (JMS) 的非同步訊息。EJB 2.1 規格擴大了訊息驅動 Bean 的定義,因而能夠支援任何傳訊系統,而不只是 JMS。

註: 已從 EJB 2.0 規格層次移轉至 EJB 2.1,並部署至 WebSphere® Application Server 第 6 版的訊息驅動 Bean,必須針對 Java 連接器架構 (JCA) 1.5 資源配接器來部署,而不是針對接聽器埠(如同在 WebSphere Application Server 第 5 版中)。您必須使用「部署描述子編輯器」來變更 EJB 2.1 訊息驅動 Bean 的「WebSphere 連結」設定,以使用 JCA 配接器。請參閱 將 EJB 2.1 訊息驅動 Bean 配置成使用 JCA 配接器。
所移轉的 EJB 2.0 訊息驅動 Bean 構件如下:
  • acknowledgeMode
  • messageSelector
  • destinationType
  • subscriptionDurablity
有些 EJB 2.0 訊息驅動 Bean 元素會被取代成 activation-config 內容。activation-config 內容中用來描述傳訊服務的內容名稱和值,會依所使用的訊息服務類型而有所不同。不過,EJB 2.1 會針對 JMS 型的訊息驅動 Bean 定義一組固定內容。

下列範例會將 EJB 2.0 中的 Bean 範例元素,與元素出現在 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>
Icon that indicates the type of topic Reference topic
Timestamp icon Last updated: last_date

File name: rv6ejbprojects.html