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 に Service endpoint interface を設定することにより、 J2EE 1.3 の EJB プロジェクトの webservices.xml 記述子に service endpoint interfaces (SEI) として定義されているステートレス・セッション Bean を 1.4 仕様レベルに マイグレーションします。

J2EE 1.4 仕様では、セッション bean が Web サービスのエンドポイントとして 使用される場合、SEI がステートレス・セッション Bean に定義されている 必要があります。EJB JAR ファイルのマイグレーション中、 EJB プロジェクト内のすべてのセッション Bean では、EJB プロジェクトの webservices.xml 記述子で 使用されている名前にサービス・エンドポイントが設定されます。以下は、 J2EE 1.4 仕様レベルへのマイグレーションの 前と後で EJB プロジェクトのメタデータがどのように変化するかについて例を 示したものです。

J2EE 1.3 の EJB プロジェクト: マイグレーション前、 Web サービス・エンドポイントとして使用されるステートレス・セッション Bean を持つ 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> タグは、マイグレーション前、 J2EE 1.3 仕様レベルの webservices 記述子のサービス・エンドポイントとして ステートレス・セッション Bean "EchoEJB" を定義しています。

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 メッセージ駆動型 Bean から EJB 2.1 Java™ Message Service (JMS) タイプのメッセージ駆動型 Bean へのマイグレーションをサポートします。

メッセージ駆動型 Bean は、 Java Message Service (JMS) からの非同期メッセージの処理をサポートするために、EJB 2.0 で導入されました。EJB 2.1 仕様は、JMS だけでなく、あらゆるメッセージング・システムをサポートできるように、 メッセージ駆動型 Bean の定義を拡張しました。

マイグレーションされる 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>

親トピック: J2EE 1.3 から 1.4 仕様レベルへのマイグレーション

関連資料
Web プロジェクト (サーブレット・レベル 2.3 からサーブレット・レベル 2.4)
コネクター・プロジェクト (JCA 1.0 から JCA 1.5)
Web サービス (J2EE 1.3 から J2EE 1.4)
J2EE 1.3 から 1.4 仕様レベルへのマイグレーション

(C) Copyright IBM Corporation 2000, 2004. All Rights Reserved.