세션 Bean이 웹 서비스 엔드포인트로 사용되어야 하는 경우 J2EE 1.4 스펙에는 Stateless 세션 Bean에 SEI가 정의되어 있어야 합니다. EJB JAR 파일을 마이그레이션하는 동안 EJB 프로젝트에 있는 모든 세션 Bean의 서비스 엔드포인트는 EJB 프로젝트의 webservices.xml 디스크립터에 사용된 이름으로 설정됩니다. 다음은 J2EE 1.4 스펙 레벨로의 마이그레이션 전후 EJB 프로젝트 메타데이터의 모양에 대한 예제입니다.
J2EE 1.3의 EJB 프로젝트: 마이그레이션 전 웹 서비스 엔드포인트 인터페이스로 사용된 Stateless 세션 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 스펙 레벨에서
Stateless 세션 Bean "EchoEJB"를 웹 서비스 디스크립터의 서비스 엔드포인트로
정의합니다. J2EE 1.4의 EJB 프로젝트: 마이그레이션 프로세스에 의해 작성된 서비스 엔드포인트 인터페이스가 있는 동일한 Stateless 세션 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은 JMS(Java™ Message Service)로부터의 비동기 메시지 처리를 지원하기 위해 EJB 2.0에서 소개되었습니다. 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>