Title: Build CORBA Applications with C , MICO and Win32
1Build CORBA Applications with C, MICO and Win32
- Luiz Carlos dOleron
- lcadb_at_cin.ufpe.br
http//www.cin.ufpe.br/if677
2Acknowlegdes
- Mayank Mishra, Master in Computer Science, Sun
MicroSystems - Nelson Souto Rosa, Doctor in Computer Science,
Cin/UFPe
3Break 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 !
4Pre-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
5Whats 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
6Install 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/monitori
a/corba
7Configure Visual Studio Project
1) File -gtNew-gtProject 2) Expand Visual C
Projects 3) Select Win32 Folder
4) Select Win32 Console Project 5) Enter a Name
to Project 6) Click OK
8Configure 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
9Configure Visual Studio Project
Was create a simple Empty project 11) Go to
Project Menu 12) Select the Properties
Item Where are the C/C Option? O For
Respond 13) Click in Cancel Button
?
?
?
10Configure Visual Studio Project
14) Add a new file from source 15) Select C File
16) Choose a name to a file, like
server.cpp 17) Click in OpenD
11Configure Visual Studio Project
Well, the file server.cpp was created. Now, 18)
Click in Project Menu 19) Select
Properties Tharamm! 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.
12Configure 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
13Create and Compile the IDL File
- Create the account.idl text file in project
folder - Open the cmd (start-gtrun enter cmd)
- Go to project folder
- 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
- interface Account
- void deposit(in long amount)
- void withdraw(in long amount)
- long balance()
account.idl
14Additional Tasks
Hei, in account.cc file, change the include
ltaccount.hgt to account.h
Do you remember the server.cpp file? Open and
enter the includes include ltiostreamgt include
ltfstreamgt include "account.h"
15Coding the server
Create Account_impl class, that will execute the
business logic
16Coding the server
Dont forget the witdraw and balance methods
17Coding the server
18Coding the server
19Excecute the server
Observe the account.ior file generated in project
folder.
20account.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
21Create the Client
- The client is another process that use CORBA to
communicate with the server - Thus, we need create another project to coding
the client (in new instance of MS Visual Studio) - Create the AccountClient project, and configure
it with the instructions few slides ago. Instead
of server.cpp, generate the client.cpp file - Copy from the server project to the client
project the three files account.cc, account.h
and account.ior - Add to project only the account.cc and account.h
22Create the Client
23Create the Client
24Execute the client
Clients 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
25The bootstrapping problem
- How client obtains the first servers reference?
- To solve this problem, servers information go to
client outside the CORBA Framework - There are some approachs
- File-Based Bootstrapping (used in our example)
- Naming Service
26Naming 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
27Naming Service Refactored Example - server
In server.cpp file, edit only the header
declarations, plus the ltcoss/CosNaming.hgt
include, and the main method
28Naming Service Refactored Example - server
29Naming Service Refactored Example - server
30Naming Service Refactored Example - client
31Naming Service Refactored Example - client
32Starting Naming Service
- Open the command prompty
- Navigate to the server project directory
- Enter
- nsd -ORBIIOPAddr inetlocalhost9001
- That start Naming Service on port 9001
33Execute the server and the client
1) The server startup
2) The client execution
3) The server execution
34Issues
- 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
35References
- 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
36Luiz Carlos dOleron
- Graduate in Computer Science, CIn/UFPEhttp//www.
cin.ufpe.br - Monitor Infra-Estrutura de Software
http//www.cin.ufpe.br/if677