In this scenario you implement your service as a MDB. When it starts, the MDB notifies the FUSE Services Framework JCA Connector. The FUSE Services Framework 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 FUSE Services Framework JCA Connector's deployment descriptor. This means that you must
edit the FUSE Services Framework 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 FUSE Services Framework JCA Connector:
Write a MDB that implements the service that you want to expose. See, for instance,
GreeterBean.java located in
and
shown in Example 2.1.InstallDir/samples/integration/jca/inbound-mdb/src/demo/ejb
Example 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.xml file located in
and shown in Example 2.2.InstallDir/samples/integration/jca/inbound-mdb/etc
Example 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-jar element. 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 FUSE Services Framework JCA Connector's deployment descriptor file, ra.xml, which is located
in the samples/integration/jca/websphere/inbound-mdb/etc directory of your
installation.
Edit the ra.xml file so that the messagelistener-type element
defines the same interface as the messaging-type element defined in your MDB deployment
descriptor. This ensures that the FUSE Services Framework JCA Connector is notified when the MDB starts.
Build the FUSE Services Framework 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-INF | The ra.xml file that you modified. |
Root |
|
The sample application's build.xml file 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.home variable must be set to the
directory. This is done for you when you set
your environment (see Setting Up Your Environment in InstallDir
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.