Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Advanced CORBA Programming wit C++ - M. Henning, S. Vinoski.pdf
Скачиваний:
65
Добавлен:
24.05.2014
Размер:
5 Mб
Скачать

IT-SC book: Advanced CORBA® Programming with C++

CORBA object to replace the now non-existent one. For example, if invoking an operation on a Thermostat results in an OBJECT_NOT_EXIST exception, you would expect that the actual thermostat device no longer exists, and would not expect that someone has destroyed the CORBA object that represents it.

The end result of misusing transient objects for objects with persistent state is that clients cannot reliably determine whether or not an object actually still exists via the OBJECT_NOT_EXIST exception. Instead, they must rely on user-defined exceptions thrown from the factory operations used to create the transient objects. This approach goes against one of the fundamental tenets of CORBA: object references should shield clients from the activation states of both servers and objects.

CORBA provides no way for client applications to determine whether an object reference refers to a transient object or a persistent one, and it is not clear that it should allow clients to make such a determination. Therefore, to set client expectations appropriately, server applications should document those operations that return transient object references. In particular, clients should know that converting transient object references to strings and storing them for later use is most likely a waste of time. By the time they attempt to use them again, the objects they refer to will most likely no longer exist.

11.15 Summary

This chapter presents the details of the Portable Object Adapter. To support a wide range of applications, the POA is very flexible, and it thus has a large feature set. Trying to learn all the POA features all at once can be daunting even for CORBA programmers who already have experience with other object adapters.

POAs deal mainly with three entities: object references, object identifiers (ObjectIds), and servants. POAs create object references, map objects to servants using object identifiers, and dispatch requests to servants. Much of the flexibility that the POA provides is intended to allow applications to control the mapping of objects to servants.

Many POA features are directly controlled by applications through the use of POA policies. Policies are locality-constrained CORBA objects that are used to configure certain aspects of a POA when it is created. Object life span, request dispatching, and whether a POA is singleor multithreaded can all be controlled through POA policy objects. This chapter describes various policy combinations and explains how they apply to different types of common applications.

Our presentation of the various features of the POA roughly follows the ordinary life cycle of a CORBA object and its servants. The POA allows CORBA objects and their object references to be created either with or without a servant. Applications can explicitly register servants for their objects, or they can supply servant managers to provide servants on demand as requests arrive. Servant managers are local CORBA objects that are implemented by the application. They help the POA map object identifiers for objects that are the targets of requests to servants that carry out those

466

IT-SC book: Advanced CORBA® Programming with C++

requests. The POAManager and ORB interfaces also allow applications to control the flow of requests to servants and to integrate ORB event handling with event-handling loops for other software, such as GUI systems. This chapter also explains the conditions under which both servant and POAs can be safely destroyed.

Overall, the POA provides outstanding flexibility to allow applications to control the allocation of servants to objects, the allocation of requests to threads and to servants, and the allocation of objects to POAs. Although there will always be application niches that are better served by specialized object adapters, the POA is flexible enough to support the vast majority of CORBA server applications.

467