The client of CORBA implementation in BCB environment

Source: Internet
Author: User
Tags bind joins stub

Establish a CORBA client

When you write a CORBA customer, the first step is to make sure that the client program can talk to the Orb software on the client machine. To do this, use CORBA Client Wizard. Select file| New and select the icon labeled CORBA Client from the multitier page of the New Item dialog box. This wizard lets you explain whether you want to build a console application or a window application.

As with the CORBA server program, you can specify whether the CORBA customer uses the VCL class. If you do not select the VCL check box, all generated code can be ported to other platforms.

Add any IDL files that define the server object interface you want to use in CORBA Client Wizard. However, it is also possible to establish a CORBA client application without using any IDL file (specifically, to join a build customer unit into a job type). This is not the preferred method. When the project contains an IDL file for the server interface, you can use the wizard to bind to objects on the server.

Note: If you start the CORBA client project without adding an IDL file, you can also use project| at any time Add to project joins it.

CORBA Cleint Wizard always establishes a specified type of client project, adds a CORBA library to a project file, and joins the following starting code to initialize the Orb (object request broker objects requesting proxies).

Corba::orb_var orb= Corba::orb_init (ARGC,ARGV);

If you want to use the callback interface of the CORBA server, initialize the BOA (Basic object adapter) in the client program. Just select the appropriate box in the wizard and you can do it. The next step is to write the application in the same way as other cbuider applications. However, when you use an object defined in a server application, instead of dealing directly with an object instance, you get a reference to a CORBA object and use it to work. There are two ways to get a reference to a server object, which is related to which binding you are using:

If you use static bindings, you can invoke the CORBA Object Wizard (edit| Use CORBA Object). Static bindings are faster than dynamic and provide the benefits of compile-time type checking, code integrity (code_completion), and more.

However, there is always a time when you need to run to know the interface or object you want to use, then you need to use dynamic binding. Dynamic binding uses a general-purpose CORBA object that passes the request to the server with a special CORBA type named any.

Using stubs

Stub classes are generated automatically when the IDL file is compiled. They are defined in the generated client file, these files are named Xxx_c.cpp and Xxx_c.hh.

Note: You can have C++builder create a client file (stub) instead of a server file, which is set by the CORBA page of the Project Options dialog box.

When writing a CORBA client, you do not have to edit the code in the generated client file, instead, instantiate the stub class when you use it. This has to be done by choosing edit| Use CORBA object to invoke the use CORBA Object Wizard.

In this object using the wizard, indicate the IDL file that contains the desired interface, and select the interface you want to use. If you only want to bind to a CORBA object instance of a particular name, you can optionally provide a name to the CORBA object.

Use CORBA Object Wizard lets you select from the following binding mechanisms:

If the client program is a VCL-available window application, you can create an attribute in the program form to save an instance of your CORBA object stub class. You can use this property as an instance of a CORBA server object.

If you are building a console application, the wizard will sample the stub class as a variable in your main () function. Similarly, it can sample the stub class as a variable in WinMain (), if it is a window application.

Whether it is Windows or console applications, the wizard can add a property to a class in any given cell or draft a new class that has a property representing the stub instance.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.