Der J2EE-Migrationsassistent unterstützt die Migration von Enterprise-Bean-Implementierungsdeskriptoren von EJB-Ressourcen der Spezifikationsstufe J2EE 1.3 auf die Spezifikationsstufe J2EE 1.4. Session-Beans ohne Status und nachrichtengesteuerte Beans werden auf J2EE 1.4 migriert.
Die Spezifikation J2EE 1.4 erfordert, dass eine SEI als eine Session-Bean ohne Status definiert ist, falls die Session-Bean als ein Web-Service-Endpunkt verwendet wird. Während der Migration einer EJB-JAR-Datei wird für alle Session-Beans im EJB-Projekt der Serviceendpunkt auf den Namen gesetzt, der im Deskriptor webservices.xml des EJB-Projekts verwendet wird. Es folgt ein Beispiel für die Darstellung der Metadaten eines EJB-Projekts vor und nach der Migration auf die Spezifikationsstufe J2EE 1.4.
EJB-Projekt in J2EE 1.3: Deskriptor webservices.xml mit Session-Bean ohne Status, die vor der Migration als eine Web-Service-Endpunktschnittstelle verwendet wurde
<?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>Die Tags <service-endpoint-interface> und <service-impl-bean> im vorstehenden Beispiel definieren die Session-Bean ohne Status "EchoEJB" vor der Migration als einen Serviceendpunkt im Web-Service-Deskriptor auf der Spezifikationsstufe J2EE 1.3.
EJB-Projekt in J2EE 1.4: EJB-Implementierungsdeskriptor für die vorstehende Session-Bean ohne Status "EchoEJB" mit Serviceendpunktschnittstelle, die vom Migrationsprozess erstellt wurde
<?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>Der Tag <service-endpoint> im vorstehenden Beispiel definiert "EchoEJB" nach der Migration als einen Serviceendpunkt der Spezifikationsstufe J2EE 1.4.
Nachrichtengesteuerte Beans wurden in EJB 2.0 eingeführt, um die Verarbeitung asynchroner Nachrichten aus einem Java-Nachrichtenservice zu unterstützen. Die Spezifikationsstufe EJB 2.1 erweitert die Definition von nachrichtengesteuerten Beans, sodass sie jegliches Nachrichtensystem, nicht nur JMS, unterstützen können.
Im folgenden Beispiel werden Elemente einer Musterbean in EJB 2.0 mit der Darstellung der Elemente in EJB 2.1 verglichen.
Es folgt ein Beispiel für nachrichtengesteuerte Beanelemente in EJB 2.0:
<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>
Es folgt ein Beispiel für nachrichtengesteuerte Beanelemente in EJB 2.1:
<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>