LibraryLink ToToggle FramesPrintFeedback

Service Implemented as a Stateless Session Bean

In this scenario you implement your service as a Stateless Session Bean (SLSB). FUSE Services Framework provides a generic MDB implementation that notifies the FUSE Services Framework JCA Connector when it starts. The FUSE Services Framework JCA Connector then activates the FUSE Services Framework service endpoint facade, which dispatches client requests to the generic MDB. The MDB dispatches incoming requests to your SLSB, using the SLSB's EJB local reference (as implemented in its Local Home interface).

The advantage of this approach is that you do not have to edit the FUSE Services Framework JCA Connector deployment descriptor.

In addition, there is no need for a service WSDL file. FUSE Services Framework uses the service endpoint interface to build a service model as it is defined in the activation specification serviceInterfaceClass property in your application's deployment descriptor file, ejb-jar.xml.

The disadvantage of this approach is that it may not preform as fast as the approach described in Service Implemented as a Message Driven Bean.

FUSE Services Framework includes a working example of this scenario. You can find it in the samples/integration/jca/inbound-mdb-dispatch directory of your FUSE Services Framework installation.

If you want to build and run this sample, please follow the instructions outlined in the README.txt file located in this directory. The example code shown in this section is taken from this sample application.

Complete the following steps to expose your J2EE application, implemented as a SLSB, as a Web service using the FUSE Services Framework JCA Connector:

  1. Write a SLSB that implements the service that you want to expose. See, for instance, GreeterBean.java located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/src/demo/ejb and shown in Example 2.5.


  2. Write an EJB Local Home interface for your SLSB. See, for instance, GreeterLocalHome.java located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/src/demo/ejb and shown in Example 2.6.


  3. Write a deployment descriptor for your SLSB and ensure that it includes:

    See, for instance, the ejb-jar.xml located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/etc and shown in Example 2.7.

    Example 2.7. Stateless Session Bean Deployment Descriptor—ejb-jar.xml

    <?xml version="1.0"?>
                                ...
    <ejb-jar 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"
           version="2.1">
                                    
       <enterprise-beans>
          <session>
             <ejb-name>DispatchedGreeterBean</ejb-name>
             <home>demo.ejb.GreeterHome</home>
             <remote>demo.ejb.GreeterRemote</remote>
             <local-home>demo.ejb.GreeterLocalHome</local-home>
             <local>demo.ejb.GreeterLocal</local>
             <ejb-class>demo.ejb.GreeterBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
           </session>
                                        
           <message-driven>
             <ejb-name>GreeterEndpointActivator</ejb-name>
             <ejb-class>org.apache.cxf.jca.inbound.DispatchMDBMessageListenerImpl</ejb-class>
             <messaging-type>org.apache.cxf.jca.inbound.DispatchMDBMessageListener
             </messaging-type>
             <transaction-type>Bean</transaction-type>
                                            
             <activation-config>
                  <!-- display name-->
                  <activation-config-property>
                      <activation-config-property-name>
                         DisplayName
                      </activation-config-property-name>
                      <activation-config-property-value>
                         DispatchedGreeterEndpoint
                      </activation-config-property-value>
                  </activation-config-property>
                  <!-- service endpoint interface -->
                  <activation-config-property>
                      <activation-config-property-name>
                         serviceInterfaceClass
                      </activation-config-property-name>
                      <activation-config-property-value>
                         org.apache.hello_world_soap_http.Greeter
                      </activation-config-property-value>
                  </activation-config-property>
                  <!-- address -->
                  <activation-config-property>
                      <activation-config-property-name>
                         address
                      </activation-config-property-name>
                      <activation-config-property-value>
                         http://localhost:9999/GreeterBean
                      </activation-config-property-value>
                  </activation-config-property>
                  <!-- targetBeanJndiName -->
                  <activation-config-property>
                      <activation-config-property-name>
                          targetBeanJndiName
                     </activation-config-property-name>
                     <activation-config-property-value>
                         java:comp/env/DispatchedGreeterLocalHome
                     </activation-config-property-value>
                  </activation-config-property>
              </activation-config>
                                       
              <ejb-local-ref>
                  <ejb-ref-name>DispatchedGreeterLocalHome</ejb-ref-name>
                  <ejb-ref-type>Session</ejb-ref-type>
                  <local-home>demo.ejb.GreeterLocalHome</local-home>
                  <local>demo.ejb.GreeterLocal</local>
                  <ejb-link>DispatchedGreeterBean</ejb-link>
              </ejb-local-ref>
           </message-driven>
                                        
         </enterprise-beans>
    </ejb-jar>

    For more information about the supported activation configuration properties, see Inbound Activation Configuration.

    If you are using EJB 3.0, the only change you need to make to the deployment descriptor is in the opening ejb-jar element. For EJB 3.0 it should read as shown in Example 2.3.

  4. Package your application in an EJB JAR file.

  5. Build the FUSE Services Framework JCA Connector RAR file. It must have the following structure and contents:

    1. META-INF directory — Must contain the ra.xml, located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/etc.

    2. Root directory — Must contain the JAR files listed under Root in Table 2.1.

    The sample application's build.xml file includes a generate.rar target that you can use to build the RAR file (see Example 2.4).

    Note that the ra.xml file activation spec is set to org.apache.cxf.jca.inbound.DispatchMDBActivationSpec, which includes a targetBeanJndiName configuration property that enables you to specify your SLSB's JNDI name.

  6. Deploy the FUSE Services Framework JCA Connector RAR file and your EJB JAR file to your J2EE application server. For details, see Deploying FUSE Services Framework JCA Connector.