7.17.3. Object Adapter

The object adapter delivers requests to servants using a mapping from object ID values to servant references. An object ID is an opaque sequence of octets assigned to each object by the server. Incoming requests identify the target objects using their object ID.

The object adapter specification supports multiple configurations that govern the process of delivering requests to servants. Some configurations use an active object map to map object ID values to servant references. Other configurations use custom servant managers to determine the mapping. It is also possible to configure the threading model used to invoke servants. The configuration is set using policies.

Figure 7.32. Object Adapter Configuration

local interface POA
{
  POA create_POA (in string adapter_name,
                  in POAManager manager,
                  in CORBA::PolicyList policies);

  ThreadPolicy create_thread_policy (in ThreadPolicyValue value);
  LifespanPolicy create_lifespan_policy (in LifespanPolicyValue value);
  ServantRetentionPolicy create_servant_retention_policy (in ServantRetentionPolicyValue value);
  RequestProcessingPolicy create_request_processing_policy (in RequestProcessingPolicyValue value);

  ...
};

local interface POAManager
{
  enum State { HOLDING, ACTIVE, DISCARDING, INACTIVE };
  State get_state ();

  void activate () raises (AdapterInactive);
  void hold_requests (in boolean wait_for_completion) raises (AdapterInactive);
  void discard_requests (in boolean wait_for_completion) raises (AdapterInactive);

  void deactivate (in boolean etherealize_objects,
                   in boolean wait_for_completion);
};

The threading model configuration is restricted to general categories. A particular object adapter implementation can provide more detailed threading model configuration. Typical configurations include the single threaded model and the leader-follower thread pool model.

The object identity policies default to an automatically assigned system identity. Explicit configuration allows for custom identities, useful especially when object state is external, rather than encapsulated in the servant. Each servant can query the object identity associated with current request.

Figure 7.33. Object Activation

ObjectId activate_object (in Servant servant) raises (ServantAlreadyActive, WrongPolicy);

void activate_object_with_id (in ObjectId oid, in Servant servant)
raises (ObjectAlreadyActive, ServantAlreadyActive, WrongPolicy);

void deactivate_object (in ObjectId oid) raises (ObjectNotActive, WrongPolicy);

Object create_reference (in CORBA::RepositoryId ifc) raises (WrongPolicy);
Object create_reference_with_id (in ObjectId oid, in CORBA::RepositoryId ifc);

Object servant_to_reference (in Servant servant) raises (ServantNotActive, WrongPolicy);
Servant reference_to_servant (in Object reference) raises (ObjectNotActive, WrongAdapter, WrongPolicy);

Figure 7.34. Current Object Interface

local interface Current
{
  POA get_POA () raises (NoContext);
  ObjectId get_object_id () raises (NoContext);
  Object get_reference () raises (NoContext);
  Servant get_servant () raises (NoContext);
};

A request can be delivered to a servant tracked in the active object map, a servant identified by one of the two servant manager types, or a default servant.

Figure 7.35. Servant Activator Interface

local interface ServantActivator : ServantManager
{
  Servant incarnate (in ObjectId oid,
                     in POA adapter)
  raises (ForwardRequest);

  void etherealize (in ObjectId oid,
                    in POA adapter,
                    in Servant servant,
                    in boolean cleanup_in_progress,
                    in boolean remaining_activations};
};

Figure 7.36. Servant Locator Interface

local interface ServantLocator : ServantManager
{
  native Cookie;

  Servant preinvoke (in ObjectId oid,
                     in POA adapter,
                     in CORBA::Identifier operation,
                     out Cookie cookie)
  raises (ForwardRequest);

  void postinvoke (in ObjectId oid,
                   in POA adapter,
                   in CORBA::Identifier operation,
                   in Cookie cookie,
                   in Servant servant);
};

A request forwarding mechanism supports creating object references whose lifetime exceeds that of the server.

Figure 7.37. Request Forward Exception

exception ForwardRequest
{
  Object forward_reference;
};