Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Hubert Klein Ikkink (aka Mr.Haki) - Communications Officer TDMWeb Kylix Developer's Guide
 JBuilder 3.5 CORBA Clients
See Also: JBuilder Papers

JBuilder 3.5 CodeSite CORBA Client
This article continues Bob Swart's article about CodeSite as CORBA server. We will write a CORBA client using JBuilder 3.5 Enterprise on Linux. The client application can access the CodeSite CORBA server. This way we can use CodeSite from any Java platform. For example a Window machine has a CodeSite server running and debug message from a Java client running on the Linux platform will be displayed in the CodeSite window.

Setting up JBuilder for VisiBroker
First we must have installed VisiBroker for Java on our machine. If we never have used VisiBroker with JBuilder we must do some setting up in JBuilder:

Writing the client
We have set up VisiBroker in JBuilder and now we can start using it to write a CodeSite CORBA client. We have to create a new project. Go to the project properties and select the Build tab page. This should look something like this:

Make sure the VisiBroker configuration is selected. It is good practice to organise our class files in packages. If we compile an IDL file, the module name is used to generate package names. But most of the time this will not be sufficient. We can set a package name in this dialogue window, which will be the base of the package generated from the IDL. We set the Package to com.ukbug.cs. Our project is set up and we must now include the IDL file generated by Delphi. Go to Project | Add to project | Add file and select the IDL file. The file is added to the project. Select the IDL file and right-click on the file. Select the Make command from the pop-up menu. JBuilder now compiles the IDL file and generates stub and skeleton Java source files. If the compile progress is stopped we can see a lot of files added to the IDL file node. Most of them are not interesting, because they are used for writing CORBA sever applications and we are writing a CORBA client. But still it can be quit interesting to look at the files and see what they do (we will at the CORBA MasterClass). We are going to write a separate class, CSLogger, to access the CodeSite server and print debug messages. As a separate class we can use it in many more projects and applications The following piece of code shows the class:

  package com.ukbug.cs.csclient;

  import org.omg.CORBA.*;
  import com.ukbug.cs.CSCServer.*;

  public class CSLogger {
    private ICodeSite logger = null;

    public CSLogger() {

    private void initCORBA() {
      try {
        ORB orb = ORB.init(new String[]{}, null);
        CodeSiteFactory factory =
          CodeSiteFactoryHelper.bind(orb, "CodeSite");
        logger = factory.CreateInstance("CodeSite");
      } catch (Exception e) {

    public void println(String message) {

    public void enterMethod(String s) {

    public void exitMethod(String s) {

    public static void main(String[] args) {
      CSLogger log = new CSLogger();
      log.enterMethod("Enter a JBuilder 3.5 Method");
      log.println("Some debugging message...");
      log.println("Another debugging message...");
      log.println("A final debugging message...");
      log.exitMethod("Exit a JBuilder 3.5 method");
The code is pretty straightforward. We need to include two import statement to be able to access the ORB and to access the files generated by the IDL compilation process. The initCorba() method contains all the logic to find the CORBA server and to create an instance of the CodeSite CORBA object. Once we have reference if this object we store it as a data member with the name logger. Next three public methods are added to access the methods of the CodeSite object. We could of course simply have written a get() method for the CodeSite object, but this way we have hidden the CORBA stuff from the user of the class. The main() method at the end of the source is only used for testing. In Bob Swart's article we will see the result when we have run this application.

This webpage © 1997-2010 by Bob Swart (aka Dr.Bob - All Rights Reserved.