The Generic Sender and Receiver Xbeans

Function

The generic Sender is a sink Xbean that sends a DOM document to a Receiver. The protocol that is used is established by setting a protocol property. The generic sender then dynamically loads the correct Xbean sender that implements that protocol. The protocol can be corba, ejb, http, rmi, servlet or soap.

The generic Receiver is a source Xbean that receives the DOM document and passes it on to the next Xbean in the Xbean channel. The protocol that is used is established by setting a protocol property. The protocol can be corba, http, or rmi. The ejb, servlet and soap receivers are not supported because they must be deployed individually into a J2EE application server according to their own procedures.

Generic Sender XBean Properties

protocol The protocol to be used by the generic sender. The generic sender dynamically loads the correct Xbean sender that implements that protocol. The protocol can be corba, ejb, http, rmi, servlet or soap.
id The identifier used for finding the receiver Xbean.  The exact form of the identifier is protocol specific.

 compression

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

Generic Receiver XBean Properties

protocol The protocol used by the generic receiver Xbean. The generic receiver dynamically loads the correct Xbean receiver that implements that protocol.The protocol can be corba, http, or rmi.
id The identifier used to advertise the services of the receiver Xbean. The exact form of the identifier is protocol specific. The http receiver ignores this property since the receiver is identified by a URL.

 compression

The receiver dynamically figures out if the document is compressed. The receiver bean ignores the compression property. 
DOMListener As with all source Xbeans, the DOMListener property is the next Xbean in the channel. The DOMListener receives the DOM produced by receiver Xbean.

Using the Generic Sender

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

import org.xbeans.communication.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 protocol and id properties. For example:

sender.setProtocol("rmi");
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.

Using the Generic Receiver

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

import org.xbeans.communication.receiver.ReceiverBean;

Creating a receiver Xbean is accomplished by instantiating the class:

ReceiverBean receiver = new ReceiverBean();

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 receiver Xbean, you must set the protocol and id properties. For example:

receiver.setProtocol("rmi");
receiver.setId("my-receiver");

You need to establish which Xbean will receive the DOM document from the receiver. To pass the document on to the next Xbean, you simply register the next Xbean to be the receiver's DOM Listener.

receiver.setDOMListener(nextXbean);

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

Finally, you must tell the receiver to receive the document:

receiver.receive();

Running sender or receiver programs

The procedures for running a sender or receiver program differ depending on the protocol. See corba, ejb, http, rmi, servlet or soap.

Source files

source/org/xbeans/communication/*.java