The CORBA Sender and Receiver Xbeans

Function

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

The CORBA Xbeans have been developed to work with JavaIDL, Sun's CORBA implementation that is distributed with JDK1.3. The CORBA Xbeans depend on a CORBA name service running, such as Sun's tnameserv that is distributed with the JDK.

The use with other implementations of CORBA, such as VisiBroker, has not been tested but should be possible with little or no modification to the Xbeans. 

CORBA Sender XBean Properties

id The name in the CORBA naming service identifying the CORBA receiver Xbean. 

 compression

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

CORBA Receiver XBean Properties

id The name in the CORBA naming service used to advertise the services of the CORBA receiver Xbean. 

 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 CORBA Sender

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

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

Using the CORBA Receiver

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

import org.xbeans.communication.corba.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 id 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 a CORBA name service. The CORBA name service distributed with JDK 1.3 is called tnameserv. It takes an optional parameter -ORBInitialPort to indicate the port number it should listen on for requests. (If you do not give the port number it defaults to 900.)

Running "tnameserv -ORBInitialPort 1500" produces this output.

Initial Naming Context:
IOR:000000000000002849444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f
6e746578743a312e3000000000010000000000000054000101000000000c3139322e3136382e302e
3100042b000000000018afabcafe000000027befb04a000000080000000000000000000000010000
0001000000140000000000010020000000000001010000000000
TransientNameServer: setting port for initial object references to: 1500
Ready.

When you run the sender and the receiver programs, you need to pass the Java VM the initial port. That can be accomplished by setting the org.omg.CORBA.ORBInitialPort property. For example:

java -Dorg.omg.CORBA.ORBInitialPort=1500 ...

If the sender or receiver program is to run on a different machine than the name service is running, you need to set the org.omg.CORBA.ORBInitialHost property. For example:

java -Dorg.omg.CORBA.ORBInitialHost=myhost ...

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

Source files

source/org/xbeans/communication/corba/*.java
source/XMLReceiver.idl