The EJB Sender and Receiver Xbeans

Function

The EJB Sender is a sink Xbean that sends a DOM document to an EJB Receiver . The EJB Receiver is a stateless session bean that receives the DOM document and passes it on to the next Xbean in the Xbean channel. The EJB Receiver can be deployed in any J2EE compliant ejb container, such as Weblogic, JBoss, WebSphere, Borland Application Server, etc.

EJB Sender XBean Properties

id The name in the JNDI naming service identifying the EJB receiver Xbean. In particular, this is the name of the receiver's home that is added to JNDI when the receiver is deployed.

 compression

Setting this property to true causes the sender to compress the document using GZIP compression prior to sending it. 

EJB Receiver XBean

The EJB receiver is a stateless session bean. It is deployed into an ejb container. It does not have any Java Bean properties. Instead, all configuration is done in the ejb-jar.xml and application server specific configuration files.

id

The EJB receiver's identifier is established in an application server specific fashion. For example, with the WebLogic application server it is established in the weblogic-ejb-jar.xml file using the <jndi-name> tag.

 compression

Compression is determined dynamically and automatically. There is no need to configure compression on the receiver side.
DOMListener The DOMListener is set in ejb-jar.xml as an <env-entry> parameter, named domListener. If you have a single Xbean as a DOMListener, then you can set the parameter to be that Xbean. If on the other hand, you have several Xbeans forming a channel, you need to write a class that implements the DOMListener interface, instantiates and configures the channel and calls the first Xbean in the channel when documentReady is called by the EJB receiver.

Sample ejb-jar.xml file

The Xbeans release comes with a sample ejb-jar.xml file for deploying the ejb receiver. The file is in lib/ejbxbean.jar and the <session> tag is shown below. Note the setting of the domListener in the <env-entry> tag.

      <session id="org.xbeans.communication.ejb.receiver.Receiver">
         <description><![CDATA[This is the EJB Receiver Xbean]]></description>
         <display-name>EJB Receiver Xbean</display-name>
         <ejb-name>org.xbeans.communication.ejb.receiver.Receiver</ejb-name>
         <home>org.xbeans.communication.ejb.receiver.ReceiverHome</home>
         <remote>org.xbeans.communication.ejb.receiver.Receiver</remote>
         <ejb-class>org.xbeans.communication.ejb.receiver.ReceiverBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
         <env-entry>
            <env-entry-name>domListener</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>org.xbeans.tests.ReceiverDemoClass</env-entry-value>
         </env-entry>
      </session>

 

Using the EJB Sender

The sender Xbean is in the org.xbeans.communication.ejb.sender package. The sender can be imported into Java source code as follows:

import org.xbeans.communication.ejb.sender.SenderBean;

Creating a sender Xbean is accomplished by instantiating the class:

SenderBean sender = new SenderBean();

Note that if you are using a Java Bean design tools found in many Java Integrated Development Environments, the above code is generated automatically when you drag and drop a sender Xbean into your application.

After creating the sender Xbean, you must set the id property. For example:

sender.setId("my-receiver");

You need to get a DOM document by registering the sender with the previous Xbean in the channel.

previousXbean.setDOMListener(sender);

Again, if you are using a Java Bean design tool, the above calls to set properties may be automatically generated for you.

 

Source files

source/org/xbeans/communication/ejb/*.java
source/org/xbeans/communication/rmi/XMLReceiver.java
lib/ejbxbean.jar