Distributed objects are objects that can be accessed remotely. This means that a distributed object can be used like a regular object, but from any machine on the network. The physical location of the object is not critical to the user of the object.
CORBA provides the mechanisms by which objects transparently make requests and receive responses. The CORBA ORB is an application framework that provides interoperability between objects, built in (possibly) different languages, running on (possibly) different machines, in heterogeneous distributed environments.
JBuilder includes a set of visual tools for creating 100% Pure Java distributed applications, applets, and JavaBeans for the enterprise. JBuilder supports CORBA through the VisiBroker ORB. Outline: creating a CORBA application in JBuilder provides an overview of the steps required to create a distributed application using CORBA.
JBuilder supports RMI through the 100% Pure Java standard. RMI provides the mechanisms by which objects transparently make requests and receive responses. RMI is the application framework that provides interoperability between objects running on different Java virtual machines (VM). Outline: creating an RMI application in JBuilder provides an overview of the steps required to create a distributed application using RMI.
JBuilder Client/Server also includes InterClient, a tool for developers who want to create Java-based client-server applications. Java developers should be able to seamlessly swap RDBMS back ends underneath their JDBC applications. InterClient provides a small footprint, easy-to-maintain RDBMS (InterBase) as the back end to JDBC applications. An InterBase back end is an ideal solution because it's small, economical, and conforms to the same SQL standards as the JDBC.
If you are new to distributed applications, a good source for information and examples is http://www.omg.org/news/begin.htm, the OMG's CORBA for Beginners Web page.
If you would like more information on the differences, advantages, and disadvantages of each approach to distributed computing, a good source for information is Part 4 of the Orfali and Harkey book "Client/Server Programming with JAVA and CORBA".
Some remote object terminology follows. For other object terminology, see the Glossary.
The following steps outline how to use JBuilder's distributed objects features to create a CORBA application. For a tutorial recreating one of the JBuilder sample projects, see Tutorial: creating distributed applications in CORBA.
The interface is used to generate interface definitions and client stubs and server skeletons. To support the distribution of objects implemented in a variety of programming languages, an Interface Definition Language (IDL) file is used to define the services offered by a particular distributed object. CORBA then defines a wire protocol (Internet InterORB Protocol, IIOP) for making requests to an object and for the object to respond to the application making the request. The options for defining the interface are IDL, Java, and Java-to-IDL.
To see an existing IDL file, you can load the Bank.idl file from jbuilder/samples/visibroker/samples/bank.
Add the IDL code to this file. For more information on writing IDL code, see http://www.omg.org/corba/cichpter.htm#idls&s for IDL syntax and semantics. An example IDL file is located in the sample directory JBuilder/samples/borland/reference/creditapproval of your JBuilder installation.
Right-click the IDL file in the Navigation pane to set IDL properties.
Create a Java interface in a standard .java file. To create a new Java interface that can generate IIOP messages, (i.e. client stubs and server skeletons), right-click the Java interface file in the Navigation pane, select Java source properties, then check Generate IIOP interface. See Caffeine: defining CORBA interfaces with Java for more information.
Using a Java interface to describe a CORBA object has some limitations. All Java primitive types can be used. However, Java objects can be used to define the interface only if the object implements java.io.Serializable.
Create a Java interface in a standard .java file. To generate an IDL file from this Java file, right-click the Java interface file in the Navigation pane, select Java source properties, then check Generate IDL.
When the file is compiled, IDL code is generated. The IDL code generated during this process may contain code specific to the VisiBroker ORB.
Compile the interface definition file with the Build command. When the interfaces are compiled, a Java client can transparently invoke an IDL object that resides on a remote server. Compiling the interface definition file generates client stubs, server skeletons, and various helper files. These files stuff information into an IIOP message that can be sent over the wire.
The generated files are read-only and are generated to your OUTPATH/Generated Source directory.
Select Build|Build to compile the entire project, or right-click on the IDL or Java file and select Build to compile only the interfaces.
You must provide an implementation for the CORBA interface file. The implementation is done in Java. To help you get started with the implementation, some example files are created when the interface definitions are compiled. The example files have a file name of the format _example*.*
Some example implementation files are located in the sample directories found beneath the JBuilder/samples/visibroker/samples/ directory of your JBuilder installation.
A CORBA server needs to be created to make the CORBA object available to the ORB (Object Request Broker). This is necessary so that remote clients can access the object. You can create a simple server by selecting File|New, then selecting CORBA Server from the VisiBroker tab. Enter the appropriate information. A new file called MyCORBAServerClass1.java, by default, will be added to the project. Edit the server code to throw exceptions as applicable.
The client can be either a Java applet or an application. You should be able to bind to the remote object in the client. Edit the client code to catch exceptions as applicable.
In the JBuilder/samples/visibroker/samples/ subdirectories of your JBuilder installation are several sample CORBA applications. See the Bank application for an example of how to create the client.
Use the Deployment Wizard, or see the deployment topic in the User's Guide for more information, or see Deployment in the "Tutorial: creating distributed applications in CORBA".
This topic briefly discusses how to run a CORBA application. For more information, look for documentation updates on www.borland.com/techpubs/jbuilder/.
This topic presents the steps to create a simple distributed application in JBuilder using Java RMI. The application referenced here is located in the jbuilder/samples/borland/samples/rmi/simple directory of your JBuilder installation. For a tutorial recreating one of the JBuilder sample projects, see Tutorial: creating a distributed application with Java RMI.
The interface created for this example is SimpleRMIInterface.java. It contains only one method which takes no arguments and returns an object of type java.util.Date. Note two things about this interface:
See the online JDK documentation (in the java.rmi section) for
a complete list of exceptions that can be thrown.
In this example, the implementation is found in SimpleRMIImpl.java. This class must extend java.rmi.UnicastRemoteObject and must implement the interface you created in the previous step. In this example, the only method that needs to be implemented is getDate(), which returns the current date and time on the system. Note two things about the constructor:
This call informs the RMI registry that this object is available with the
name given in "String name". Other than that, this object simply implements
all the methods declared in the interface.
In this example, the server class is SimpleRMIServer.java. In this case, the server is pretty simple. It does two things:
The SimpleRMIImpl object takes care of registering the
object with the RMI registry. After this code is run, the object will
be available to remote clients as "rmi://<your server here>/SimpleRMIImpl instance".
This is how the client connects to it in the next step.
In this example, the client class is SimpleRMIClient.java. The client first installs a new RMI Security
Manager (see previous step), then uses the static method Naming.lookup()
to get a reference to the remote object. Note that the client is using
the interface to hold the reference and make method calls.
You should make sure you've created your interface before you try
to build the client, or you'll get "class not found" errors when
you try to compile your client.
This step generates some additional Java classes. They're stubs and skeletons used by RMI; you don't have to worry about what's in them.
Any errors detected during the build process will be reported in the compiler output window.
At this point, you're done with development; you've built all the code you need to run this example. Next, set up the environment so that you can run the application.
Run the SimpleRMIServer from the project.
This starts the server running. The
server then creates an instance of SimpleRMIImpl and makes it known
to the RMI server as "SimpleRMIImpl instance".
Run SimpleRMIClient. The program will ask the RMI registry for a
reference to "SimpleRMIImpl instance". After it has this reference,
the client can invoke any methods declared in the SimpleRMIInterface
interface as if the object were a local object.
Next you might want to look at Tutorial: creating a distributed application with Java RMI and try to create a distributed version of the classic "Hello World" program using Java RMI. The completed application can be found in the JBuilder/doc/java/guide/rmi/examples/hello directory of your JBuilder installation.