J2EE 移轉精靈支援將 Enterprise Bean 部署描述子從 J2EE 1.3 規格層次的 EJB 資源移轉至 J2EE 1.4。Stateless Session Bean 和訊息驅動 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 專案:在移轉之前,以 Stateless Session Bean 為 Web 服務端點介面的 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> 標示將 Stateless Session Bean "EchoEJB" 定義成 J2EE 1.3 規格層次之 Web 服務描述子中的服務端點。
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 規格層次的服務端點。
EJB 2.0 引進訊息驅動 Bean 來支援處理 Java 傳訊服務 (JMS) 所發出的非同步訊息。 EJB 2.1 規格擴充了訊息驅動 Bean 的定義,使它能夠支援任何傳訊系統,而不只是 JMS。
下列範例比較 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>