Thursday, July 26, 2007

Creating CORBA Client Applications

http://e-docs.bea.com/tuxedo/tux91/creclient/corba.htm

Steps for developing CORBA C++ client applications
  1. Obtain the OMG IDL file.
  2. Select the Invocation type.
  3. Use the IDL compiler to compile the OMG IDL file. Generating client stubs
  4. Write the CORBA C++ client application.
  5. Build the CORBA C++ application

-idl command compiles the OMG IDL file and generates the client stubs required for the CORBA interface.
-The buildobjclient command constructs a CORBA C++ client application executables.

step1: Obtaining the OMG IDL file
The available interfaces and operations are provided by application designer.

step2: Selecting the Invocation Type
select static, dynamic or both.

step3: Compiling the OMG IDL File
syntax of the idl command:

idl idlfilename(s)

The IDL compiler generates a client stub(idlfilename_c.cpp) and a header file (idlfilename_c.h). You need to link these files into your CORBA client application.

step4: Writing the CORBA client Application
To get an object reference for a CORBA object and invoke operations on the object
  • Intialize the BEA Tuxedo ORB.
  • Establish communication with the BEA Tuxedo domain.
  • Resolve initial reference to the FactoryFinder object.
  • Use a factory to get an object referencefor the desired CORBA object.
  • Invoke operations on the CORBA object.
a. Initializing the ORB
syntax
CORBA::ORB_var orb=CORBA::ORB_init(argc, argv, ORBid);

if CORBA client application wants to access server applications in another BEA Tuxemo domain, you need to override the default ORBid as BEA_IIOP
b. Establishing Communication with the BEA Tuxedo Domain
The CORBA client application creates a Bootstrap object.

The following code shows how to use the Bootstrap object:
Tobj_Bootstrap* bootstrap = new Tobj_Bootstrap(orb, "//host:port");
c. Resolving Initial References to the FactoryFinder Object
The client application must obtain initail references to the environmental objects that provide services for the CORBA application.
The Bootstrap object's resolve_initial_references operation can be called to obtain references environmental objects.

CORBA::Object_var var_factory_finder_oref = bootstrap.resolve_initial_references
("FactoryFinder");
Tobj::FactoryFinder_var var_factory_finder_ref = Tobj::FactoryFinder::_narrow
(factory_finder_oref.in());

d. Using the FactoryFinder Object to Get a Factory
CORBA client applications get object references to CORBA objects from factories.
To use factories, the CORBA client application must be able to locate the factory it needs. The FactoryFinder object serves this purpose.

FactoryFinder object has the following methods
-find_factories()
-find_one_factory()
-find_factories_by_id()
_find_one_factory_by_id()

syntax:
CORBA::Object_var var_registrar_factory_oref = var_factory_finder_ref->
find_one_factory_by_id(UniversityB::_tc_RegistrarFactory->id());
UniversityB::RegistrarFactory_var var_RegistrarFactory_ref = UniversityB::RegistrarFactory::_narrow(var_RegistrarFactory_oref.in() );
e. Using Factory to Get a CORBA Object
The CORBA client applications invoke operations on the CORBA object by passing a pointer to the factory and any arguments that the operation requires.

The following code invoking the get_cources_details() method on the Registrar object

UniversityB::Registrar_var var_Registrar = var_RegistrarFactory->
find_Registrar();
UniversityB::CourseDetailsList_var course_details_list = Registrar_oref->
get_course_details(CourseNumberList);
step5: Building the CORBA Client Application

Compile the code and link against the client stub.
use the buildobjclient command to construct a CORBA client application executable.

No comments: