Previous Table of Contents Next


4.7 Current Object

   ORB and CORBA services may wish to provide access to information (context) associated with the thread of execution in which they are running. This information is accessed in a structured manner using interfaces derived from the Current interface defined in the CORBA module.

   Each ORB or CORBA service that needs its own context derives an interface from the CORBA module's Current. Users of the service can obtain an instance of the appropriate Current interface by invoking ORB::resolve_initial_references. For example the Security service obtains the Current relevant to it by invoking

   ORB::resolve_initial_references(“SecurityCurrent?)

   A CORBA service does not have to use this method of keeping context but may choose to do so.

   module CORBA { // interface for the Current object local interface Current { };

   };

   Operations on interfaces derived from Current access state associated with the thread in which they are invoked, not state associated with the thread from which the Current was obtained. This prevents one thread from manipulating another thread's state, and avoids the need to obtain and narrow a new Current in each method's thread context.

   Current objects must not be exported to other processes, or externalized with ORB::object_to_string. If any attempt is made to do so, the offending operation will raise a MARSHAL system exception. Currents are per-process singleton objects, so no destroy operation is needed.