Developing distributed applications

Note: Only the Client/Server version of JBuilder ships with distributed applications features. Refer to the JBuilder product page from the Borland Web site at http://www.borland.com/jbuilder for availability of features in each JBuilder version.

This section of the Developer's Guide provides information on using JBuilder's distributed applications functionality. Before you create a distributed application, you should understand the various types of architecture available. JBuilder supports at least three methods of creating and distributing applications:

See more information for a list of distributed object/application resources.

This book is intended for developers familiar with distributed applications and distributed applications terminology. If you are not already familiar with these, a book such as "Java Programming with CORBA, 2nd ed.", by Vogel and Duddy, will explain the concepts and specifics of programming with distributed objects. This book explains how to use JBuilder to create distributed applications. Included are an overview of JBuilder's distributed applications features, tutorials for creating some basic distributed applications using JBuilder, Java, and VisiBroker, and references to other information. Sample applications are located in the following directories to provide further assistance:

Specifications can be found online at the following URLs:

Understanding the distributed computing options

CORBA or Java RMI? Which is appropriate for your application? If you want an all-Java solution, use Java RMI or Caffeine. If you want an open, standards-based solution, use CORBA/IIOP.

For other differences, and a more complete discussion of distributed computing alternatives, an excellent reference is "Part 4: CORBA and its competitors" from Client/Server Programming with JAVA and CORBA by Orfali and Harkey.

When you are ready to create an application using distributed objects, see Overview: creating a distributed application in JBuilder.

Common Object Request Broker Architecture (CORBA)

The Object Management Group (OMG) is an industry consortium formed to develop the Distributed Object Standard. OMG created the Object Management Architecture (OMA), developed the specification for CORBA, and specified the Internet InterORB Protocol (IIOP), the standard communication protocol between Object Request Brokers (ORB).

CORBA is an open standards-based solution to distributed computing. The primary advantage to using CORBA is that clients and servers can be in any language with an IDL mapping. There is no need to predetermine the programming language, the hardware platform, the operating system, the specific ORB, or the degree of application distribution (whether it runs locally or remotely). Objects can act as clients, servers, or both.

IIOP, the standard communication protocol between ORBs, resides on top of TCP/IP, but developers do not need to learn IIOP, because the ORB handles this for them.

Tutorial: creating distributed applications in CORBA provides a simple tutorial for creating a distributed application using CORBA and JBuilder.

Java Remote Method Invocation (RMI)

Distributed systems require that computations running in different address spaces, potentially on different hosts, be able to communicate. For a basic communication mechanism, the Java language supports sockets, which are flexible and sufficient for general communication. However, sockets require the client and server to engage in applications-level protocols to encode and decode messages for exchange, and the design of such protocols is cumbersome and can be error-prone.

An alternative to sockets is Remote Procedure Call (RPC), which abstracts the communication interface to the level of a procedure call. Instead of working directly with sockets, the programmer has the illusion of calling a local procedure, when in fact the arguments of the call are packaged up and shipped off to the remote target of the call. RPC systems encode arguments and return values using an external data representation, such as XDR.

RPC, however, does not translate well into distributed object systems, where communication between program-level objects residing in different address spaces is needed. In order to match the semantics of object invocation, distributed object systems require remote method invocation, or RMI. In such systems, a local surrogate (stub) object manages the invocation on a remote object.

The Java remote method invocation system has been specifically designed to operate in the Java environment. While other RMI systems can be adapted to handle Java objects, these systems fall short of seamless integration with the Java system due to their interoperability requirement with other languages. For example, CORBA presumes a heterogeneous, multilanguage environment and thus must have a language-neutral object model. In contrast, the Java language's RMI system assumes the homogeneous environment of the Java virtual machine, and the system can therefore take advantage of the Java object model whenever possible.

Tutorial: creating a distributed application with Java RMI provides a simple tutorial for creating a distributed application using RMI and JBuilder.

Caffeine

Caffeine provides an RMI-like programming environment on top of VisiBroker for Java. The Caffeinated Count program shows you how to write CORBA distributed objects using Java instead of CORBA IDL. Caffeine presents a pure Java alternative to the traditional CORBA development process.

VisiBroker's Caffeine contains a set of features that include Web Naming, and the java2iiop and java2idl compilers. The java2iiop compiler allows you to use the Java language to define interfaces, instead of using IDL. You can use the java2iiop utility if you have existing Java code that you want to adapt to use distributed objects or if you do not want to learn IDL. The java2iiop compiler generates the necessary container classes, client stubs, and server skeletons directly from Java code. The java2idl compiler turns your Java code into IDL, thereby, allowing you to generate client stubs in the language of your choice. In addition, because this compiler maps your Java interfaces to IDL, you can re-implement Java objects in another programming language that supports the same IDL. For more information, see Defining CORBA interfaces with Java.