Object Identity

From Apache OpenOffice Wiki
Jump to: navigation, search



UNO guarantees if two object references are identical, that a check is performed and it always leads to a correct result, whether it be true or false. This is different from CORBA, where a return of false does not necessarily mean that the objects are different.

Every UNO runtime environment defines how this check should be performed. In Java UNO, there is a static areSame() function at the com.sun.star.uno.UnoRuntime class. In C++, the check is performed with the Reference<>::operator == () function that queries both references for XInterface and compares the resulting XInterface pointers.

This has a direct effect in the API design. For instance, look at com.sun.star.lang.XComponent:

  interface XComponent: com::sun::star::uno::XInterface
  { 
      void dispose(); 
      void addEventListener( [in] XEventListener xListener ); 
      void removeEventListener( [in] XEventListener aListener ); 
  };

The method removeEventListener() that takes a listener reference, is logical if the implementation can check for object identity, otherwise it could not identify the listener that has to be removed. CORBA interfaces are not designed in this manner. They need an object ID, because object identity is not guaranteed.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages