J2EE 1.4 仕様では、 ステートレス・セッション Bean を Web サービス・エンドポイントとして使用する場合には、 そのセッション Bean に SEI が定義されている必要があります。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 仕様レベルの Web サービス記述子にサービス・エンドポイントとしてステートレス・セッション 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> タグは、
マイグレーション後に、J2EE 1.4 仕様レベルのサービス・エンドポイントとして "EchoEJB" を定義しています。メッセージ駆動型 Bean は、Java™ Message Service (JMS) からの非同期メッセージの処理をサポートするために EJB 2.0 において導入されたものです。 EJB 2.1 仕様は、メッセージ駆動型 Bean が 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>