Step 1: Define your interfaces and component types

 

Please make sure to read the following article to under the Stock Quoter system architecture before delving further into the tutorial:

·         The CORBA Component Model, Part 2: Defining Components with the IDL 3.x Types

 

Directory Structure:

The tutorial relies on the following directory structure. Create Quoter and all its subdirectories as shown below. We will describe the purpose of these directories later in the tutorial.

Quoter

                 |---- descriptors

                 |---- Stock_Base

                 |---- Distributor

                 |---- Broker

 

Preliminaries:

·         We use the Make Project Creator (MPC) throughout this tutorial. Understanding MPC will aid you in understanding this tutorial. For more information on MPC please look at the following:

1.      MPC Chapter in TAO’s Developer’s Guide 1.4a.

2.      $ACE_ROOT/MPC/README

Interface Design:

·         In the Quoter/Stock_Base sub-directory, place an idl file Stock_Base.idl that you could copy from here. This file defines the interfaces and events that will be used by both Stock Distributor and Stock Broker. We put together the common interface definitions so the base library can be shared by both components, reducing the size of "real" components.

·         Next, we need to create a Make Project Creator (MPC) file to generate the make files for us. From the Quoter/Stock_Base subdirectory, type the following command:

generate_component_mpc.pl –n -e Stock_Base

 

Note that we pass the –e option to generate_component_mpc.pl because our Stock_Base.idl uses eventtypes. If our idl file did not use eventtypes, we would

not pass the –e command line option.

 

The command above will generate a Stock_Base.mpc file that contains two projects Stock_Base_stub and Stock_Base_skel for the Stub and Servant code respectively. In addition, the command above will generate export files that will portably handle platform specific issues of import/export declarations of dynamically linked libraries (DLLs). After executing the command above you should see the following output on your screen.

 

The following commands have been executed:

        generate_export_file.pl STOCK_BASE_STUB > Stock_Base_stub_export.h

        generate_export_file.pl STOCK_BASE_SKEL > Stock_Base_skel_export.h

 

·         The MPC file should look like this.

 

Component Design:

Distributor:   

·         In the Quoter/Distributor sub-directory, place an idl file Distributor.idl that looks like this. This file defines the StockDistributor component interfaces.

·         Next, we need to create a Make Project Creator (MPC) file to generate the make files for us. From the Quoter/Distributor  sub-directory, type the following command:

generate_component_mpc.pl -p Stock_Base Distributor

 

The command above will generate a Distirubotor.mpc file that contains three projects Distributor_stub, Distributor_svnt, and Distributor_exec for the Stub, Servant, and Executor code respectively. In addition, the command above will generate export files that will portably handle platform specific issues of import/export declarations of dynamically linked libraries (DLLs). After executing the command above you should see the following output on your screen.

 

The following commands have been executed:

        generate_export_file.pl DISTRIBUTOR_STUB > Distributor_stub_export.h

        generate_export_file.pl DISTRIBUTOR_SVNT > Distributor_svnt_export.h

        generate_export_file.pl DISTRIBUTOR_EXEC > Distributor_exec_export.h

 

We will modify the generated MPC file to add an additional project later in the tutorial.

·         The Stock_Base_Distributor_stub, Stock_Base_Distributor_svnt, and Stock_Base_Distributor_exec projects in the MPC file should look like this.

 

Broker:

·         In the Quoter/Broker sub-directory, place an idl file Broker.idl that looks like this. This file defines the StockBroker component interface.

·         Next, we need to create a Make Project Creator (MPC) file to generate the make files for us. From the Quoter/Broker sub-directory, type the following command:

generate_component_mpc.pl -p Stock_Base Broker

 

The command above will generate a Broker.mpc file that contains three projects Broker_stub, Broker_svnt, and Broker_exec for the Stub, Servant, and Executor code respectively. In addition, the command above will generate export files that will portably handle platform specific issues of import/export declarations of dynamically linked libraries (DLLs). After executing the command above you should see the following output on your screen.

 

The following commands have been executed:

        generate_export_file.pl BROKER_STUB > Broker_stub_export.h

        generate_export_file.pl BROKER_SVNT > Broker_svnt_export.h

        generate_export_file.pl BROKER_EXEC > Broker_exec_export.h

 

We will modify the generated MPC file to add an additional project later in the tutorial.

·         The Stock_Base_Broker_stub, Stock_Base_Broker_svnt, and Stock_Base_Broker_exec projects in the MPC file should look like this.


Note:

To understand the meaning of different parameters passed to generate_export_file.pl type the following command:

generate_export_file.pl -h

   


Ming Xiong
Abdullah Sowayan
 

Last modified: