The RMI Sender and Receiver Xbeans

Function

The RMI Sender is a sink Xbean that sends a DOM document to a RMI Receiver using RMI as a transport mechanism. The RMI Receiver is a source Xbean that receives the DOM document and passes it on to the next Xbean in the Xbean channel.

The RMI Xbeans depend on the RMI registry running.

RMI Sender XBean Properties

id The name in the RMI registry identifying the RMI receiver Xbean. 

 compression

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

RMI Receiver XBean Properties

id The name in the RMI registry used to advertise the services of the RMI receiver Xbean. 
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.

 compression

The receiver dynamically figures out if the document is compressed. The receiver bean ignores the compression property. There is no need to set it. 

Using the RMI Sender

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

import org.xbeans.communication.rmi.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 rmiName 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.

Using the RMI Receiver

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

import org.xbeans.communication.rmi.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 rmiName property. This allows the sender to find the receiver. For example:

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.

Running programs with senders or receivers

In order to run a program with a sender or a receiver, you must first run the RMI registry.

More information about RMI is available on Sun's Java site.

Source files

source/org/xbeans/communication/rmi/*.java
source/org/xbeans/communication/rmi/XMLReceiver.java