Electronic Postcard Application with CORBA (part I)
Name
Short: CORBA client
Long: Electronic Postcard Application with CORBA (part I)
Objective
The purpose of this lab is to implement a part of a distributed application
using CORBA.
Time allocation
Four hours are allocated to complete this lab assignment.
Exercise
You will have to implement an application in C++ or Java that
uses the CORBA objects Database and Writer provided.
Follow the links to see the IDL files with the interface of Database
and Writer objects. The Database object is located on mir54
and the Writer runs on mir51. Both objects are accessible through a NameService running
on mir14 on port 10000. The objects are bound to the NameService with the names
Database.trapo and Writer.trapo
There are several ways of building the interface for the application
using CORBA. A simple text based interface will be accepted if you just want to pass
this lab. However, a web-based graphical interface can still be added afterwards.
For example, HTML can be generated from a CGI program, an applet or a servlet.
For this lab, we encourage you to reuse the servlet-based interface which you developed
for the 2nd assignment.
TO DO
-
Install the lab.
-
Compile, run and understand the Hello World example of your choice. See below the link to the ORBacus documentation for a step-by-step explanation of this process.
-
Modify the example to use the Database object:
-
Create the stubs for the client:
idl Database.idl
.(C++)
jidl --package database Database.idl
.(Java)
-
Modify the Client.cpp file by replacing all "Hello" with "Database" and
"hello" with "database".
-
Instead of reading the "stringified" object reference form the Hello.ref
file, you will ask the NameService:
- Get a reference to the NameService:
- C++:
CORBA::Object_var obj = orb -> resolve_initial_references("NameService");
CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow(obj.in());
- Java:
org.omg.CORBA.Object rootObj = orb.resolve_initial_references("NameService");
org.omg.CosNaming.NamingContext root = org.omg.CosNaming.NamingContextHelper.narrow(rootObj);
- Get a reference of a Database object by name:
- C++:
CosNaming::Name dbName;
dbName.length(1);
dbName[0].id = CORBA::string_dup("Database");
dbName[0].kind = CORBA::string_dup("trapo");
CORBA::Object_var dbObj = nc -> resolve(dbName);
Database_var db = Database::_narrow(dbObj.in());
- Java:
NameComponent[] nc = new NameComponent[1];
nc[0] = new NameComponent("Database","trapo");
org.omg.CORBA.Object obj = ((NamingContext)root).resolve(nc);
Database database = DatabaseHelper.narrow(obj);
-
Use the database object in some way (i.e., printf("%d %s", database->getCardsNumber(),
database->getCardName(5));).
-
Implement the Electronic Postcard service using the CORBA objects.
-
Build a graphical interface for the Electronic Postcard service.
This step is optional and command-line user-interfaces are accepted.
-
When you run your client, don't forget to specify the location of the NameService
as an argument in the command line:
client -ORBInitRef NameService=corbaloc::mir14:10000/NameService
These command line arguments should be specified internally in the source file
in case you want to reuse the servlet-based interface developed in the 2nd assignment.
Important!!
The Database and Writer objects are different programs than the CardDatabase and CardWrite servers which you used in the 2nd assignment. You should pay attention when you use the Database object, as it starts counting the cards from 0, as opposed to the CardDatabase server which counts the cards from 1.
Reporting your work
The lab is reported by showing the assistant the working application. All
members of the lab group should be present when reporting.
Appendices