In addition to the name service and naming context object, the server in Program 8.3 also uses a portable object adapter. Recall from Figure 8-6 that the adapter acts as a kind of middleman between the ORB and the servant object that actually does the work of the CORBA object. We can compare a servant object to a ghost writer that writes a book on behalf of a celebrity. The publicists, marketers, and lawyers interact with the celebrity. The celebrity gets all the credit, but the ghost writer does the actual work and writing involved. The CORBA object publishes an interface to the outside world and is the celebrity in a CORBA program. The client or producer program interacts with the interface that the CORBA object provides, however, it's the servant object playing the part of the ghost writer that actually does the real work. The servant object has its own protocol. This protocol might be different from the one presented by the CORBA object. The CORBA object might present a C++ interface to the client. The servant object might be implemented in Java, Smalltalk, Fortran and so on. The object adapter provides an interface to the servant object. It adapts the interface so that the implementation of the servant object is transparent to the ORB and the client program. A CORBA implementation will normally have support for two types of object adapters: the Basic Object Adapter (BOA) and the Portable Object Adapter (POA). The BOA was the original adapter specified by the CORBA standard. The POA was designed to replace the BOA and is considerably more flexible and most commonly used. The BOA is a barebones adapter that has minimal capabilities. However, the BOA can be used to activate object implementations based on information stored in the Implementation Repository. Table 8-4 contains some of the commonly found elements in an Implementation Repository. The BOA uses the activation mode and the path from the Implementation Repository to start the execution of a producer or server object. Although some of the simpler examples in this chapter used the BOA, we recommend that you use the POA for any serious CORBA development. The POA:
Table 8-4. Some Commonly Found Elements in an Implementation Repository
Perhaps the most important function of the POA is to interact with servant objects. The CORBA specification defines a servant accordingly :
Every servant object will have at least one POA. However, other configurations are possible. Figure 8-9 shows the configuration possibilities between POAs and servants. Figure 8-9. Configuration possibilities between POAs and servants.
POAs are managed in part by POA manager objects. The CORBA specification defines a POA manager accordingly.
The server in Program 8.3 provides a simple example of how to use POAs and POA manager objects. A complete discussion of the POA is beyond the scope of this book. For a thorough discussion of POAs, see Advanced CORBA Programming with C++ by Michi Henning and Steve Vinoski. The MICO distribution also contains several examples of how to use some of the more advanced features of the POA. |