8.4 The Anatomy of a CORBA Producer

The producer is responsible for providing either data, routines, or services to its consumer programs. The producer, together with the consumer, make a complete distributed application. Each CORBA producer program is designed with the assumption that there will be consumer programs to invoke its services. Therefore, each producer program will create servant objects and provide IORs so that the objects may be accessed. Figure 8-5 contains a simple producer program used in conjunction with the consumer program from Figure 8-4. Figure 8-5 contains the basic components that any CORBA producer program will contain.

Figure 8-5. Basic components of a CORBA producer program.

graphics/08fig05.gif

Notice that part A for the consumer program and the producer program are essentially the same. Both the consumer and the producer program require an ORB to communicate. The ORB is used to get a reference to an object adapter . Figure 8-5 contains the call:

 CORBA::BOA_var Boa = Orb->BOA_init(argc,argv,"mico-local-boa"); 

This call is used to get a reference to an object adapter. The object adapter is a middleman between the ORB and the object that implements the services to be called. Keep in mind that CORBA objects start as interface declarations only. At some point in the development process, a derived class provides the implementation for the CORBA interface. The object adapter acts as the middleman between the interface that the ORB interacts with and the real methods implemented by the derived class. The object adapters are used to access servant and implementation objects. The producer in Figure 8-5 creates an implementation object in part B using:

 adding_machine_impl *AddingMachine = new adding_machine_impl; 

This is the object that will provide the implementation for the services that the client or consumer objects will request. Also notice that in part C in Figure 8-5, the producer program uses the Orb object to convert the IOR to a string and writes the string to a file named adding_machine.ior . This file can be transmitted to the producer through ftp , e-mail, over http using Web pages, via NFS mounts and so on. There are other ways to communicate the IOR, but the file method provides a simple introduction. After the IOR is written the producer program simply waits for requests from client or consumer programs. The producer program in Figure 8-5 is also an oversimplification of the CORBA producer or server program, but it does contain the basic components that a typical producer program will have.



Parallel and Distributed Programming Using C++
Parallel and Distributed Programming Using C++
ISBN: 0131013769
EAN: 2147483647
Year: 2002
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net