In this scenario you implement your service as a MDB. When it starts, the MDB notifies the Apache CXF JCA Connector. The Apache CXF JCA Connector activates the Fuse Services Framework service endpoint facade, which receives client requests and invokes directly on the MDB. Incoming invocations do not have to be dispatched to another EJB.
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 advantages of using this approach is that it preforms faster than either of the SLSB scenarios because the MDB does not need to dispatch incoming requests to another EJB.
In addition, you do not need to implement EJB Home, Local or Remote interfaces.
The disadvantage of this approach is that the service endpoint interface has to be exposed as the
messagelistener-type element in the Apache CXF JCA Connector's deployment descriptor. This means that you must
edit the Apache CXF JCA Connector's deployment descriptor file.
Fuse Services Framework includes a working example of this scenario. It is located in the
samples/integration/jca/inbound-mdb 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 MDB, as a Web service using the Apache CXF JCA Connector:
Write a MDB that implements the service that you want to expose. See, for instance,
GreeterBean.javalocated inand shown in Example 2.1.InstallDir/samples/integration/jca/inbound-mdb/src/demo/ejbExample 2.1. Message Driven Bean—GreeterBean.java
package demo.ejb; import javax.ejb.MessageDrivenBean; import javax.ejb.MessageDrivenContext; import org.apache.hello_world_soap_http.Greeter; public class GreeterBean implements MessageDrivenBean, Greeter { public String sayHi() { System.out.println("sayHi called "); return "Hi there!"; } public String greetMe(String user) { System.out.println("greetMe called user = " + user); return "Hello " + user; } //---------------- EJB Methods public void ejbCreate() { } public void ejbRemove() { } public void setMessageDrivenContext(MessageDrivenContext mdc) { } }Write a deployment descriptor for your MDB. See, for instance, the
ejb-jar.xmlfile located inand shown in Example 2.2.InstallDir/samples/integration/jca/inbound-mdb/etcExample 2.2. Message Driven 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> <message-driven> <ejb-name>Greeter MDB</ejb-name> <ejb-class>demo.ejb.GreeterBean</ejb-class> <messaging-type> org.apache.hello_world_soap_http.Greeter </messaging-type> <transaction-type>Bean</transaction-type> <activation-config> <!-- displayName --> <activation-config-property> <activation-config-property-name> displayName </activation-config-property-name> <activation-config-property-value> MyCxfEndpoint </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> </activation-config> </message-driven> </enterprise-beans> <assembly-descriptor> <method-permission> <unchecked/> <method> <ejb-name>GreeterBean</ejb-name> <method-name>*</method-name> </method> </method-permission> <container-transaction> <description/> <method> <description/> <ejb-name>GreeterBean</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Supports</trans-attribute> </container-transaction> </assembly-descriptor> </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-jarelement. For EJB 3.0 it should read as shown in Example 2.3.Example 2.3. EJB 3.0 Deployment Descriptor
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
Package you application in an EJB JAR file.
Make a copy of the Apache CXF JCA Connector's deployment descriptor file,
ra.xml, which is located in thesamples/integration/jca/websphere/inbound-mdb/etcdirectory of your installation.Edit the
ra.xmlfile so that themessagelistener-typeelement defines the same interface as themessaging-typeelement defined in your MDB deployment descriptor. This ensures that the Apache CXF JCA Connector is notified when the MDB starts.Build the Apache CXF JCA Connector RAR file. It must have the following structure and contents:
Table 2.1. RAR File Structure and Contents: Service Implemented as MDB
Directory Contents META-INFThe ra.xmlfile that you modified.RootAll of the JARs in the
modulesdirectory of the Fuse Services Framework installation, except the*manifest*.jarfiles.The
cxf-integration-jca-*.jars from themodules/integrationdirectory of the Fuse Services Framework installation.All of the JARs in the
libdirectory of the Fuse Services Framework installation, except thecxf*.jarfiles.
The sample application's
build.xmlfile includes a generate.rar target that builds the RAR file (see Example 2.4).Example 2.4. generate.rar Target
<target name="generate.rar" depends="init"> <copy file="${basedir}/etc/ra.xml" todir="${build.classes.dir}/cxf-rar/META-INF"/> <copy todir="${build.classes.dir}/cxf-rar"> <fileset dir="${cxf.home}/lib"> <include name="*.jar"/> <exclude name="cxf*.jar"/> </fileset> <fileset dir="${cxf.home}/modules"> <include name="*.jar"/> <exclude name="*manifest*.jar"/> </fileset> <fileset dir="${cxf.home}/modules/integration"> <include name="*.jar"/> <exclude name="*-jbi-*.jar" /> </fileset> </copy> <jar destfile="${build.classes.dir}/lib/cxf.rar" basedir="${build.classes.dir}/cxf-rar"/> </target>The
cxf.homevariable must be set to thedirectory. This is done for you when you set your environment (see Setting Up Your Environment in Configuring and Deploying Web Service Endpoints.InstallDirDeploy the Apache CXF JCA Connector RAR file and your EJB JAR file to your J2EE application server. For details, see Deploying Apache CXF JCA Connector.








