[Enterprise Extensions only]

Object::_duplicate

Overview Duplicates an object reference.
Original class CORBA::Object


Intended Usage

This method is intended to be used by client and server applications, to duplicate object references (both pointers to local implementation objects and proxies to remote objects). For each duplication performed on an object reference, an equal number of alls to CORBA::release must also be made for the reference to be deleted.

When an application passes an object reference (either a local object or a proxy) on a method call, either as a parameter value or a return result, if the call transfers ownership of the object reference and the application needs to retain ownership of the reference as well, the application should first duplicate the reference before passing it. Each user of the reference should subsequently CORBA::release the reference so that its resources can be reclaimed.

When CORBA::Object::_duplicate is called on a proxy object, only the proxy is affected; no remote invocation is made to the remote object to which the proxy refers. Hence, CORBA::Object::_duplicate and CORBA::release are only used to manage the local resources associated with object references.

IDL Syntax

  static CORBA::Object_ptr _duplicate (CORBA::Object_ptr obj);

Input parameters

obj
The object reference to be duplicated., If this parameter is a nil object referce (NULL), no action is taken.

Return values

CORBA::Object_ptr
The duplicate of the input object reference. (Because CORBA::Object::_duplicate and CORBA::release are implemented using reference couting, this will be the same as the input value.) If the input value is a nil reference, the return value will likewis e be nil.

Example

  /*The following example is written in C++*/
  #include "corba.h"
 
  /* this function returns duplicate of an object ref */
  ::CORBA::Object_ptr getObj(::CORBA::Object_ptr p)
  {
    return CORBA::Object::_duplicate(p);
  }