Inprise Delphi CORBA Support - Examples

# Examples

The examples listed below are intended to illustrate specific aspects of the interaction between Delphi and VisiBroker. Complications such as error handling have been omitted or minimized in order to make the interaction clearer.

### Examples

| Account DOS | This is the traditional simple account client example written as a console application.
| Account GUI | This is the traditional simple account client example with a GUI.
| Anys | This example illustrates the use of the CORBA Any type. If you look at the generated code you can see that Anys are mapped to Delphi variants. It is good practice to minimize the use of Anys since that gets away from type checking at compile time.
| Arrays | This example shows how to declare a CORBA array in IDL and pass it as an argument to an interface method.
| Attributes | This example illustrates the use of CORBA attributes. If you examine the generated code you can see that attributes are mapped to Delphi properties.
| Call Backs | This shows how to make the server call an object created in the client.

COSNaming

This shows how to use the COS Naming Service with the VisiBroker 3.3 ORB. Before you start the server, you must start the naming service. The executable is in the vbroker\bin directory. Open a DOS command window and type:

NameExtF Test1 mylog.log

Test1 is the Node you're binding to and mylog.log is a log file. After the naming service has started, run the server and then the client.

COSNaming40

This shows how to use the COS Naming Service with the VisiBroker 4 ORB. The Naming Service was changed in the VB 4.0 implementation. It is now a Java application and must be started with a command line parameter that tells the service the TCP/IP port number to use. This same command line argument must be suppplied to servers and clients too. Sample batch files have been provided in the example to show how to start the Naming Service, Servers and Clients.

Before you start the server, you must start the naming service. The executable is in the Inprise\VisiBroker\bin directory. Open a DOS command window and type:

start nameserv -J-Dvbroker.se.iiop_tp.scm.iiop_tp.listener.port=23000

In this case, 23000 is the port number. After the naming service has started, run the server and then the client with the same argument.

Delphi Server

This example illustrates the use of the idl2pas compiler to create a client for a server created in Delphi DII solution. The ability to create both DII and IDL2Pas static binding servers and clients is only available if you installed the VisiBroker 3.3 ORB.

1. Create the server in Delphi.
2. From the Type Library user interface, export the interface as Corba IDL.
3. Run the IDL2pas compiler on the IDL file and it will generate the client side files (_c and _i) for you.
4. Write the client in Delphi and include the generated _c and _i files in the project.
5. The client should now be able to access the server.

EJB/EuroConverter

This example shows how to write a CORBA client that can connect to a Java EJB deployed with Borland AppServer 4.5.1. The directory has the Delphi client and a subdirectory that contains the EJB source.

To run this example, deploy the EJB with the AppServer console application, then build and run the EuroConverter client application. The applicaton converts Dutch Guilders to Euros by calling a conversion method in the EJB.

There is further documentation in the example's Java directory on how to build and connect to EJBs.

Event Service

This shows how to use the COS Event Service. Two examples are shown: a) a Push example, and b) a Pull example

Note that neither of these examples binds to a specific Event Channel. To do that, you would use the COSNaming service.

To start the Event service in Visibroker 3.3, open a DOS command window in the vbroker\bin directory and type:

Channel Test1

Test1 is a dummy name for the event channel. (Note: The Event service in VisiBroker 4 is called Event.exe.) Once the Event Service has started, you can run the server, followed by the client.

| Exceptions | This example illustrates the creation of user-defined exceptions in IDL and their handling on the client side. Note the use of complex types as exception data types.
| Interface Arguments | This example illustrates the passing of an interface as an operation parameter.

Midas

This example shows two ways to use Midas and CORBA. Note, you have to have the sample database tables installed to run this example. It uses the Employee.db Paradox table.

The first example takes the Midas data packet and converts it to XML. The data is sent from the server to the client as a CORBA string. On the client side, the string is hooked to the TClientdataset. The XML packet is also displayed. The second example transmits the Midas data packet as a CORBA Any variable.

Bonus: One interesting aspect of this example is the dmPooler data module. This shows how to do thread safe database connection pooling. At start up, a pool of connections is created. As each database request is made, a connection is taken from the pool and returned immediately following the SQL command. This technique avoids a common error of making a new connection each time a database request is processed. Establishing a connection for each request will eventually starve resources from the BDE. The dmPooler example avoids this error.

| Multiple Inheritence | This example illustrates the implementation of multiple inheritance of CORBA interfaces in Delphi.
| Nested Modules | This example illustrates the implementation of nested CORBA modules in Delphi.
| Sequences | This example shows how to package data into sequences. This is useful for database applications.
| Single Inheritence | This example illustrates the implementation of single inheritance of CORBA interfaces in Delphi.
| Structures | This example illustrates the use of CORBA structures.
| Unions | This example illustrates the use of CORBA unions.