Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron [email protected] if677.
-
Upload
melvyn-shaw -
Category
Documents
-
view
218 -
download
0
Transcript of Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron [email protected] if677.
![Page 1: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/1.jpg)
Build CORBA Applications with C++, MICO and Win32
Luiz Carlos d´[email protected]
http://www.cin.ufpe.br/~if677
![Page 2: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/2.jpg)
Acknowlegdes
Mayank Mishra, Master in Computer Science, Sun MicroSystems
Nelson Souto Rosa, Doctor in Computer Science, Cin/UFPe
![Page 3: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/3.jpg)
Break Point
This is a attachment to the regular course. In this material, only practical issues can be
found. Please, read the references of CORBA and Distributed Systems in discipline home page !
![Page 4: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/4.jpg)
Pre-requisits
Before you continue, be sure that you have at least:
Low level C/C++ domain Familiar with Middlewares, CORBA and Distributed
Systems concepts Solid knowledges in Object Oriented Paradgma Familiar with Windows and Microsoft Visual Studio 2003
platform*
* so little work is sufficient to migrate to others platforms
![Page 5: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/5.jpg)
What´s MICO
MICO is CORBA! Micro CORBA A Implementation of CORBA specification subset With him you can write CORBA applications in C+
+ or Java Visit http://www.mico.org
![Page 6: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/6.jpg)
Install MICO on Windows
Download MICO source from mico.org
Unzip it
Read README-WIN32 to compile the source
Edit the environment variables to add win32-bin directory to PATH variable
You can download a compiled distribution of MICO to Win32 in http://www.cin.ufpe.br/~if677/monitoria/corba
![Page 7: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/7.jpg)
Configure Visual Studio ProjectConfigure Visual Studio Project
1) File ->New->Project…
2) Expand “Visual C++ Projects”
3) Select Win32 Folder
4) Select Win32 Console Project
5) Enter a Name to Project
6) Click OK
![Page 8: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/8.jpg)
Configure Visual Studio ProjectConfigure Visual Studio Project
7) Click in “Application Settings”
8) Be sure that the “Console application” is selected
9) Mark the “Empty project” checkbox
10) Click in Finish to create the project
![Page 9: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/9.jpg)
Configure Visual Studio ProjectConfigure Visual Studio Project
Was create a simple Empty project
11) Go to Project Menu12) Select the “Properties” Item
Where are the C/C++ Option? :OFor Respond:
13) Click in Cancel Button
![Page 10: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/10.jpg)
Configure Visual Studio ProjectConfigure Visual Studio Project
14) Add a new file from source15) Select C++ File
16) Choose a name to a file, like “server.cpp”17) Click in “Open”:D
![Page 11: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/11.jpg)
Configure Visual Studio ProjectConfigure Visual Studio Project
Well, the file server.cpp was created. Now,
18) Click in Project Menu
19) Select PropertiesTharamm! The C/C++ folder is enable!
20) Expand him
21)
In “Additional include Directories”
enter the complete path from the Include folder of MICO distro.
![Page 12: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/12.jpg)
Configure Visual Studio ProjectConfigure Visual Studio Project
22) Expand linker
23) In “ Additonal Library Directories, enter the complete path of the lib folder over win32-bin directory of MICO
24) Select Input
25) Enter the mico2312.lib and micocoss2312.lib references.
26) Click OK
Finish the Visual Studio Project Configuration for MICO Applications
![Page 13: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/13.jpg)
Create and Compile the IDL FileCreate and Compile the IDL File
interface Account{
void deposit(in long amount);void withdraw(in long amount);long balance();
};
account.idl
1) Create the account.idl text file in project folder
2) Open the cmd (start->run enter ‘cmd’)
3) Go to project folder
4) Enter “idl account.idl”
The idl.exe from MICO will compile the account.idl and generate two files:
• account.h
• account.cc
Add this files to project
![Page 14: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/14.jpg)
Additional TasksAdditional Tasks
Hei, in account.cc file, change the include <account.h> to “account.h”
Do you remember the server.cpp file? Open and enter the includes:
#include <iostream>#include <fstream>#include "account.h"
![Page 15: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/15.jpg)
Coding the serverCoding the server
Create Account_impl class, that will execute the business logic
![Page 16: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/16.jpg)
Coding the serverCoding the server
Don’t forget the witdraw and balance methods
![Page 17: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/17.jpg)
Coding the serverCoding the server
![Page 18: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/18.jpg)
Coding the serverCoding the server
![Page 19: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/19.jpg)
Excecute the serverExcecute the server
Observe the account.ior file generated in project folder.
![Page 20: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/20.jpg)
account.ior
The ior file have data that represents the remote object location
In each execution, a new account.ior file is created, and replace the prior
Clients that use the server will need read the account.ior file to locate the remote object
![Page 21: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/21.jpg)
Create the Client1. The client is another process that use CORBA to communicate
with the server
2. Thus, we need create another project to coding the client (in new instance of MS Visual Studio)
3. Create the AccountClient project, and configure it with the instructions few slides ago. Instead of server.cpp, generate the client.cpp file
4. Copy from the server project to the client project the three files: account.cc, account.h and account.ior
5. Add to project only the account.cc and account.h
![Page 22: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/22.jpg)
Create the ClientCreate the Client
![Page 23: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/23.jpg)
Create the ClientCreate the Client
![Page 24: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/24.jpg)
Execute the clientExecute the client
Client´s execution with the server response. If you have communication matters, try copy any time the account.ior file from server project to client project. Note that the client can execute serious times with the same server process
![Page 25: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/25.jpg)
The bootstrapping problem
How client obtains the first server´s reference? To solve this problem, server´s information go to
client outside the CORBA Framework There are some approachs:
File-Based Bootstrapping (used in our example) Naming Service
![Page 26: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/26.jpg)
Naming Service
Naming Service is crucial in distributed applications
Examples: java RMI Registry and DNS The Corba Naming Service maps names to
Remote Objects Client yet knew where is the Naming Service Naming Server resolve names in references
![Page 27: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/27.jpg)
Naming Service Refactored Example - server
In server.cpp file, edit only the header declarations, plus the <coss/CosNaming.h> include, and the main method
![Page 28: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/28.jpg)
Naming Service Refactored Example - server
![Page 29: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/29.jpg)
Naming Service Refactored Example - server
![Page 30: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/30.jpg)
Naming Service Refactored Example - client
![Page 31: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/31.jpg)
Naming Service Refactored Example - client
![Page 32: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/32.jpg)
Starting Naming Service1. Open the command prompty
2. Navigate to the server project directory
3. Enter
nsd -ORBIIOPAddr inet:localhost:9001
That start Naming Service on port 9001
![Page 33: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/33.jpg)
Execute the server and the client
1) The server startup
2) The client execution
3) The server execution
![Page 34: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/34.jpg)
Issues
Be sure that you understand:
How the server and the client acquire the Naming Service reference
How server use the Naming Service to bind the Account reference to a name
How client acquire the Account remote reference How client use the methods from the Account Remote reference
![Page 35: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/35.jpg)
References
Distributed Systems Architecture – Arno Puder at al C++ Programming with CORBA - Andreas Vogel at al Advanced CORBA® Programming with C++ - Michi
Henning at al MICO-mail list www.mico.org
![Page 36: Build CORBA Applications with C++, MICO and Win32 Luiz Carlos d´Oleron lcadb@cin.ufpe.br if677.](https://reader034.fdocuments.net/reader034/viewer/2022051417/56649e905503460f94b94e0e/html5/thumbnails/36.jpg)
Luiz Carlos d´Oleron Graduate in Computer Science, CIn/UFPE
http://www.cin.ufpe.br
Monitor Infra-Estrutura de Software http://www.cin.ufpe.br/~if677